ruby-prof 0.10.6 → 0.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,3 +1,11 @@
1
+ 0.10.7
2
+ ======================
3
+ Fix a bug with REE's GC stats. Issue #53 [thanks graaff]
4
+
5
+ 0.10.6
6
+ ======================
7
+ Slightly more normalized url for linux/windows links to files.
8
+
1
9
  0.10.5
2
10
  =======================
3
11
  1.8.6 compat for -v command (bug fix)
data/examples/empty.png CHANGED
File without changes
data/examples/minus.png CHANGED
File without changes
data/examples/plus.png CHANGED
File without changes
@@ -1078,10 +1078,8 @@ pop_frames(st_data_t key, st_data_t value, st_data_t now_arg)
1078
1078
  }
1079
1079
 
1080
1080
  static void
1081
- prof_pop_threads()
1081
+ prof_pop_threads(prof_measure_t now)
1082
1082
  {
1083
- /* Get current measurement */
1084
- prof_measure_t now = get_measurement();
1085
1083
  st_foreach(threads_tbl, pop_frames, (st_data_t) &now);
1086
1084
  }
1087
1085
 
@@ -1613,6 +1611,10 @@ prof_resume(VALUE self)
1613
1611
  static VALUE
1614
1612
  prof_stop(VALUE self)
