ruby-prof 1.5.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +13 -0
  3. data/ext/ruby_prof/rp_allocation.c +136 -81
  4. data/ext/ruby_prof/rp_allocation.h +8 -6
  5. data/ext/ruby_prof/rp_call_tree.c +8 -1
  6. data/ext/ruby_prof/rp_measurement.c +10 -3
  7. data/ext/ruby_prof/rp_method.c +51 -76
  8. data/ext/ruby_prof/rp_profile.c +62 -77
  9. data/ext/ruby_prof/rp_profile.h +1 -0
  10. data/ext/ruby_prof/rp_thread.c +14 -4
  11. data/ext/ruby_prof/vc/ruby_prof.vcxproj +1 -1
  12. data/lib/ruby-prof/compatibility.rb +14 -0
  13. data/lib/ruby-prof/printers/abstract_printer.rb +1 -1
  14. data/lib/ruby-prof/printers/call_tree_printer.rb +1 -1
  15. data/lib/ruby-prof/printers/multi_printer.rb +17 -17
  16. data/lib/ruby-prof/profile.rb +5 -5
  17. data/lib/ruby-prof/rack.rb +31 -21
  18. data/lib/ruby-prof/version.rb +1 -1
  19. data/test/abstract_printer_test.rb +1 -0
  20. data/test/alias_test.rb +6 -11
  21. data/test/call_tree_visitor_test.rb +1 -6
  22. data/test/call_trees_test.rb +2 -2
  23. data/test/{basic_test.rb → compatibility_test.rb} +8 -2
  24. data/test/duplicate_names_test.rb +1 -1
  25. data/test/dynamic_method_test.rb +1 -6
  26. data/test/enumerable_test.rb +1 -1
  27. data/test/exceptions_test.rb +2 -2
  28. data/test/exclude_methods_test.rb +3 -8
  29. data/test/exclude_threads_test.rb +4 -9
  30. data/test/fiber_test.rb +4 -9
  31. data/test/gc_test.rb +2 -1
  32. data/test/inverse_call_tree_test.rb +33 -34
  33. data/test/line_number_test.rb +1 -1
  34. data/test/marshal_test.rb +3 -3
  35. data/test/measure_allocations_test.rb +8 -17
  36. data/test/measure_memory_test.rb +3 -12
  37. data/test/measure_process_time_test.rb +29 -34
  38. data/test/measure_wall_time_test.rb +176 -181
  39. data/test/multi_printer_test.rb +0 -5
  40. data/test/no_method_class_test.rb +1 -1
  41. data/test/pause_resume_test.rb +12 -16
  42. data/test/printer_call_stack_test.rb +2 -2
  43. data/test/printer_call_tree_test.rb +2 -2
  44. data/test/printer_flat_test.rb +1 -1
  45. data/test/printer_graph_html_test.rb +2 -2
  46. data/test/printer_graph_test.rb +2 -2
  47. data/test/printers_test.rb +14 -20
  48. data/test/printing_recursive_graph_test.rb +2 -2
  49. data/test/recursive_test.rb +2 -7
  50. data/test/singleton_test.rb +1 -1
  51. data/test/stack_printer_test.rb +5 -8
  52. data/test/start_stop_test.rb +11 -14
  53. data/test/thread_test.rb +13 -15
  54. data/test/unique_call_path_test.rb +4 -4
  55. data/test/yarv_test.rb +3 -3
  56. metadata +4 -4
data/test/alias_test.rb CHANGED
@@ -15,13 +15,8 @@ class AliasTest < TestCase
15
15
  end
16
16
  end
17
17
 
18
- def setup
19
- # Need to use wall time for this test due to the sleep calls
20
- RubyProf::measure_mode = RubyProf::WALL_TIME
21
- end
22
-
23
18
  def test_alias
24
- result = RubyProf.profile do
19
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
25
20
  TestMe.new.some_method
26
21
  end
27
22
 
