ruby-prof 1.4.3 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +30 -9
- data/{README.rdoc → README.md} +2 -2
- data/Rakefile +3 -3
- data/ext/ruby_prof/rp_call_tree.c +0 -2
- data/ext/ruby_prof/rp_call_tree.h +1 -1
- data/ext/ruby_prof/rp_measure_allocations.c +10 -13
- data/ext/ruby_prof/rp_measure_memory.c +8 -4
- data/ext/ruby_prof/rp_measure_process_time.c +7 -6
- data/ext/ruby_prof/rp_measurement.c +1 -1
- data/ext/ruby_prof/rp_measurement.h +1 -1
- data/ext/ruby_prof/rp_profile.c +18 -3
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +8 -6
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +2 -1
- data/lib/ruby-prof/printers/call_tree_printer.rb +3 -7
- data/lib/ruby-prof/printers/graph_html_printer.rb +1 -1
- data/lib/ruby-prof/version.rb +1 -1
- data/lib/ruby-prof.rb +1 -1
- data/ruby-prof.gemspec +2 -3
- data/test/alias_test.rb +97 -101
- data/test/duplicate_names_test.rb +4 -4
- data/test/dynamic_method_test.rb +23 -9
- data/test/marshal_test.rb +15 -2
- data/test/measure_allocations.rb +1 -5
- data/test/measure_allocations_test.rb +643 -349
- data/test/{measure_memory_trace_test.rb → measure_memory_test.rb} +178 -605
- data/test/measure_process_time_test.rb +1564 -735
- data/test/measure_wall_time_test.rb +6 -15
- data/test/printer_call_tree_test.rb +2 -2
- data/test/recursive_test.rb +372 -148
- data/test/test_helper.rb +4 -8
- data/test/unique_call_path_test.rb +24 -8
- data/test/yarv_test.rb +8 -4
- metadata +10 -26
- data/test/measure_allocations_trace_test.rb +0 -375
- data/test/temp.rb +0 -20
@@ -395,21 +395,12 @@ class MeasureWallTimeTest < TestCase
|
|
395
395
|
assert_in_delta(0.3, methods[2].self_time, 0.03)
|
396
396
|
assert_in_delta(0.0, methods[2].children_time, 0.03)
|
397
397
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
assert_in_delta(0.0, method.children_time, 0.03)
|
405
|
-
else
|
406
|
-
method = methods.detect {|a_method| a_method.full_name == 'Singleton::SingletonClassMethods#instance'}
|
407
|
-
assert_equal('Singleton::SingletonClassMethods#instance', method.full_name)
|
408
|
-
assert_in_delta(0.0, method.total_time, 0.03)
|
409
|
-
assert_in_delta(0.0, method.wait_time, 0.03)
|
410
|
-
assert_in_delta(0.0, method.self_time, 0.03)
|
411
|
-
assert_in_delta(0.0, method.children_time, 0.03)
|
412
|
-
end
|
398
|
+
method = methods.detect {|a_method| a_method.full_name == 'Singleton::SingletonClassMethods#instance'}
|
399
|
+
assert_equal('Singleton::SingletonClassMethods#instance', method.full_name)
|
400
|
+
assert_in_delta(0.0, method.total_time, 0.03)
|
401
|
+
assert_in_delta(0.0, method.wait_time, 0.03)
|
402
|
+
assert_in_delta(0.0, method.self_time, 0.03)
|
403
|
+
assert_in_delta(0.0, method.children_time, 0.03)
|
413
404
|
|
414
405
|
method = methods.detect {|a_method| a_method.full_name == 'Thread::Mutex#synchronize'}
|
415
406
|
assert_equal('Thread::Mutex#synchronize', method.full_name)
|
@@ -19,8 +19,8 @@ class PrinterCallTreeTest < TestCase
|
|
19
19
|
def test_call_tree_string
|
20
20
|
printer = RubyProf::CallTreePrinter.new(@result)
|
21
21
|
|
22
|
-
printer.print(:
|
23
|
-
main_output_file_name = File.join(Dir.tmpdir, "
|
22
|
+
printer.print(:path => Dir.tmpdir)
|
23
|
+
main_output_file_name = File.join(Dir.tmpdir, "callgrind.out.#{$$}")
|
24
24
|
assert(File.exist?(main_output_file_name))
|
25
25
|
output = File.read(main_output_file_name)
|
26
26
|
assert_match(/fn=Object::find_primes/i, output)
|
data/test/recursive_test.rb
CHANGED
@@ -46,64 +46,158 @@ class RecursiveTest < TestCase
|
|
46
46
|
end
|
47
47
|
|
48
48
|
methods = result.threads.first.methods.sort.reverse
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
49
|
+
|
50
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1')
|
51
|
+
assert_equal(3, methods.length)
|
52
|
+
|
53
|
+
# Method 0: RecursiveTest#test_simple
|
54
|
+
method = methods[0]
|
55
|
+
assert_equal('RecursiveTest#test_simple', method.full_name)
|
56
|
+
assert_equal(1, method.called)
|
57
|
+
refute(method.recursive?)
|
58
|
+
assert_in_delta(2, method.total_time, 0.1)
|
59
|
+
assert_in_delta(0, method.self_time, 0.01)
|
60
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
61
|
+
assert_in_delta(2, method.children_time, 0.1)
|
62
|
+
|
63
|
+
assert_equal(0, method.call_trees.callers.length)
|
64
|
+
|
65
|
+
assert_equal(1, method.call_trees.callees.length)
|
66
|
+
call_tree = method.call_trees.callees[0]
|
67
|
+
assert_equal('SimpleRecursion#simple', call_tree.target.full_name)
|
68
|
+
|
69
|
+
# Method 1: SimpleRecursion#simple
|
70
|
+
method = methods[1]
|
71
|
+
assert_equal('SimpleRecursion#simple', method.full_name)
|
72
|
+
assert_equal(2, method.called)
|
73
|
+
assert(method.recursive?)
|
74
|
+
assert_in_delta(2, method.total_time, 0.1)
|
75
|
+
assert_in_delta(0, method.self_time, 0.1)
|
76
|
+
assert_in_delta(0, method.wait_time, 0.1)
|
77
|
+
assert_in_delta(2, method.children_time, 0.1)
|
78
|
+
|
79
|
+
assert_equal(2, method.call_trees.callers.length)
|
80
|
+
call_tree = method.call_trees.callers[0]
|
81
|
+
assert_equal('RecursiveTest#test_simple', call_tree.parent.target.full_name)
|
82
|
+
|
83
|
+
call_tree = method.call_trees.callers[1]
|
84
|
+
assert_equal('SimpleRecursion#simple', call_tree.parent.target.full_name)
|
85
|
+
|
86
|
+
assert_equal(2, method.call_trees.callees.length)
|
87
|
+
call_tree = method.call_trees.callees[0]
|
88
|
+
assert_equal('Kernel#sleep', call_tree.target.full_name)
|
89
|
+
|
90
|
+
call_tree = method.call_trees.callees[1]
|
91
|
+
assert_equal('SimpleRecursion#simple', call_tree.target.full_name)
|
92
|
+
|
93
|
+
# Method 2: Kernel#sleep
|
94
|
+
method = methods[2]
|
95
|
+
assert_equal('Kernel#sleep', method.full_name)
|
96
|
+
assert_equal(2, method.called)
|
97
|
+
refute(method.recursive?)
|
98
|
+
|
99
|
+
assert_in_delta(2, method.total_time, 0.1)
|
100
|
+
assert_in_delta(2, method.self_time, 0.1)
|
101
|
+
assert_in_delta(0, method.wait_time, 0.1)
|
102
|
+
assert_in_delta(0, method.children_time, 0.1)
|
103
|
+
|
104
|
+
assert_equal(1, method.call_trees.callers.length)
|
105
|
+
call_tree = method.call_trees.callers[0]
|
106
|
+
assert_equal('SimpleRecursion#simple', call_tree.parent.target.full_name)
|
107
|
+
assert_equal(0, method.call_trees.callees.length)
|
108
|
+
|
109
|
+
assert_equal(0, method.call_trees.callees.length)
|
110
|
+
else
|
111
|
+
assert_equal(5, methods.length)
|
112
|
+
|
113
|
+
# Method 0: RecursiveTest#test_simple
|
114
|
+
method = methods[0]
|
115
|
+
assert_equal('RecursiveTest#test_simple', method.full_name)
|
116
|
+
assert_equal(1, method.called)
|
117
|
+
refute(method.recursive?)
|
118
|
+
assert_in_delta(2, method.total_time, 0.1)
|
119
|
+
assert_in_delta(0, method.self_time, 0.01)
|
120
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
121
|
+
assert_in_delta(2, method.children_time, 0.1)
|
122
|
+
|
123
|
+
assert_equal(0, method.call_trees.callers.length)
|
124
|
+
|
125
|
+
assert_equal(1, method.call_trees.callees.length)
|
126
|
+
call_tree = method.call_trees.callees[0]
|
127
|
+
assert_equal('SimpleRecursion#simple', call_tree.target.full_name)
|
128
|
+
|
129
|
+
# Method 1: SimpleRecursion#simple
|
130
|
+
method = methods[1]
|
131
|
+
assert_equal('SimpleRecursion#simple', method.full_name)
|
132
|
+
assert_equal(2, method.called)
|
133
|
+
assert(method.recursive?)
|
134
|
+
assert_in_delta(2, method.total_time, 0.1)
|
135
|
+
assert_in_delta(0, method.self_time, 0.1)
|
136
|
+
assert_in_delta(0, method.wait_time, 0.1)
|
137
|
+
assert_in_delta(2, method.children_time, 0.1)
|
138
|
+
|
139
|
+
assert_equal(2, method.call_trees.callers.length)
|
140
|
+
call_tree = method.call_trees.callers[0]
|
141
|
+
assert_equal('RecursiveTest#test_simple', call_tree.parent.target.full_name)
|
142
|
+
|
143
|
+
call_tree = method.call_trees.callers[1]
|
144
|
+
assert_equal('SimpleRecursion#simple', call_tree.parent.target.full_name)
|
145
|
+
|
146
|
+
assert_equal(4, method.call_trees.callees.length)
|
147
|
+
call_tree = method.call_trees.callees[0]
|
148
|
+
assert_equal('Kernel#sleep', call_tree.target.full_name)
|
149
|
+
|
150
|
+
call_tree = method.call_trees.callees[1]
|
151
|
+
assert_equal('Integer#==', call_tree.target.full_name)
|
152
|
+
|
153
|
+
call_tree = method.call_trees.callees[2]
|
154
|
+
assert_equal('Integer#-', call_tree.target.full_name)
|
155
|
+
|
156
|
+
call_tree = method.call_trees.callees[3]
|
157
|
+
assert_equal('SimpleRecursion#simple', call_tree.target.full_name)
|
158
|
+
|
159
|
+
# Method 2: Kernel#sleep
|
160
|
+
method = methods[2]
|
161
|
+
assert_equal('Kernel#sleep', method.full_name)
|
162
|
+
assert_equal(2, method.called)
|
163
|
+
refute(method.recursive?)
|
164
|
+
|
165
|
+
assert_in_delta(2, method.total_time, 0.1)
|
166
|
+
assert_in_delta(2, method.self_time, 0.1)
|
167
|
+
assert_in_delta(0, method.wait_time, 0.1)
|
168
|
+
assert_in_delta(0, method.children_time, 0.1)
|
169
|
+
|
170
|
+
assert_equal(1, method.call_trees.callers.length)
|
171
|
+
call_tree = method.call_trees.callers[0]
|
172
|
+
assert_equal('SimpleRecursion#simple', call_tree.parent.target.full_name)
|
173
|
+
assert_equal(0, method.call_trees.callees.length)
|
174
|
+
|
175
|
+
assert_equal(0, method.call_trees.callees.length)
|
176
|
+
|
177
|
+
# Method 3
|
178
|
+
method = methods[3]
|
179
|
+
assert_equal('Integer#==', method.full_name)
|
180
|
+
assert_equal(2, method.called)
|
181
|
+
refute(method.recursive?)
|
182
|
+
|
183
|
+
assert_equal(1, method.call_trees.callers.length)
|
184
|
+
call_tree = method.call_trees.callers[0]
|
185
|
+
assert_equal('SimpleRecursion#simple', call_tree.parent.target.full_name)
|
186
|
+
|
187
|
+
assert_equal(0, method.call_trees.callees.length)
|
188
|
+
|
189
|
+
# Method 4
|
190
|
+
method = methods[4]
|
191
|
+
assert_equal('Integer#-', method.full_name)
|
192
|
+
assert_equal(1, method.called)
|
193
|
+
refute(method.recursive?)
|
194
|
+
|
195
|
+
assert_equal(1, method.call_trees.callers.length)
|
196
|
+
call_tree = method.call_trees.callers[0]
|
197
|
+
assert_equal('SimpleRecursion#simple', call_tree.parent.target.full_name)
|
198
|
+
|
199
|
+
assert_equal(0, method.call_trees.callees.length)
|
200
|
+
end
|
107
201
|
end
|
108
202
|
|
109
203
|
def test_cycle
|
@@ -112,95 +206,225 @@ class RecursiveTest < TestCase
|
|
112
206
|
end
|
113
207
|
|
114
208
|
methods = result.threads.first.methods.sort.reverse
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
209
|
+
|
210
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1')
|
211
|
+
assert_equal(5, methods.length)
|
212
|
+
|
213
|
+
# Method 0
|
214
|
+
method = methods[0]
|
215
|
+
assert_equal('RecursiveTest#test_cycle', method.full_name)
|
216
|
+
assert_equal(1, method.called)
|
217
|
+
refute(method.recursive?)
|
218
|
+
assert_in_delta(5, method.total_time, 0.1)
|
219
|
+
assert_in_delta(0, method.self_time, 0.01)
|
220
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
221
|
+
assert_in_delta(5, method.children_time, 0.1)
|
222
|
+
|
223
|
+
assert_equal(0, method.call_trees.callers.length)
|
224
|
+
|
225
|
+
assert_equal(1, method.call_trees.callees.length)
|
226
|
+
call_tree = method.call_trees.callees[0]
|
227
|
+
assert_equal('SimpleRecursion#render', call_tree.target.full_name)
|
228
|
+
|
229
|
+
# Method 1
|
230
|
+
method = methods[1]
|
231
|
+
assert_equal('SimpleRecursion#render', method.full_name)
|
232
|
+
assert_equal(1, method.called)
|
233
|
+
refute(method.recursive?)
|
234
|
+
assert_in_delta(5, method.total_time, 0.1)
|
235
|
+
assert_in_delta(0, method.self_time, 0.01)
|
236
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
237
|
+
assert_in_delta(5, method.children_time, 0.1)
|
238
|
+
|
239
|
+
assert_equal(1, method.call_trees.callers.length)
|
240
|
+
call_tree = method.call_trees.callers[0]
|
241
|
+
assert_equal('RecursiveTest#test_cycle', call_tree.parent.target.full_name)
|
242
|
+
|
243
|
+
assert_equal(1, method.call_trees.callees.length)
|
244
|
+
call_tree = method.call_trees.callees[0]
|
245
|
+
assert_equal('Integer#times', call_tree.target.full_name)
|
246
|
+
|
247
|
+
# Method 2
|
248
|
+
method = methods[2]
|
249
|
+
assert_equal('Integer#times', method.full_name)
|
250
|
+
assert_equal(2, method.called)
|
251
|
+
assert(method.recursive?)
|
252
|
+
assert_in_delta(5, method.total_time, 0.1)
|
253
|
+
assert_in_delta(0, method.self_time, 0.1)
|
254
|
+
assert_in_delta(0, method.wait_time, 0.1)
|
255
|
+
assert_in_delta(5, method.children_time, 0.1)
|
256
|
+
|
257
|
+
assert_equal(2, method.call_trees.callers.length)
|
258
|
+
call_tree = method.call_trees.callers[0]
|
259
|
+
assert_equal('SimpleRecursion#render', call_tree.parent.target.full_name)
|
260
|
+
|
261
|
+
call_tree = method.call_trees.callers[1]
|
262
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
|
263
|
+
|
264
|
+
assert_equal(1, method.call_trees.callees.length)
|
265
|
+
call_tree = method.call_trees.callees[0]
|
266
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.target.full_name)
|
267
|
+
|
268
|
+
# Method 3
|
269
|
+
method = methods[3]
|
270
|
+
assert_equal('SimpleRecursion#render_partial', method.full_name)
|
271
|
+
assert_equal(5, method.called)
|
272
|
+
assert(method.recursive?)
|
273
|
+
assert_in_delta(5, method.total_time, 0.1)
|
274
|
+
assert_in_delta(0, method.self_time, 0.1)
|
275
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
276
|
+
assert_in_delta(5, method.children_time, 0.05)
|
277
|
+
|
278
|
+
assert_equal(2, method.call_trees.callers.length)
|
279
|
+
call_tree = method.call_trees.callers[0]
|
280
|
+
assert_equal('Integer#times', call_tree.parent.target.full_name)
|
281
|
+
|
282
|
+
call_tree = method.call_trees.callers[1]
|
283
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
|
284
|
+
|
285
|
+
assert_equal(3, method.call_trees.callees.length)
|
286
|
+
call_tree = method.call_trees.callees[0]
|
287
|
+
assert_equal('Kernel#sleep', call_tree.target.full_name)
|
288
|
+
|
289
|
+
call_tree = method.call_trees.callees[1]
|
290
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.target.full_name)
|
291
|
+
|
292
|
+
call_tree = method.call_trees.callees[2]
|
293
|
+
assert_equal('Integer#times', call_tree.target.full_name)
|
294
|
+
|
295
|
+
# Method 4
|
296
|
+
method = methods[4]
|
297
|
+
assert_equal('Kernel#sleep', method.full_name)
|
298
|
+
assert_equal(5, method.called)
|
299
|
+
refute(method.recursive?)
|
300
|
+
assert_in_delta(5, method.total_time, 0.1)
|
301
|
+
assert_in_delta(5, method.self_time, 0.1)
|
302
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
303
|
+
assert_in_delta(0, method.children_time, 0.01)
|
304
|
+
|
305
|
+
assert_equal(1, method.call_trees.callers.length)
|
306
|
+
call_tree = method.call_trees.callers[0]
|
307
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
|
308
|
+
|
309
|
+
assert_equal(0, method.call_trees.callees.length)
|
310
|
+
else
|
311
|
+
assert_equal(6, methods.length)
|
312
|
+
|
313
|
+
# Method 0
|
314
|
+
method = methods[0]
|
315
|
+
assert_equal('RecursiveTest#test_cycle', method.full_name)
|
316
|
+
assert_equal(1, method.called)
|
317
|
+
refute(method.recursive?)
|
318
|
+
assert_in_delta(5, method.total_time, 0.1)
|
319
|
+
assert_in_delta(0, method.self_time, 0.01)
|
320
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
321
|
+
assert_in_delta(5, method.children_time, 0.1)
|
322
|
+
|
323
|
+
assert_equal(0, method.call_trees.callers.length)
|
324
|
+
|
325
|
+
assert_equal(1, method.call_trees.callees.length)
|
326
|
+
call_tree = method.call_trees.callees[0]
|
327
|
+
assert_equal('SimpleRecursion#render', call_tree.target.full_name)
|
328
|
+
|
329
|
+
# Method 1
|
330
|
+
method = methods[1]
|
331
|
+
assert_equal('SimpleRecursion#render', method.full_name)
|
332
|
+
assert_equal(1, method.called)
|
333
|
+
refute(method.recursive?)
|
334
|
+
assert_in_delta(5, method.total_time, 0.1)
|
335
|
+
assert_in_delta(0, method.self_time, 0.01)
|
336
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
337
|
+
assert_in_delta(5, method.children_time, 0.1)
|
338
|
+
|
339
|
+
assert_equal(1, method.call_trees.callers.length)
|
340
|
+
call_tree = method.call_trees.callers[0]
|
341
|
+
assert_equal('RecursiveTest#test_cycle', call_tree.parent.target.full_name)
|
342
|
+
|
343
|
+
assert_equal(1, method.call_trees.callees.length)
|
344
|
+
call_tree = method.call_trees.callees[0]
|
345
|
+
assert_equal('Integer#times', call_tree.target.full_name)
|
346
|
+
|
347
|
+
# Method 2
|
348
|
+
method = methods[2]
|
349
|
+
assert_equal('Integer#times', method.full_name)
|
350
|
+
assert_equal(2, method.called)
|
351
|
+
assert(method.recursive?)
|
352
|
+
assert_in_delta(5, method.total_time, 0.1)
|
353
|
+
assert_in_delta(0, method.self_time, 0.1)
|
354
|
+
assert_in_delta(0, method.wait_time, 0.1)
|
355
|
+
assert_in_delta(5, method.children_time, 0.1)
|
356
|
+
|
357
|
+
assert_equal(2, method.call_trees.callers.length)
|
358
|
+
call_tree = method.call_trees.callers[0]
|
359
|
+
assert_equal('SimpleRecursion#render', call_tree.parent.target.full_name)
|
360
|
+
|
361
|
+
call_tree = method.call_trees.callers[1]
|
362
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
|
363
|
+
|
364
|
+
assert_equal(2, method.call_trees.callees.length)
|
365
|
+
call_tree = method.call_trees.callees[0]
|
366
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.target.full_name)
|
367
|
+
call_tree = method.call_trees.callees[1]
|
368
|
+
assert_equal('Integer#+', call_tree.target.full_name)
|
369
|
+
|
370
|
+
# Method 3
|
371
|
+
method = methods[3]
|
372
|
+
assert_equal('SimpleRecursion#render_partial', method.full_name)
|
373
|
+
assert_equal(5, method.called)
|
374
|
+
assert(method.recursive?)
|
375
|
+
assert_in_delta(5, method.total_time, 0.1)
|
376
|
+
assert_in_delta(0, method.self_time, 0.1)
|
377
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
378
|
+
assert_in_delta(5, method.children_time, 0.05)
|
379
|
+
|
380
|
+
assert_equal(2, method.call_trees.callers.length)
|
381
|
+
call_tree = method.call_trees.callers[0]
|
382
|
+
assert_equal('Integer#times', call_tree.parent.target.full_name)
|
383
|
+
|
384
|
+
call_tree = method.call_trees.callers[1]
|
385
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
|
386
|
+
|
387
|
+
assert_equal(3, method.call_trees.callees.length)
|
388
|
+
call_tree = method.call_trees.callees[0]
|
389
|
+
assert_equal('Kernel#sleep', call_tree.target.full_name)
|
390
|
+
|
391
|
+
call_tree = method.call_trees.callees[1]
|
392
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.target.full_name)
|
393
|
+
|
394
|
+
call_tree = method.call_trees.callees[2]
|
395
|
+
assert_equal('Integer#times', call_tree.target.full_name)
|
396
|
+
|
397
|
+
# Method 4
|
398
|
+
method = methods[4]
|
399
|
+
assert_equal('Kernel#sleep', method.full_name)
|
400
|
+
assert_equal(5, method.called)
|
401
|
+
refute(method.recursive?)
|
402
|
+
assert_in_delta(5, method.total_time, 0.1)
|
403
|
+
assert_in_delta(5, method.self_time, 0.1)
|
404
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
405
|
+
assert_in_delta(0, method.children_time, 0.01)
|
406
|
+
|
407
|
+
assert_equal(1, method.call_trees.callers.length)
|
408
|
+
call_tree = method.call_trees.callers[0]
|
409
|
+
assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
|
410
|
+
|
411
|
+
assert_equal(0, method.call_trees.callees.length)
|
412
|
+
|
413
|
+
# Method 5
|
414
|
+
method = methods[5]
|
415
|
+
assert_equal('Integer#+', method.full_name)
|
416
|
+
assert_equal(2, method.called)
|
417
|
+
refute(method.recursive?)
|
418
|
+
assert_in_delta(0, method.total_time, 0.1)
|
419
|
+
assert_in_delta(0, method.self_time, 0.1)
|
420
|
+
assert_in_delta(0, method.wait_time, 0.01)
|
421
|
+
assert_in_delta(0, method.children_time, 0.01)
|
422
|
+
|
423
|
+
assert_equal(1, method.call_trees.callers.length)
|
424
|
+
call_tree = method.call_trees.callers[0]
|
425
|
+
assert_equal('Integer#times', call_tree.parent.target.full_name)
|
426
|
+
|
427
|
+
assert_equal(0, method.call_trees.callees.length)
|
428
|
+
end
|
205
429
|
end
|
206
430
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'bundler/setup'
|
4
|
-
require '
|
4
|
+
require 'ruby-prof'
|
5
5
|
|
6
6
|
# Disable minitest parallel tests. The problem is the thread switching will change test results
|
7
7
|
# (self vs wait time)
|
8
|
-
|
9
|
-
|
10
|
-
else
|
11
|
-
ENV["N"] = "0" # Older versions of minitest
|
12
|
-
end
|
13
|
-
|
14
|
-
require 'ruby-prof'
|
8
|
+
ENV["MT_CPU"] = "0" # New versions of minitest
|
9
|
+
ENV["N"] = "0" # Older versions of minitest
|
15
10
|
|
11
|
+
require 'minitest/autorun'
|
16
12
|
class TestCase < Minitest::Test
|
17
13
|
end
|
@@ -79,8 +79,14 @@ class UniqueCallPathTest < TestCase
|
|
79
79
|
array
|
80
80
|
end
|
81
81
|
|
82
|
-
|
83
|
-
|
82
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1')
|
83
|
+
assert_equal(1, call_info_a.children.length)
|
84
|
+
assert_equal("UniqueCallPath#method_b", call_info_a.children[0].target.full_name)
|
85
|
+
else
|
86
|
+
assert_equal(2, call_info_a.children.length)
|
87
|
+
assert_equal("Integer#==", call_info_a.children[0].target.full_name)
|
88
|
+
assert_equal("UniqueCallPath#method_b", call_info_a.children[1].target.full_name)
|
89
|
+
end
|
84
90
|
end
|
85
91
|
|
86
92
|
def test_unique_path
|
@@ -106,15 +112,25 @@ class UniqueCallPathTest < TestCase
|
|
106
112
|
array
|
107
113
|
end
|
108
114
|
|
109
|
-
assert_equal(1, call_info_a.children.length)
|
110
|
-
assert_equal(1, children_of_a.length)
|
111
|
-
|
112
115
|
children_of_a = children_of_a.sort do |c1, c2|
|
113
116
|
c1.target.full_name <=> c2.target.full_name
|
114
117
|
end
|
115
118
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1')
|
120
|
+
assert_equal(1, call_info_a.children.length)
|
121
|
+
assert_equal(1, children_of_a.length)
|
122
|
+
|
123
|
+
assert_equal(1, children_of_a[0].called)
|
124
|
+
assert_equal("UniqueCallPath#method_b", children_of_a[0].target.full_name)
|
125
|
+
else
|
126
|
+
assert_equal(2, call_info_a.children.length)
|
127
|
+
assert_equal(2, children_of_a.length)
|
128
|
+
|
129
|
+
assert_equal(1, children_of_a[0].called)
|
130
|
+
assert_equal("Integer#==", children_of_a[0].target.full_name)
|
131
|
+
|
132
|
+
assert_equal(1, children_of_a[1].called)
|
133
|
+
assert_equal("UniqueCallPath#method_b", children_of_a[1].target.full_name)
|
134
|
+
end
|
119
135
|
end
|
120
136
|
end
|