ruby-prof 1.6.3 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +11 -0
  3. data/ext/ruby_prof/rp_allocation.c +342 -342
  4. data/ext/ruby_prof/rp_call_tree.c +1 -1
  5. data/ext/ruby_prof/rp_call_tree.h +1 -1
  6. data/ext/ruby_prof/rp_call_trees.c +2 -2
  7. data/ext/ruby_prof/rp_call_trees.h +2 -2
  8. data/ext/ruby_prof/rp_measure_allocations.c +1 -1
  9. data/ext/ruby_prof/rp_measure_memory.c +46 -46
  10. data/ext/ruby_prof/rp_measure_process_time.c +1 -1
  11. data/ext/ruby_prof/rp_measure_wall_time.c +1 -1
  12. data/ext/ruby_prof/rp_measurement.c +364 -364
  13. data/ext/ruby_prof/rp_method.c +26 -25
  14. data/ext/ruby_prof/rp_method.h +5 -2
  15. data/ext/ruby_prof/rp_profile.c +2 -2
  16. data/ext/ruby_prof/rp_profile.h +36 -36
  17. data/ext/ruby_prof/rp_stack.c +1 -1
  18. data/ext/ruby_prof/rp_thread.c +1 -1
  19. data/ext/ruby_prof/ruby_prof.c +1 -1
  20. data/ext/ruby_prof/ruby_prof.h +34 -34
  21. data/ext/ruby_prof/vc/ruby_prof.vcxproj +5 -7
  22. data/lib/ruby-prof/compatibility.rb +10 -10
  23. data/lib/ruby-prof/exclude_common_methods.rb +9 -3
  24. data/lib/ruby-prof/method_info.rb +87 -85
  25. data/lib/ruby-prof/version.rb +1 -1
  26. data/ruby-prof.gemspec +2 -1
  27. data/test/crash2.rb +144 -0
  28. data/test/enumerable_test.rb +5 -5
  29. data/test/exclude_methods_test.rb +197 -86
  30. data/test/line_number_test.rb +254 -99
  31. data/test/measure_allocations_test.rb +422 -1
  32. data/test/measure_memory_test.rb +433 -1
  33. data/test/measure_process_time_test.rb +882 -15
  34. data/test/measure_wall_time_test.rb +195 -47
  35. data/test/method_info_test.rb +1 -1
  36. data/test/recursive_test.rb +198 -1
  37. data/test/thread_test.rb +0 -4
  38. metadata +20 -5
@@ -157,56 +157,204 @@ class MeasureWallTimeTest < TestCase
157
157
  assert_in_delta(0, method.self_time, 0.03 * @delta_multiplier)
158
158
  end
159
159
 
160
- def test_instance_methods_block
161
- result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
162
- 1.times { RubyProf::C1.new.sleep_wait }
163
- end
164
-
165
- methods = result.threads.first.methods.sort.reverse
166
- assert_equal(6, methods.length)
167
-
168
- # Check times
169
- method = methods[0]
170
- assert_equal("MeasureWallTimeTest#test_instance_methods_block", method.full_name)
171
- assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
172
- assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
173
- assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
174
- assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
175
-
176
- method = methods[1]
177
- assert_equal("Integer#times", method.full_name)
178
- assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
179
- assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
180
- assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
181
- assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
182
-
183
- method = methods[2]
184
- assert_equal("RubyProf::C1#sleep_wait", method.full_name)
185
- assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
186
- assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
187
- assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
188
- assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
160
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.3')
161
+ def test_instance_methods_block
162
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
163
+ 1.times { RubyProf::C1.new.sleep_wait }
164
+ end
189
165
 
190
- method = methods[3]
191
- assert_equal("Kernel#sleep", method.full_name)
192
- assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
193
- assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
194
- assert_in_delta(0.2, method.self_time, 0.03 * @delta_multiplier)
195
- assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
166
+ methods = result.threads.first.methods.sort.reverse
167
+ assert_equal(6, methods.length)
168
+
169
+ # Check times
170
+ method = methods[0]
171
+ assert_equal("MeasureWallTimeTest#test_instance_methods_block", method.full_name)
172
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
173
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
174
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
175
+ assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
176
+
177
+ method = methods[1]
178
+ assert_equal("Integer#times", method.full_name)
179
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
180
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
181
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
182
+ assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
183
+
184
+ method = methods[2]
185
+ assert_equal("RubyProf::C1#sleep_wait", method.full_name)
186
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
187
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
188
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
189
+ assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
190
+
191
+ method = methods[3]
192
+ assert_equal("Kernel#sleep", method.full_name)
193
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
194
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
195
+ assert_in_delta(0.2, method.self_time, 0.03 * @delta_multiplier)
196
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
197
+
198
+ method = methods[4]
199
+ assert_equal("Class#new", method.full_name)
200
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
201
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
202
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
203
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
204
+
205
+ method = methods[5]
206
+ assert_equal("BasicObject#initialize", method.full_name)
207
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
208
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
209
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
210
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
211
+ end
212
+ elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.3')
213
+ def test_instance_methods_block
214
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
215
+ 1.times { RubyProf::C1.new.sleep_wait }
216
+ end
196
217
 