@@ -31,7 +26,7 @@ class AliasTest < TestCase
31
26
  # Method 0
32
27
  method = methods[0]
33
28
  assert_equal('AliasTest#test_alias', method.full_name)
34
- assert_equal(25, method.line)
29
+ assert_equal(20, method.line)
35
30
  refute(method.recursive?)
36
31
 
37
32
  assert_equal(0, method.call_trees.callers.count)
@@ -39,11 +34,11 @@ class AliasTest < TestCase
39
34
  assert_equal(2, method.call_trees.callees.count)
40
35
  call_tree = method.call_trees.callees[0]
41
36
  assert_equal('Class#new', call_tree.target.full_name)
42
- assert_equal(25, call_tree.line)
37
+ assert_equal(20, call_tree.line)
43
38
 
44
39
  call_tree = method.call_trees.callees[1]
45
40
  assert_equal('AliasTest::TestMe#some_method', call_tree.target.full_name)
46
- assert_equal(25, call_tree.line)
41
+ assert_equal(20, call_tree.line)
47
42
 
48
43
  # Method 1
49
44
  method = methods[1]
@@ -54,7 +49,7 @@ class AliasTest < TestCase
54
49
  assert_equal(1, method.call_trees.callers.count)
55
50
  call_tree = method.call_trees.callers[0]
56
51
  assert_equal('AliasTest#test_alias', call_tree.parent.target.full_name)
57
- assert_equal(25, call_tree.line)
52
+ assert_equal(20, call_tree.line)
58
53
 
59
54
  assert_equal(1, method.call_trees.callees.count)
60
55
  call_tree = method.call_trees.callees[0]
@@ -83,7 +78,7 @@ class AliasTest < TestCase
83
78
  assert_equal(1, method.call_trees.callers.count)
84
79
  call_tree = method.call_trees.callers[0]
85
80
  assert_equal('AliasTest#test_alias', call_tree.parent.target.full_name)
86
- assert_equal(25, call_tree.line)
81
+ assert_equal(20, call_tree.line)
87
82
 
88
83
  assert_equal(1, method.call_trees.callees.count)
89
84
  call_tree = method.call_trees.callees[0]
@@ -5,13 +5,8 @@ require File.expand_path('../test_helper', __FILE__)
5
5
  require_relative './measure_times'
6
6
 
7
7
  class CallTreeVisitorTest < TestCase
8
- def setup
9
- # Need to use wall time for this test due to the sleep calls
10
- RubyProf::measure_mode = RubyProf::WALL_TIME
11
- end
12
-
13
8
  def test_visit
14
- result = RubyProf.profile do
9
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
15
10
  RubyProf::C1.sleep_wait
16
11
  end
17
12
 
@@ -13,7 +13,7 @@ class CallTreesTest < TestCase
13
13
  end
14
14
 
15
15
  def test_call_infos
16
- result = RubyProf.profile do
16
+ result = RubyProf::Profile.profile do
17
17
  some_method_1
18
18
  end
19
19
 
@@ -51,7 +51,7 @@ class CallTreesTest < TestCase
51
51
  end
52
52
 
53
53
  def test_gc
54
- result = RubyProf.profile do
54
+ result = RubyProf::Profile.profile do
55
55
  some_method_1
56
56
  end
57
57
 
@@ -4,12 +4,18 @@
4
4
  require File.expand_path('../test_helper', __FILE__)
5
5
  require_relative './measure_times'
6
6
 
7
- class BasicTest < TestCase
7
+ class CompatibilityTest < TestCase
8
8
  def setup
9
- # Need to use wall time for this test due to the sleep calls
9
+ super
10
+ Gem::Deprecate.skip = true
10
11
  RubyProf::measure_mode = RubyProf::WALL_TIME
11
12
  end
12
13
 
14
+ def teardown
15
+ super
16
+ Gem::Deprecate.skip = false
17
+ end
18
+
13
19
  def test_running
