ruby-prof 1.5.0-x64-mingw-ucrt → 1.6.2-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +19 -0
  3. data/bin/ruby-prof +105 -87
  4. data/ext/ruby_prof/rp_allocation.c +136 -81
  5. data/ext/ruby_prof/rp_allocation.h +8 -6
  6. data/ext/ruby_prof/rp_call_tree.c +502 -457
  7. data/ext/ruby_prof/rp_call_tree.h +47 -44
  8. data/ext/ruby_prof/rp_call_trees.c +1 -1
  9. data/ext/ruby_prof/rp_measurement.c +10 -3
  10. data/ext/ruby_prof/rp_method.c +86 -79
  11. data/ext/ruby_prof/rp_method.h +63 -62
  12. data/ext/ruby_prof/rp_profile.c +933 -948
  13. data/ext/ruby_prof/rp_profile.h +1 -0
  14. data/ext/ruby_prof/rp_thread.c +433 -410
  15. data/ext/ruby_prof/rp_thread.h +39 -39
  16. data/ext/ruby_prof/vc/ruby_prof.vcxproj +6 -3
  17. data/lib/3.1/ruby_prof.so +0 -0
  18. data/lib/3.2/ruby_prof.so +0 -0
  19. data/lib/ruby-prof/compatibility.rb +14 -0
  20. data/lib/ruby-prof/printers/abstract_printer.rb +2 -1
  21. data/lib/ruby-prof/printers/call_tree_printer.rb +1 -1
  22. data/lib/ruby-prof/printers/multi_printer.rb +17 -17
  23. data/lib/ruby-prof/profile.rb +70 -70
  24. data/lib/ruby-prof/rack.rb +31 -21
  25. data/lib/ruby-prof/version.rb +1 -1
  26. data/test/abstract_printer_test.rb +1 -0
  27. data/test/alias_test.rb +6 -11
  28. data/test/call_tree_test.rb +94 -197
  29. data/test/call_tree_visitor_test.rb +1 -6
  30. data/test/call_trees_test.rb +2 -2
  31. data/test/{basic_test.rb → compatibility_test.rb} +8 -2
  32. data/test/duplicate_names_test.rb +1 -1
  33. data/test/dynamic_method_test.rb +1 -6
  34. data/test/enumerable_test.rb +1 -1
  35. data/test/exceptions_test.rb +2 -2
  36. data/test/exclude_methods_test.rb +3 -8
  37. data/test/exclude_threads_test.rb +4 -9
  38. data/test/fiber_test.rb +2 -58
  39. data/test/gc_test.rb +2 -2
  40. data/test/inverse_call_tree_test.rb +33 -34
  41. data/test/line_number_test.rb +1 -1
  42. data/test/marshal_test.rb +3 -3
  43. data/test/measure_allocations_test.rb +8 -17
  44. data/test/measure_memory_test.rb +3 -12
  45. data/test/measure_process_time_test.rb +32 -36
  46. data/test/measure_wall_time_test.rb +176 -181
  47. data/test/merge_test.rb +146 -0
  48. data/test/multi_printer_test.rb +0 -5
  49. data/test/no_method_class_test.rb +1 -1
  50. data/test/pause_resume_test.rb +12 -16
  51. data/test/printer_call_stack_test.rb +2 -2
  52. data/test/printer_call_tree_test.rb +2 -2
  53. data/test/printer_flat_test.rb +1 -1
  54. data/test/printer_graph_html_test.rb +2 -2
  55. data/test/printer_graph_test.rb +2 -2
  56. data/test/printers_test.rb +14 -20
  57. data/test/printing_recursive_graph_test.rb +2 -2
  58. data/test/recursive_test.rb +2 -7
  59. data/test/scheduler.rb +9 -0
  60. data/test/singleton_test.rb +1 -1
  61. data/test/stack_printer_test.rb +5 -8
  62. data/test/start_stop_test.rb +11 -14
  63. data/test/test_helper.rb +7 -0
  64. data/test/thread_test.rb +84 -19
  65. data/test/unique_call_path_test.rb +4 -4
  66. data/test/yarv_test.rb +3 -3
  67. metadata +6 -5
@@ -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
@@ -6,20 +6,15 @@ require_relative './measure_times'
6
6
 
7
7
  class MeasureProcessTimeTest < TestCase
8
8
  def setup
9
- # Need to fix this for linux (windows works since PROCESS_TIME is WALL_TIME anyway)
10
- RubyProf::measure_mode = RubyProf::PROCESS_TIME
9
+ super
11
10
  GC.start
12
11
  end
13
12
 
14
- def test_mode
15
- assert_equal(RubyProf::PROCESS_TIME, RubyProf::measure_mode)
16
- end
17
-
18
13
  # These tests run to fast for Windows to detect any used process time
19
14
  if !windows?
20
15
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1')
21
16
  def test_class_methods_sleep