197
- method = methods[4]
198
- assert_equal("Class#new", method.full_name)
199
- assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
200
- assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
201
- assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
202
- assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
218
+ methods = result.threads.first.methods.sort.reverse
219
+ assert_equal(9, methods.length)
220
+
221
+ # Check times
222
+ method = methods[0]
223
+ assert_equal("MeasureWallTimeTest#test_instance_methods_block", method.full_name)
224
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
225
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
226
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
227
+ assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
228
+
229
+ method = methods[1]
230
+ assert_equal("Integer#times", method.full_name)
231
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
232
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
233
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
234
+ assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
235
+
236
+ method = methods[2]
237
+ assert_equal("RubyProf::C1#sleep_wait", method.full_name)
238
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
239
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
240
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
241
+ assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
242
+
243
+ method = methods[3]
244
+ assert_equal("Kernel#sleep", method.full_name)
245
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
246
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
247
+ assert_in_delta(0.2, method.self_time, 0.03 * @delta_multiplier)
248
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
249
+
250
+ method = methods[4]
251
+ assert_equal("Integer#succ", method.full_name)
252
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
253
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
254
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
255
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
256
+
257
+ method = methods[5]
258
+ assert_equal("Class#new", method.full_name)
259
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
260
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
261
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
262
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
263
+
264
+ method = methods[6]
265
+ assert_equal("Integer#<", method.full_name)
266
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
267
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
268
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
269
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
270
+
271
+ method = methods[7]
272
+ assert_equal("Kernel#block_given?", method.full_name)
273
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
274
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
275
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
276
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
277
+
278
+ method = methods[8]
279
+ assert_equal("BasicObject#initialize", method.full_name)
280
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
281
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
282
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
283
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
284
+ end
285
+ else
286
+ def test_instance_methods_block
287
+ result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
288
+ 1.times { RubyProf::C1.new.sleep_wait }
289
+ end
203
290
 
204
- method = methods[5]
205
- assert_equal("BasicObject#initialize", method.full_name)
206
- assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
207
- assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
208
- assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
209
- assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
291
+ methods = result.threads.first.methods.sort.reverse
292
+ assert_equal(9, methods.length)
293
+
294
+ # Check times
295
+ method = methods[0]
296
+ assert_equal("MeasureWallTimeTest#test_instance_methods_block", method.full_name)
297
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
298
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
299
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
300
+ assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
301
+
302
+ method = methods[1]
303
+ assert_equal("Integer#times", method.full_name)
304
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
305
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
306
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
307
+ assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
308
+
309
+ method = methods[2]
310
+ assert_equal("RubyProf::C1#sleep_wait", method.full_name)
311
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
312
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
313
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
314
+ assert_in_delta(0.2, method.children_time, 0.03 * @delta_multiplier)
315
+
316
+ method = methods[3]
317
+ assert_equal("Kernel#sleep", method.full_name)
318
+ assert_in_delta(0.2, method.total_time, 0.03 * @delta_multiplier)
319
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
320
+ assert_in_delta(0.2, method.self_time, 0.03 * @delta_multiplier)
321
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
322
+
323
+ method = methods[4]
324
+ assert_equal("Kernel#block_given?", method.full_name)
325
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
326
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
327
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
328
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
329
+
330
+ method = methods[5]
331
+ assert_equal("Integer#succ", method.full_name)
332
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
333
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
334
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
335
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
336
+
337
+ method = methods[6]
338
+ assert_equal("Integer#<", method.full_name)
339
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
340
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
341
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
342
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
343
+
344
+ method = methods[7]
345
+ assert_equal("Class#new", method.full_name)
346
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
347
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
348
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
349
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
350
+
351
+ method = methods[8]
352
+ assert_equal("BasicObject#initialize", method.full_name)
353
+ assert_in_delta(0.0, method.total_time, 0.03 * @delta_multiplier)
354
+ assert_in_delta(0.0, method.wait_time, 0.03 * @delta_multiplier)
355
+ assert_in_delta(0.0, method.self_time, 0.03 * @delta_multiplier)
356
+ assert_in_delta(0.0, method.children_time, 0.03 * @delta_multiplier)
357
+ end
210
358
  end