14
20
  assert(!RubyProf.running?)
15
21
  RubyProf.start
@@ -5,7 +5,7 @@ require File.expand_path('../test_helper', __FILE__)
5
5
 
6
6
  class DuplicateNamesTest < TestCase
7
7
  def test_names
8
- result = RubyProf::profile do
8
+ result = RubyProf::Profile.profile do
9
9
  str = %{module Foo; class Bar; def foo; end end end}
10
10
 
11
11
  eval str
@@ -24,14 +24,9 @@ class DynamicMethodTest < TestCase
24
24
  end
25
25
  end
26
26
 
27
- def setup
28
- # Need to use wall time for this test due to the sleep calls
29
- RubyProf::measure_mode = RubyProf::WALL_TIME
30
- end
31
-
32
27
  def test_dynamic_method
33
28
  medley = FruitMedley.new
34
- result = RubyProf.profile do
29
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
35
30
  medley.apple
36
31
  medley.orange
37
32
  medley.banana
@@ -8,7 +8,7 @@ require File.expand_path('../test_helper', __FILE__)
8
8
 
9
9
  class EnumerableTest < TestCase
10
10
  def test_enumerable
11
- result = RubyProf.profile do
11
+ result = RubyProf::Profile.profile do
12
12
  3.times { [1,2,3].any? {|n| n} }
13
13
  end
14
14
  methods = if RUBY_VERSION >= "2.2.0"
@@ -6,7 +6,7 @@ require File.expand_path('../test_helper', __FILE__)
6
6
  class ExceptionsTest < TestCase
7
7
  def test_profile
8
8
  result = begin
9
- RubyProf.profile do
9
+ RubyProf::Profile.profile do
10
10
  raise(RuntimeError, 'Test error')
11
11
  end
12
12
  rescue
@@ -16,7 +16,7 @@ class ExceptionsTest < TestCase
16
16
 
17
17
  def test_profile_allows_exceptions
18
18
  assert_raises(RuntimeError) do
19
- RubyProf.profile(:allow_exceptions => true) do
19
+ RubyProf::Profile.profile(:allow_exceptions => true) do
20
20
  raise(RuntimeError, 'Test error')
21
21
  end
22
22
  end
@@ -34,14 +34,9 @@ class ExcludeMethodsClass
34
34
  end
35
35
 
36
36
  class ExcludeMethodsTest < TestCase
37
- def setup
38
- # Need to use wall time for this test due to the sleep calls
39
- RubyProf::measure_mode = RubyProf::WALL_TIME
40
- end
41
-
42
37
  def test_methods_can_be_profiled
43
38
  obj = ExcludeMethodsClass.new
44
- prf = RubyProf::Profile.new
39
+ prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
45
40
 
46
41
  result = prf.profile {obj.a}
47
42
  methods = result.threads.first.methods.sort.reverse
@@ -102,7 +97,7 @@ class ExcludeMethodsTest < TestCase
102
97
 
103
98
  def test_exclude_common_methods1
104
99
  obj = ExcludeMethodsClass.new
105
- prf = RubyProf::Profile.new
100
+ prf = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
106
101
 
107
102
  prf.exclude_common_methods!
108
103
 
@@ -124,7 +119,7 @@ class ExcludeMethodsTest < TestCase
124
119
  def test_exclude_common_methods2
125
120
  obj = ExcludeMethodsClass.new
126
121
 
127
- result = RubyProf.profile(exclude_common: true) { 5.times {obj.a} }
122
+ result = RubyProf::Profile.profile(exclude_common: true) { 5.times {obj.a} }
128
123
  methods = result.threads.first.methods.sort.reverse
129
124
 
130
125
  assert_equal(9, methods.count)
@@ -26,15 +26,10 @@ class ExcludeThreadsTest < TestCase
26
26
  thread2_proc
27
27
  end
28
28
 