22
- result = RubyProf.profile do
17
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
23
18
  RubyProf::C1.sleep_wait
24
19
  end
25
20
 
@@ -53,7 +48,7 @@ class MeasureProcessTimeTest < TestCase
53
48
  end
54
49
 
55
50
  def test_class_methods_sleep_threaded
56
- result = RubyProf.profile do
51
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
57
52
  background_thread = Thread.new do
58
53
  RubyProf::C1.sleep_wait
59
54
  end
@@ -130,7 +125,7 @@ class MeasureProcessTimeTest < TestCase
130
125
  end
131
126
 
132
127
  def test_class_methods_busy
133
- result = RubyProf.profile do
128
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
134
129
  RubyProf::C1.busy_wait
135
130
  end
136
131
 
@@ -164,7 +159,7 @@ class MeasureProcessTimeTest < TestCase
164
159
  end
165
160
 
166
161
  def test_class_methods_busy_threaded
167
- result = RubyProf.profile do
162
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
168
163
  background_thread = Thread.new do
169
164
  RubyProf::C1.busy_wait
170
165
  end
@@ -241,7 +236,7 @@ class MeasureProcessTimeTest < TestCase
241
236
  end
242
237
 
243
238
  def test_instance_methods_sleep
244
- result = RubyProf.profile do
239
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
245
240
  RubyProf::C1.new.sleep_wait
246
241
  end
247
242
 
@@ -289,7 +284,7 @@ class MeasureProcessTimeTest < TestCase
289
284
  end
290
285
 
291
286
  def test_instance_methods_sleep_block
292
- result = RubyProf.profile do
287
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
293
288
  1.times { RubyProf::C1.new.sleep_wait }
294
289
  end
295
290
 
@@ -341,7 +336,7 @@ class MeasureProcessTimeTest < TestCase
341
336
  end
342
337
 
343
338
  def test_instance_methods_sleep_threaded
344
- result = RubyProf.profile do
339
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
345
340
  background_thread = Thread.new do
346
341
  RubyProf::C1.new.sleep_wait
347
342
  end
@@ -432,7 +427,7 @@ class MeasureProcessTimeTest < TestCase
432
427
  end
433
428
 
434
429
  def test_instance_methods_busy
435
- result = RubyProf.profile do
430
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
436
431
  RubyProf::C1.new.busy_wait
437
432
  end
438
433
 
@@ -480,7 +475,7 @@ class MeasureProcessTimeTest < TestCase
480
475
  end
481
476
 
482
477
  def test_instance_methods_busy_block
483
- result = RubyProf.profile do
478
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
484
479
  1.times { RubyProf::C1.new.busy_wait }
485
480
  end
486
481
 
@@ -532,7 +527,7 @@ class MeasureProcessTimeTest < TestCase
532
527
  end
533
528
 
534
529
  def test_instance_methods_busy_threaded
535
- result = RubyProf.profile do
530
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
536
531
  background_thread = Thread.new do
537
532
  RubyProf::C1.new.busy_wait
538
533
  end
@@ -623,7 +618,7 @@ class MeasureProcessTimeTest < TestCase
623
618
  end
624
619
 
625
620
  def test_module_methods_sleep
626
- result = RubyProf.profile do
621
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
627
622
  RubyProf::C2.sleep_wait
628
623
  end
629
624
 
@@ -657,7 +652,7 @@ class MeasureProcessTimeTest < TestCase
657
652
  end
658
653
 
659
654
  def test_module_methods_busy
660
- result = RubyProf.profile do
655
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
661
656
  RubyProf::C2.busy_wait
662
657
  end
663
658
 
@@ -691,7 +686,7 @@ class MeasureProcessTimeTest < TestCase
691
686
  end
692
687
 
693
688
  def test_module_instance_methods_sleep
694
- result = RubyProf.profile do
689
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
695
690
  RubyProf::C2.new.sleep_wait
696
691
  end
697
692
 
@@ -739,7 +734,7 @@ class MeasureProcessTimeTest < TestCase
739
734
  end
740
735
 
741
736
  def test_module_instance_methods_busy
742
- result = RubyProf.profile do
737
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
743
738
  RubyProf::C2.new.busy_wait
744
739
  end
745
740
 
@@ -785,9 +780,9 @@ class MeasureProcessTimeTest < TestCase
785
780
  assert_in_delta(0.0, method.self_time, 0.05)
786
781
  assert_in_delta(0.0, method.children_time, 0.05)
787
782
  end
788
- else
783
+ else # Ruby 3.1 and higher
789
784
  def test_class_methods_sleep
790
- result = RubyProf.profile do
785
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
791
786
  RubyProf::C1.sleep_wait
792
787
  end
793
788
 
@@ -821,7 +816,7 @@ class MeasureProcessTimeTest < TestCase
821
816
  end
822
817
 
823
818
  def test_class_methods_sleep_threaded
824
- result = RubyProf.profile do
819
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
825
820
  background_thread = Thread.new do