1615
1613
  {
1614
+ /* get 'now' before prof emove hook because it calls GC.disable_stats
1615
+ which makes the call within prof_pop_threads of now return 0, which is wrong
1616
+ */
1617
+ prof_measure_t now = get_measurement();
1616
1618
  if (threads_tbl == NULL)
1617
1619
  {
1618
1620
  rb_raise(rb_eRuntimeError, "RubyProf.start was not yet called");
@@ -1626,10 +1628,10 @@ prof_stop(VALUE self)
1626
1628
  fclose(trace_file);
1627
1629
  trace_file = NULL;
1628
1630
  }
1629
-
1631
+
1630
1632
  prof_remove_hook();
1631
1633
 
1632
- prof_pop_threads();
1634
+ prof_pop_threads(now);
1633
1635
 
1634
1636
  /* Create the result */
1635
1637
  result = prof_result_new();
@@ -1,4 +1,4 @@
1
- #define RUBY_PROF_VERSION "0.10.6" // for easy parsing from rake files
1
+ #define RUBY_PROF_VERSION "0.10.7" // for easy parsing from rake files
2
2
  #define RUBY_PROF_VERSION_MAJ 0
3
3
  #define RUBY_PROF_VERSION_MIN 10
4
- #define RUBY_PROF_VERSION_MIC 6
4
+ #define RUBY_PROF_VERSION_MIC 7
File without changes
File without changes
File without changes
File without changes
File without changes
data/test/basic_test.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
data/test/exec_test.rb CHANGED
File without changes
data/test/go.rb ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'ruby-prof'
4
+
5
+ class MeasurementTest < Test::Unit::TestCase
6
+
7
+ if RubyProf::MEMORY
8
+ def test_memory_mode
9
+ RubyProf::measure_mode = RubyProf::MEMORY
10
+ assert_equal(RubyProf::MEMORY, RubyProf::measure_mode)
11
+ end
12
+
13
+ def test_memory
14
+ t = RubyProf.measure_memory
15
+ assert_kind_of Integer, t
16
+
17
+ u = RubyProf.measure_memory
18
+ assert(u >= t, [t, u].inspect)
19
+
20
+ RubyProf::measure_mode = RubyProf::MEMORY
21
+ result = RubyProf.profile {Array.new}
22
+ require 'rubygems'
23
+ require 'ruby-debug'
24
+ #debugger
25
+ total = result.threads.values.first.inject(0) { |sum, m| sum + m.total_time }
26
+
27
+
28
+ assert(total > 0, 'Should measure more than zero kilobytes of memory usage')
29
+ p total
30
+ assert_not_equal(0, total % 1, 'Should not truncate fractional kilobyte measurements')
31
+ end
32
+ end
33
+ end
File without changes
@@ -4,10 +4,12 @@ require 'ruby-prof'
4
4
 
5
5
  class MeasurementTest < Test::Unit::TestCase
6
6
  def setup
7
+ # also done in C these days...
7
8
  GC.enable_stats if GC.respond_to?(:enable_stats)
8
9
  end
9
10
 
10
11
  def teardown
12
+ # also done in C for normal runs...
11
13
  GC.disable_stats if GC.respond_to?(:disable_stats)
12
14
  end
13
15
 
@@ -69,6 +71,13 @@ class MeasurementTest < Test::Unit::TestCase
69
71
  end
70
72
  end
71
73
 
74
+ def memory_test_helper
75
+ result = RubyProf.profile {Array.new}
76
+ total = result.threads.values.first.inject(0) { |sum, m| sum + m.total_time }
77
+ assert(total < 1_000_000, 'Total should not have subtract overflow error')
78
+ total
79
+ end
80
+
72
81
  if RubyProf::MEMORY
73
82
  def test_memory_mode
74
83
  RubyProf::measure_mode = RubyProf::MEMORY
@@ -81,11 +90,8 @@ class MeasurementTest < Test::Unit::TestCase
81
90
 
82
91
  u = RubyProf.measure_memory
83
92
  assert(u >= t, [t, u].inspect)
84
-
85
93
  RubyProf::measure_mode = RubyProf::MEMORY
86
- result = RubyProf.profile {Array.new}
87
- total = result.threads.values.first.inject(0) { |sum, m| sum + m.total_time }
88
-
94
+ total = memory_test_helper
89
95
  assert(total > 0, 'Should measure more than zero kilobytes of memory usage')
90
96
  assert_not_equal(0, total % 1, 'Should not truncate fractional kilobyte measurements')
91
97
  end
@@ -105,6 +111,8 @@ class MeasurementTest < Test::Unit::TestCase
105
111
 
106
112
  u = RubyProf.measure_gc_runs
107
113
  assert u > t, [t, u].inspect
114
+ RubyProf::measure_mode = RubyProf::GC_RUNS
115
+ memory_test_helper
108
116
  end
109
117
  end
110
118
 
@@ -117,6 +125,8 @@ class MeasurementTest < Test::Unit::TestCase
117
125
 
118
126
  u = RubyProf.measure_gc_time
119
127
  assert u > t, [t, u].inspect
128
+ RubyProf::measure_mode = RubyProf::GC_TIME
129
+ memory_test_helper
120
130
  end
121
131
  end
122
132
  end
data/test/module_test.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -46,7 +46,7 @@ class StackPrinterTest < Test::Unit::TestCase
46
46
  assert file_contents =~ /Thread: (\d+) \(100\.00% ~ ([.0-9]+)\)/
47
47
  actual_time = $2.to_f
48
48
  difference = (expected_time-actual_time).abs
49
- assert difference < 0.01 # less than 1 ms
49
+ assert_in_delta(expected_time, actual_time, 0.01)
50
50
  end
51
51
 
52
52
  def test_method_elimination
data/test/stack_test.rb CHANGED
File without changes
File without changes
data/test/thread_test.rb CHANGED
@@ -155,7 +155,7 @@ class ThreadTest < Test::Unit::TestCase
155
155
  a.join
156
156
  b.join
157
157
  end
158
- assert result.threads.values.flatten.sort[-1].total_time < 10 # 10s
158
+ assert result.threads.values.flatten.sort[-1].total_time < 10 # 10s. Amazingly, this can fail in OS X at times. Amazing.
159
159
  end
160
160
 
161
161
  def test_thread
File without changes
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-prof
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 10
9
- - 6
10
- version: 0.10.6
9
+ - 7
10
+ version: 0.10.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-29 00:00:00 Z
18
+ date: 2011-05-09 00:00:00 -06:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: os
@@ -125,6 +126,7 @@ files:
125
126
  - test/exceptions_test.rb
126
127
  - test/exclude_threads_test.rb
127
128
  - test/exec_test.rb
129
+ - test/go.rb
128
130
  - test/line_number_test.rb
129
131
  - test/measurement_test.rb
130
132
  - test/method_elimination_test.rb
@@ -144,6 +146,7 @@ files:
144
146
  - test/thread_test.rb
145
147
  - test/unique_call_path_test.rb
146
148
  - ext/ruby_prof/extconf.rb
149
+ has_rdoc: true
147
150
  homepage: http://rubyforge.org/projects/ruby-prof/
148
151
  licenses: []
149
152
 
@@ -175,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
178
  requirements: []
176
179
 
177
180
  rubyforge_project: ruby-prof
178
- rubygems_version: 1.7.2
181
+ rubygems_version: 1.6.2
179
182
  signing_key:
180
183
  specification_version: 3
181
184
  summary: Fast Ruby profiler