29
- # exclude_threads already includes the minitest thread pool
30
- RubyProf.exclude_threads += [ thread2 ]
31
-
32
- RubyProf.start
33
-
34
- thread1.join
35
- thread2.join
36
-
37
- result = RubyProf.stop
29
+ result = RubyProf::Profile.profile(exclude_threads: [thread2]) do
30
+ thread1.join
31
+ thread2.join
32
+ end
38
33
 
39
34
  assert_equal(2, result.threads.length)
40
35
 
data/test/fiber_test.rb CHANGED
@@ -46,13 +46,8 @@ class FiberTest < TestCase
46
46
  fiber.resume
47
47
  end
48
48
 
49
- def setup
50
- # Need to use wall time for this test due to the sleep calls
51
- RubyProf::measure_mode = RubyProf::WALL_TIME
52
- end
53
-
54
49
  def test_fibers
55
- result = RubyProf.profile { enumerator_with_fibers }
50
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { enumerator_with_fibers }
56
51
 
57
52
  assert_equal(2, result.threads.size)
58
53
 
@@ -142,7 +137,7 @@ class FiberTest < TestCase
142
137
  end
143
138
 
144
139
  def test_fiber_resume
145
- result = RubyProf.profile { fiber_yield_resume }
140
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { fiber_yield_resume }
146
141
 
147
142
  assert_equal(2, result.threads.size)
148
143
 
@@ -217,7 +212,7 @@ class FiberTest < TestCase
217
212
 
218
213
  if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0')
219
214
  def test_times_no_merge
220
- result = RubyProf.profile { concurrency }
215
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency }
221
216
 
222
217
  assert_equal(4, result.threads.size)
223
218
 
@@ -230,7 +225,7 @@ class FiberTest < TestCase
230
225
  end
231
226
 
232
227
  def test_times_merge
233
- result = RubyProf.profile { concurrency }
228
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency }
234
229
  result.merge!
235
230
 
236
231
  assert_equal(2, result.threads.size)
data/test/gc_test.rb CHANGED
@@ -6,6 +6,7 @@ Minitest::Test.i_suck_and_my_tests_are_order_dependent!
6
6
 
7
7
  class GcTest < TestCase
8
8
  def setup
9
+ super
9
10
  GC.stress = true
10
11
  end
11
12
 
@@ -18,7 +19,7 @@ class GcTest < TestCase
18
19
  end
19
20
 
20
21
  def run_profile
21
- RubyProf.profile do
22
+ RubyProf::Profile.profile do
22
23
  self.some_method
23
24
  end
24
25
  end
@@ -4,18 +4,17 @@
4
4
  require File.expand_path('../test_helper', __FILE__)
5
5
 
6
6
  class InverseCallTreeTest < TestCase
7
- INVERSE_DEPTH = 5
8
-
9
7
  def setup
10
- # Need to use wall time for this test due to the sleep calls
11
- RubyProf::measure_mode = RubyProf::WALL_TIME
8
+ super
9
+ @profile = RubyProf::Profile.new
12
10
  end
11
+ INVERSE_DEPTH = 5
13
12
 
14
13
  INVERSE_DEPTH.times do |i|
15
14
  if i == 0
16
15
  define_method("method_#{i}") do
17
16
  sleep_amount = (i + 1) * 0.05
18
- RubyProf.start
17
+ @profile.start
19
18
  sleep(sleep_amount)
20
19
  end
21
20
  else
@@ -31,11 +30,11 @@ class InverseCallTreeTest < TestCase
31
30
  def test_inverse
32
31
  method_name = "method_#{INVERSE_DEPTH - 1}"
33
32
  self.send(method_name.to_sym)
34
- profile = RubyProf.stop
33
+ result = @profile.stop
35
34
 
36
- assert_equal(1, profile.threads.count)
35
+ assert_equal(1, result.threads.count)
37
36
 
38
- thread = profile.threads.first
37
+ thread = result.threads.first
39
38
  assert_in_delta(0.79, thread.total_time, 0.05)