826
821
  RubyProf::C1.sleep_wait
827
822
  end
@@ -898,7 +893,7 @@ class MeasureProcessTimeTest < TestCase
898
893
  end
899
894
 
900
895
  def test_class_methods_busy
901
- result = RubyProf.profile do
896
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
902
897
  RubyProf::C1.busy_wait
903
898
  end
904
899
 
@@ -932,7 +927,7 @@ class MeasureProcessTimeTest < TestCase
932
927
  end
933
928
 
934
929
  def test_class_methods_busy_threaded
935
- result = RubyProf.profile do
930
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
936
931
  background_thread = Thread.new do
937
932
  RubyProf::C1.busy_wait
938
933
  end
@@ -1001,7 +996,8 @@ class MeasureProcessTimeTest < TestCase
1001
996
  assert_in_delta(0.05, method.children_time, 0.05)
1002
997
 
1003
998
  method = methods[2]
1004
- assert_equal('<Module::Process>#clock_gettime', method.full_name)
999
+ assert('<Module::Process>#clock_gettime' == method.full_name ||
1000
+ 'Float#<' == method.full_name)
1005
1001
  assert_in_delta(0.05, method.total_time, 0.05)
1006
1002
  assert_in_delta(0.0, method.wait_time, 0.05)
1007
1003
  assert_in_delta(0.05, method.self_time, 0.05)
@@ -1009,7 +1005,7 @@ class MeasureProcessTimeTest < TestCase
1009
1005
  end
1010
1006
 
1011
1007
  def test_instance_methods_sleep
1012
- result = RubyProf.profile do
1008
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1013
1009
  RubyProf::C1.new.sleep_wait
1014
1010
  end
1015
1011
 
@@ -1057,7 +1053,7 @@ class MeasureProcessTimeTest < TestCase
1057
1053
  end
1058
1054
 
1059
1055
  def test_instance_methods_sleep_block
1060
- result = RubyProf.profile do
1056
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1061
1057
  1.times { RubyProf::C1.new.sleep_wait }
1062
1058
  end
1063
1059
 
@@ -1109,7 +1105,7 @@ class MeasureProcessTimeTest < TestCase
1109
1105
  end
1110
1106
 
1111
1107
  def test_instance_methods_sleep_threaded
1112
- result = RubyProf.profile do
1108
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1113
1109
  background_thread = Thread.new do
1114
1110
  RubyProf::C1.new.sleep_wait
1115
1111
  end
@@ -1200,7 +1196,7 @@ class MeasureProcessTimeTest < TestCase
1200
1196
  end
1201
1197
 
1202
1198
  def test_instance_methods_busy
1203
- result = RubyProf.profile do
1199
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1204
1200
  RubyProf::C1.new.busy_wait
1205
1201
  end
1206
1202
 
@@ -1262,7 +1258,7 @@ class MeasureProcessTimeTest < TestCase
1262
1258
  end
1263
1259
 
1264
1260
  def test_instance_methods_busy_block
1265
- result = RubyProf.profile do
1261
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1266
1262
  1.times { RubyProf::C1.new.busy_wait }
1267
1263
  end
1268
1264
 
@@ -1328,7 +1324,7 @@ class MeasureProcessTimeTest < TestCase
1328
1324
  end
1329
1325
 
1330
1326
  def test_instance_methods_busy_threaded
1331
- result = RubyProf.profile do
1327
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1332
1328
  background_thread = Thread.new do
1333
1329
  RubyProf::C1.new.busy_wait
1334
1330
  end
@@ -1433,7 +1429,7 @@ class MeasureProcessTimeTest < TestCase
1433
1429
  end
1434
1430
 
1435
1431
  def test_module_methods_sleep
1436
- result = RubyProf.profile do
1432
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1437
1433
  RubyProf::C2.sleep_wait
1438
1434
  end
1439
1435
 
@@ -1467,7 +1463,7 @@ class MeasureProcessTimeTest < TestCase
1467
1463
  end
1468
1464
 
1469
1465
  def test_module_methods_busy
1470
- result = RubyProf.profile do
1466
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1471
1467
  RubyProf::C2.busy_wait
1472
1468
  end
1473
1469
 
@@ -1501,7 +1497,7 @@ class MeasureProcessTimeTest < TestCase
1501
1497
  end
1502
1498
 
1503
1499
  def test_module_instance_methods_sleep
1504
- result = RubyProf.profile do
1500
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1505
1501
  RubyProf::C2.new.sleep_wait
1506
1502
  end
1507
1503
 
@@ -1549,7 +1545,7 @@ class MeasureProcessTimeTest < TestCase
1549
1545
  end
1550
1546
 
1551
1547
  def test_module_instance_methods_busy
1552
- result = RubyProf.profile do
1548
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::PROCESS_TIME) do
1553
1549
  RubyProf::C2.new.busy_wait
1554
1550
  end
1555
1551