211
359
 
212
360
  def test_instance_methods_threaded
@@ -23,7 +23,7 @@ class MethodInfoTest < Minitest::Test
23
23
  error = assert_raises(NoMethodError) do
24
24
  RubyProf::MethodInfo.new(nil, nil)
25
25
  end
26
- assert_match(/undefined method `instance_method' for nil:NilClass/, error.message)
26
+ assert_match(/undefined method `instance_method' for nil/, error.message)
27
27
  end
28
28
 
29
29
  def test_initialize_nil_method_name
@@ -302,7 +302,7 @@ class RecursiveTest < TestCase
302
302
  assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
303
303
 
304
304
  assert_equal(0, method.call_trees.callees.length)
305
- else
305
+ elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.3')
306
306
  assert_equal(6, methods.length)
307
307
 
308
308
  # Method 0
@@ -419,6 +419,203 @@ class RecursiveTest < TestCase
419
419
  call_tree = method.call_trees.callers[0]
420
420
  assert_equal('Integer#times', call_tree.parent.target.full_name)
421
421
 
422
+ assert_equal(0, method.call_trees.callees.length)
423
+ else
424
+ assert_equal(9, methods.length)
425
+
426
+ # Method 0
427
+ method = methods[0]
428
+ assert_equal('RecursiveTest#test_cycle', method.full_name)
429
+ assert_equal(1, method.called)
430
+ refute(method.recursive?)
431
+ assert_in_delta(5, method.total_time, 0.1)
432
+ assert_in_delta(0, method.self_time, 0.01)
433
+ assert_in_delta(0, method.wait_time, 0.01)
434
+ assert_in_delta(5, method.children_time, 0.1)
435
+
436
+ assert_equal(0, method.call_trees.callers.length)
437
+
438
+ assert_equal(1, method.call_trees.callees.length)
439
+ call_tree = method.call_trees.callees[0]
440
+ assert_equal('SimpleRecursion#render', call_tree.target.full_name)
441
+
442
+ # Method 1
443
+ method = methods[1]
444
+ assert_equal('SimpleRecursion#render', method.full_name)
445
+ assert_equal(1, method.called)
446
+ refute(method.recursive?)
447
+ assert_in_delta(5, method.total_time, 0.1)
448
+ assert_in_delta(0, method.self_time, 0.01)
449
+ assert_in_delta(0, method.wait_time, 0.01)
450
+ assert_in_delta(5, method.children_time, 0.1)
451
+
452
+ assert_equal(1, method.call_trees.callers.length)
453
+ call_tree = method.call_trees.callers[0]
454
+ assert_equal('RecursiveTest#test_cycle', call_tree.parent.target.full_name)
455
+
456
+ assert_equal(1, method.call_trees.callees.length)
457
+ call_tree = method.call_trees.callees[0]
458
+ assert_equal('Integer#times', call_tree.target.full_name)
459
+
460
+ # Method 2
461
+ method = methods[2]
462
+ assert_equal('Integer#times', method.full_name)
463
+ assert_equal(2, method.called)
464
+ assert(method.recursive?)
465
+ assert_in_delta(5, method.total_time, 0.1)
466
+ assert_in_delta(0, method.self_time, 0.1)
467
+ assert_in_delta(0, method.wait_time, 0.1)
468
+ assert_in_delta(5, method.children_time, 0.1)
469
+
470
+ assert_equal(2, method.call_trees.callers.length)
471
+ call_tree = method.call_trees.callers[0]
472
+ assert_equal('SimpleRecursion#render', call_tree.parent.target.full_name)
473
+
474
+ call_tree = method.call_trees.callers[1]
475
+ assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
476
+
477
+ assert_equal(5, method.call_trees.callees.length)
478
+
479
+ call_tree = method.call_trees.callees[0]
480
+ assert_equal('Kernel#block_given?', call_tree.target.full_name)
481
+ assert_in_delta(0, call_tree.total_time)
482
+ assert_in_delta(0, call_tree.wait_time)
483
+ assert_in_delta(0, call_tree.self_time)
484
+ assert_in_delta(0, call_tree.children_time)
485
+
486
+ call_tree = method.call_trees.callees[1]
487
+ assert_equal('Integer#<', call_tree.target.full_name)
488
+ assert_in_delta(0, call_tree.total_time)
489
+ assert_in_delta(0, call_tree.wait_time)
490
+ assert_in_delta(0, call_tree.self_time)
491
+ assert_in_delta(0, call_tree.children_time)
492
+
493
+ call_tree = method.call_trees.callees[2]
494
+ assert_equal('SimpleRecursion#render_partial', call_tree.target.full_name)
495
+ assert_in_delta(7.0, call_tree.total_time, 0.1)
496
+ assert_in_delta(0, call_tree.wait_time)
497
+ assert_in_delta(0, call_tree.self_time)
498
+ assert_in_delta(7.0, call_tree.children_time, 0.1)
499
+
500
+ call_tree = method.call_trees.callees[3]
501
+ assert_equal('Integer#succ', call_tree.target.full_name)
502
+ assert_in_delta(0, call_tree.total_time)
503
+ assert_in_delta(0, call_tree.wait_time)
504
+ assert_in_delta(0, call_tree.self_time)
505
+ assert_in_delta(0, call_tree.children_time)
506
+
507
+ call_tree = method.call_trees.callees[4]
508
+ assert_equal('Integer#+', call_tree.target.full_name)
509
+ assert_in_delta(0, call_tree.total_time)
510
+ assert_in_delta(0, call_tree.wait_time)
511
+ assert_in_delta(0, call_tree.self_time)
512
+ assert_in_delta(0, call_tree.children_time)
513
+
514
+ # Method 3
515
+ method = methods[3]
516
+ assert_equal('SimpleRecursion#render_partial', method.full_name)
517
+ assert_equal(5, method.called)
518
+ assert(method.recursive?)
519
+ assert_in_delta(5, method.total_time, 0.1)
520
+ assert_in_delta(0, method.self_time, 0.1)
521
+ assert_in_delta(0, method.wait_time, 0.01)
522
+ assert_in_delta(5, method.children_time, 0.1)
523
+
524
+ assert_equal(2, method.call_trees.callers.length)
525
+ call_tree = method.call_trees.callers[0]
526
+ assert_equal('Integer#times', call_tree.parent.target.full_name)
527
+
528
+ call_tree = method.call_trees.callers[1]
529
+ assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
530
+
531
+ assert_equal(3, method.call_trees.callees.length)
532
+ call_tree = method.call_trees.callees[0]
533
+ assert_equal('Kernel#sleep', call_tree.target.full_name)
534
+
535
+ call_tree = method.call_trees.callees[1]
536
+ assert_equal('SimpleRecursion#render_partial', call_tree.target.full_name)
537
+
538
+ call_tree = method.call_trees.callees[2]
539
+ assert_equal('Integer#times', call_tree.target.full_name)
540
+
541
+ # Method 4
542
+ method = methods[4]
543
+ assert_equal('Kernel#sleep', method.full_name)
544
+ assert_equal(5, method.called)
545
+ refute(method.recursive?)
546
+ assert_in_delta(5, method.total_time, 0.1)
547
+ assert_in_delta(5, method.self_time, 0.1)
548
+ assert_in_delta(0, method.wait_time, 0.01)
549
+ assert_in_delta(0, method.children_time, 0.01)
550
+
551
+ assert_equal(1, method.call_trees.callers.length)
552
+ call_tree = method.call_trees.callers[0]
553
+ assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
554
+
555
+ assert_equal(0, method.call_trees.callees.length)
556
+
557
+ # Method 5
558
+ method = methods[5]
559
+ assert_equal('Kernel#block_given?', method.full_name)
560
+ assert_equal(2, method.called)
561
+ refute(method.recursive?)
562
+ assert_in_delta(0, method.total_time, 0.1)
563
+ assert_in_delta(0, method.self_time, 0.1)
564
+ assert_in_delta(0, method.wait_time, 0.01)
565
+ assert_in_delta(0, method.children_time, 0.01)
566
+
567
+ assert_equal(1, method.call_trees.callers.length)
568
+ call_tree = method.call_trees.callers[0]
569
+ assert_equal('Integer#times', call_tree.parent.target.full_name)
570
+
571
+ assert_equal(0, method.call_trees.callees.length)
572
+
573
+ # Method 6
574
+ method = methods[6]
575
+ assert_equal('Integer#succ', method.full_name)
576
+ assert_equal(4, method.called)
577
+ refute(method.recursive?)
578
+ assert_in_delta(0, method.total_time, 0.1)
579
+ assert_in_delta(0, method.self_time, 0.1)
580
+ assert_in_delta(0, method.wait_time, 0.01)
581
+ assert_in_delta(0, method.children_time, 0.01)
582
+
583
+ assert_equal(1, method.call_trees.callers.length)
584
+ call_tree = method.call_trees.callers[0]
585
+ assert_equal('Integer#times', call_tree.parent.target.full_name)
586
+
587
+ assert_equal(0, method.call_trees.callees.length)
588
+
589
+ # Method 7
590
+ method = methods[7]
591
+ assert_equal('Integer#<', method.full_name)
592
+ assert_equal(6, method.called)
593
+ refute(method.recursive?)
594
+ assert_in_delta(0, method.total_time, 0.1)
595
+ assert_in_delta(0, method.self_time, 0.1)
596
+ assert_in_delta(0, method.wait_time, 0.01)
597
+ assert_in_delta(0, method.children_time, 0.01)
598
+
599
+ assert_equal(1, method.call_trees.callers.length)
600
+ call_tree = method.call_trees.callers[0]
601
+ assert_equal('Integer#times', call_tree.parent.target.full_name)
602
+
603
+ assert_equal(0, method.call_trees.callees.length)
604
+
605
+ # Method 8
606
+ method = methods[8]
607
+ assert_equal('Integer#+', method.full_name)
608
+ assert_equal(2, method.called)
609
+ refute(method.recursive?)
610
+ assert_in_delta(0, method.total_time, 0.1)
611
+ assert_in_delta(0, method.self_time, 0.1)
612
+ assert_in_delta(0, method.wait_time, 0.01)
613
+ assert_in_delta(0, method.children_time, 0.01)
614
+
615
+ assert_equal(1, method.call_trees.callers.length)
616
+ call_tree = method.call_trees.callers[0]
617
+ assert_equal('Integer#times', call_tree.parent.target.full_name)
618
+
422
619
  assert_equal(0, method.call_trees.callees.length)
423
620
  end
424
621
  end
data/test/thread_test.rb CHANGED
@@ -144,7 +144,6 @@ class ThreadTest < TestCase
144
144
  # force it to hit thread.join, below, first
145
145
  # thus forcing sleep(1), below, to be counted as (wall) self_time
146
146
  # since we currently count time "in some other thread" as self.wait_time
147
- # for whatever reason
148
147
  sleep(1)
149
148
  end
150
149
  thread.join
@@ -155,9 +154,6 @@ class ThreadTest < TestCase
155
154
 
156
155
  rp_thread = result.threads.detect {|t| t.id == thread.object_id}
157
156
  methods = rp_thread.methods.sort.reverse
158
- # fails on travis. why?
159
- # expected_methods = ["ThreadTest#test_thread_timings", "Kernel#sleep"]
160
- # assert_equal(expected_methods, methods.map(&:full_name))
161
157
 
162
158
  method = methods[0]
163
159
  assert_equal('ThreadTest#test_thread_timings', method.full_name)
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-20 00:00:00.000000000 Z
11
+ date: 2024-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: base64
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: minitest
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +131,7 @@ files:
117
131
  - test/call_tree_visitor_test.rb
118
132
  - test/call_trees_test.rb
119
133
  - test/compatibility_test.rb
134
+ - test/crash2.rb
120
135
  - test/duplicate_names_test.rb
121
136
  - test/dynamic_method_test.rb
122
137
  - test/enumerable_test.rb
@@ -167,7 +182,7 @@ metadata:
167
182
  bug_tracker_uri: https://github.com/ruby-prof/ruby-prof/issues
168
183
  changelog_uri: https://github.com/ruby-prof/ruby-prof/blob/master/CHANGES
169
184
  documentation_uri: https://ruby-prof.github.io/
170
- source_code_uri: https://github.com/ruby-prof/ruby-prof/tree/v1.6.3
185
+ source_code_uri: https://github.com/ruby-prof/ruby-prof/tree/v1.7.1
171
186
  post_install_message:
172
187
  rdoc_options: []
173
188
  require_paths:
@@ -176,14 +191,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
191
  requirements:
177
192
  - - ">="
178
193
  - !ruby/object:Gem::Version
179
- version: 2.7.0
194
+ version: 3.0.0
180
195
  required_rubygems_version: !ruby/object:Gem::Requirement
181
196
  requirements:
182
197
  - - ">="
183
198
  - !ruby/object:Gem::Version
184
199
  version: '0'
185
200
  requirements: []
186
- rubygems_version: 3.4.8
201
+ rubygems_version: 3.5.16
187
202
  signing_key:
188
203
  specification_version: 4
189
204
  summary: Fast Ruby profiler