40
39
 
41
40
  assert_equal(7, thread.methods.length)
@@ -44,29 +43,29 @@ class InverseCallTreeTest < TestCase
44
43
  # InverseCallTreeTest#test_inverse
45
44
  method = methods[0]
46
45
  assert_equal('InverseCallTreeTest#test_inverse', method.full_name)
47
- assert_equal(34, method.line)
46
+ assert_equal(33, method.line)
48
47
 
49
48
  assert_equal(0, method.call_trees.callers.count)
50
49
 
51
50
  assert_equal(1, method.call_trees.callees.count)
52
51
  call_tree = method.call_trees.callees[0]
53
52
  assert_equal('InverseCallTreeTest#method_4', call_tree.target.full_name)
54
- assert_equal(26, call_tree.line)
53
+ assert_equal(25, call_tree.line)
55
54
 
56
55
  # InverseCallTreeTest#method_4
57
56
  method = methods[1]
58
57
  assert_equal('InverseCallTreeTest#method_4', method.full_name)
59
- assert_equal(26, method.line)
58
+ assert_equal(25, method.line)
60
59
 
61
60
  assert_equal(1, method.call_trees.callers.count)
62
61
  call_tree = method.call_trees.callers[0]
63
62
  assert_equal('InverseCallTreeTest#test_inverse', call_tree.parent.target.full_name)
64
- assert_equal(26, call_tree.line)
63
+ assert_equal(25, call_tree.line)
65
64
 
66
65
  assert_equal(2, method.call_trees.callees.count)
67
66
  call_tree = method.call_trees.callees[0]
68
67
  assert_equal('InverseCallTreeTest#method_3', call_tree.target.full_name)
69
- assert_equal(26, call_tree.line)
68
+ assert_equal(25, call_tree.line)
70
69
 
71
70
  # Kernel#sleep
72
71
  method = methods[2]
@@ -76,100 +75,100 @@ class InverseCallTreeTest < TestCase
76
75
  assert_equal(5, method.call_trees.callers.count)
77
76
  call_tree = method.call_trees.callers[0]
78
77
  assert_equal('InverseCallTreeTest#method_0', call_tree.parent.target.full_name)
79
- assert_equal(19, call_tree.line)
78
+ assert_equal(18, call_tree.line)
80
79
 
81
80
  call_tree = method.call_trees.callers[1]
82
81
  assert_equal('InverseCallTreeTest#method_1', call_tree.parent.target.full_name)
83
- assert_equal(26, call_tree.line)
82
+ assert_equal(25, call_tree.line)
84
83
 
85
84
  call_tree = method.call_trees.callers[2]
86
85
  assert_equal('InverseCallTreeTest#method_2', call_tree.parent.target.full_name)
87
- assert_equal(26, call_tree.line)
86
+ assert_equal(25, call_tree.line)
88
87
  call_tree = method.call_trees.callers[3]
89
88
 
90
89
  assert_equal('InverseCallTreeTest#method_3', call_tree.parent.target.full_name)
91
- assert_equal(26, call_tree.line)
90
+ assert_equal(25, call_tree.line)
92
91
 
93
92
  call_tree = method.call_trees.callers[4]
94
93
  assert_equal('InverseCallTreeTest#method_4', call_tree.parent.target.full_name)
95
- assert_equal(26, call_tree.line)
94
+ assert_equal(25, call_tree.line)
96
95
 
97
96
  assert_equal(0, method.call_trees.callees.count)
98
97
 
99
98
  # InverseCallTreeTest#method_3
100
99
  method = methods[3]
101
100
  assert_equal('InverseCallTreeTest#method_3', method.full_name)
102
- assert_equal(26, method.line)
101
+ assert_equal(25, method.line)
103
102
 
104
103
  assert_equal(1, method.call_trees.callers.count)
105
104
  call_tree = method.call_trees.callers[0]
106
105
  assert_equal('InverseCallTreeTest#method_4', call_tree.parent.target.full_name)
107
- assert_equal(26, call_tree.line)
106
+ assert_equal(25, call_tree.line)
108
107
 
109
108
  assert_equal(2, method.call_trees.callees.count)
110
109
  call_tree = method.call_trees.callees[0]
111
110
  assert_equal('InverseCallTreeTest#method_2', call_tree.target.full_name)
112
- assert_equal(26, call_tree.line)
111
+ assert_equal(25, call_tree.line)
113
112
 
114
113
  call_tree = method.call_trees.callees[1]
115
114
  assert_equal('Kernel#sleep', call_tree.target.full_name)
116
- assert_equal(26, call_tree.line)
115
+ assert_equal(25, call_tree.line)
117
116
 
118
117
  # InverseCallTreeTest#method_2
119
118
  method = methods[4]
120
119
  assert_equal('InverseCallTreeTest#method_2', method.full_name)
121
- assert_equal(26, method.line)
120
+ assert_equal(25, method.line)
122
121
 
123
122
  assert_equal(1, method.call_trees.callers.count)
124
123
  call_tree = method.call_trees.callers[0]
125
124
  assert_equal('InverseCallTreeTest#method_3', call_tree.parent.target.full_name)
126
- assert_equal(26, call_tree.line)
125
+ assert_equal(25, call_tree.line)
127
126
 
128
127
  assert_equal(2, method.call_trees.callees.count)
129
128
  call_tree = method.call_trees.callees[0]
130
129
  assert_equal('InverseCallTreeTest#method_1', call_tree.target.full_name)
131
- assert_equal(26, call_tree.line)
130
+ assert_equal(25, call_tree.line)
132
131
 
133
132
  call_tree = method.call_trees.callees[1]
134
133
  assert_equal('Kernel#sleep', call_tree.target.full_name)
135
- assert_equal(26, call_tree.line)
134
+ assert_equal(25, call_tree.line)
136
135
 
137
136
  call_tree = method.call_trees.callees[1]
138
137
  assert_equal('Kernel#sleep', call_tree.target.full_name)
139
- assert_equal(26, call_tree.line)
138
+ assert_equal(25, call_tree.line)
140
139
 
141
140
  # InverseCallTreeTest#method_1
142
141
  method = methods[5]
143
142
  assert_equal('InverseCallTreeTest#method_1', method.full_name)
144
- assert_equal(26, method.line)
143
+ assert_equal(25, method.line)
145
144
 
146
145
  assert_equal(1, method.call_trees.callers.count)
147
146
  call_tree = method.call_trees.callers[0]
148
147
  assert_equal('InverseCallTreeTest#method_2', call_tree.parent.target.full_name)
149
- assert_equal(26, call_tree.line)
148
+ assert_equal(25, call_tree.line)
150
149
 
151
150
  assert_equal(2, method.call_trees.callees.count)
152
151
  call_tree = method.call_trees.callees[0]
153
152
  assert_equal('InverseCallTreeTest#method_0', call_tree.target.full_name)
154
- assert_equal(19, call_tree.line)
153
+ assert_equal(18, call_tree.line)
155
154
 
156
155
  call_tree = method.call_trees.callees[1]
157
156
  assert_equal('Kernel#sleep', call_tree.target.full_name)
158
- assert_equal(26, call_tree.line)
157
+ assert_equal(25, call_tree.line)
159
158
 
160
159
  # InverseCallTreeTest#method_0
161
160
  method = methods[6]
162
161
  assert_equal('InverseCallTreeTest#method_0', method.full_name)
163
- assert_equal(19, method.line)
162
+ assert_equal(18, method.line)
164
163
 
165
164
  assert_equal(1, method.call_trees.callers.count)
166
165
  call_tree = method.call_trees.callers[0]
167
166
  assert_equal('InverseCallTreeTest#method_1', call_tree.parent.target.full_name)
168
- assert_equal(19, call_tree.line)
167
+ assert_equal(18, call_tree.line)
169
168
 
170
169
  assert_equal(1, method.call_trees.callees.count)
171
170
  call_tree = method.call_trees.callees[0]
172
171
  assert_equal('Kernel#sleep', call_tree.target.full_name)
173
- assert_equal(19, call_tree.line)
172
+ assert_equal(18, call_tree.line)
174
173
  end
175
174
  end
@@ -31,7 +31,7 @@ class LineNumbersTest < TestCase
31
31
  def test_function_line_no
32
32
  numbers = LineNumbers.new
33
33
 
34
- result = RubyProf.profile do
34
+ result = RubyProf::Profile.profile do
35
35
  numbers.method_1
36
36
  end
37
37
 
data/test/marshal_test.rb CHANGED
@@ -111,7 +111,7 @@ class MarshalTest < TestCase
111
111
  end
112
112
 
113
113
  def test_marshal_1
114
- profile_1 = RubyProf.profile(:measure_mode => RubyProf::WALL_TIME) do
114
+ profile_1 = RubyProf::Profile.profile(:measure_mode => RubyProf::WALL_TIME) do
115
115
  1.times { RubyProf::C1.new.sleep_wait }
116
116
  end
117
117
 
@@ -122,7 +122,7 @@ class MarshalTest < TestCase
122
122
  end
123
123
 
124
124
  def test_marshal_2
125
- profile_1 = RubyProf.profile(:measure_mode => RubyProf::PROCESS_TIME, :track_allocations => true) do
125
+ profile_1 = RubyProf::Profile.profile(:measure_mode => RubyProf::PROCESS_TIME, :track_allocations => true) do
126
126
  1.times { RubyProf::C1.new.sleep_wait }
127
127
  end
128
128
 
@@ -133,7 +133,7 @@ class MarshalTest < TestCase
133
133
  end
134
134
 
135
135
  def test_singleton
136
- profile_1 = RubyProf.profile do
136
+ profile_1 = RubyProf::Profile.profile do
137
137
  SingletonTest.instance.busy_wait
138
138
  end
139
139
 
@@ -4,18 +4,9 @@
4
4
  require File.expand_path('../test_helper', __FILE__)
5
5
  require_relative './measure_allocations'
6
6
 
7
- class MeasureAllocationsTraceTest < TestCase
8
- def setup
9
- RubyProf::measure_mode = RubyProf::ALLOCATIONS
10
- end
11
-
12
- def test_allocations_mode
13
- RubyProf::measure_mode = RubyProf::ALLOCATIONS
14
- assert_equal(RubyProf::ALLOCATIONS, RubyProf::measure_mode)
15
- end
16
-
7
+ class MeasureAllocationsTest < TestCase
17
8
  def test_allocations
18
- result = RubyProf.profile(:track_allocations => true) do
9
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::ALLOCATIONS, track_allocations: true) do
19
10
  allocator = Allocator.new
20
11
  allocator.run
21
12
  end
@@ -29,7 +20,7 @@ class MeasureAllocationsTraceTest < TestCase
29
20
 
30
21
  # Method 0
31
22
  method = methods[0]
32
- assert_equal('MeasureAllocationsTraceTest#test_allocations', method.full_name)
23
+ assert_equal('MeasureAllocationsTest#test_allocations', method.full_name)
33
24
  assert_in_delta(20, method.total_time, 1)
34
25
  assert_equal(0, method.wait_time)
35
26
  assert_equal(0, method.self_time)
@@ -62,7 +53,7 @@ class MeasureAllocationsTraceTest < TestCase
62
53
 
63
54
  assert_equal(1, method.call_trees.callers.length)
64
55
  call_tree = method.call_trees.callers[0]
65
- assert_equal('MeasureAllocationsTraceTest#test_allocations', call_tree.parent.target.full_name)
56
+ assert_equal('MeasureAllocationsTest#test_allocations', call_tree.parent.target.full_name)
66
57
  assert_equal(19, call_tree.total_time)
67
58
  assert_equal(0, call_tree.wait_time)
68
59
  assert_equal(0, call_tree.self_time)
@@ -100,7 +91,7 @@ class MeasureAllocationsTraceTest < TestCase
100
91
 
101
92
  assert_equal(4, method.call_trees.callers.length)
102
93
  call_tree = method.call_trees.callers[0]
103
- assert_equal('MeasureAllocationsTraceTest#test_allocations', call_tree.parent.target.full_name)
94
+ assert_equal('MeasureAllocationsTest#test_allocations', call_tree.parent.target.full_name)
104
95
  assert_equal(1, call_tree.total_time)
105
96
  assert_equal(0, call_tree.wait_time)
106
97
  assert_equal(1, call_tree.self_time)
@@ -335,7 +326,7 @@ class MeasureAllocationsTraceTest < TestCase
335
326
 
336
327
  # Method 0
337
328
  method = methods[0]
338
- assert_equal('MeasureAllocationsTraceTest#test_allocations', method.full_name)
329
+ assert_equal('MeasureAllocationsTest#test_allocations', method.full_name)
339
330
  assert_in_delta(20, method.total_time, 1)
340
331
  assert_equal(0, method.wait_time)
341
332
  assert_equal(0, method.self_time)
@@ -368,7 +359,7 @@ class MeasureAllocationsTraceTest < TestCase
368
359
 
369
360
  assert_equal(1, method.call_trees.callers.length)
370
361
  call_tree = method.call_trees.callers[0]
371
- assert_equal('MeasureAllocationsTraceTest#test_allocations', call_tree.parent.target.full_name)
362
+ assert_equal('MeasureAllocationsTest#test_allocations', call_tree.parent.target.full_name)
372
363
  assert_equal(19, call_tree.total_time)
373
364
  assert_equal(0, call_tree.wait_time)
374
365
  assert_equal(0, call_tree.self_time)
@@ -478,7 +469,7 @@ class MeasureAllocationsTraceTest < TestCase
478
469
 
479
470
  assert_equal(3, method.call_trees.callers.length)
480
471
  call_tree = method.call_trees.callers[0]
481
- assert_equal('MeasureAllocationsTraceTest#test_allocations', call_tree.parent.target.full_name)
472
+ assert_equal('MeasureAllocationsTest#test_allocations', call_tree.parent.target.full_name)
482
473
  assert_equal(1, call_tree.total_time)
483
474
  assert_equal(0, call_tree.wait_time)
484
475
  assert_equal(1, call_tree.self_time)
@@ -5,18 +5,9 @@ require File.expand_path('../test_helper', __FILE__)
5
5
  require_relative './measure_allocations'
6
6
 
7
7
  class MeasureMemoryTest < TestCase
8
- def setup
9
- RubyProf::measure_mode = RubyProf::MEMORY
10
- end
11
-
12
- def test_memory_mode
13
- RubyProf::measure_mode = RubyProf::MEMORY
14
- assert_equal(RubyProf::MEMORY, RubyProf::measure_mode)
15
- end
16
-
17
8
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0')
18
9
  def test_memory
19
- result = RubyProf.profile do
10
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::MEMORY) do
20
11
  allocator = Allocator.new
21
12
  allocator.run
22
13
  end
@@ -351,7 +342,7 @@ class MeasureMemoryTest < TestCase
351
342
  end
352
343
  elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.2')
353
344
  def test_memory
354
- result = RubyProf.profile do
345
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::MEMORY) do
355
346
  allocator = Allocator.new
356
347
  allocator.run
357
348
  end
@@ -686,7 +677,7 @@ class MeasureMemoryTest < TestCase
686
677
  end
687
678
  else
688
679
  def test_memory
689
- result = RubyProf.profile do
680
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::MEMORY) do
690
681
  allocator = Allocator.new
691
682
  allocator.run
692
683
  end