ruby-prof 1.1.0-x64-mingw32 → 1.3.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +19 -1
  3. data/bin/ruby-prof +100 -152
  4. data/ext/ruby_prof/rp_aggregate_call_tree.c +59 -0
  5. data/ext/ruby_prof/rp_aggregate_call_tree.h +13 -0
  6. data/ext/ruby_prof/rp_allocation.c +67 -59
  7. data/ext/ruby_prof/rp_allocation.h +3 -3
  8. data/ext/ruby_prof/rp_call_tree.c +369 -0
  9. data/ext/ruby_prof/rp_call_tree.h +43 -0
  10. data/ext/ruby_prof/rp_call_trees.c +288 -0
  11. data/ext/ruby_prof/rp_call_trees.h +28 -0
  12. data/ext/ruby_prof/rp_measure_allocations.c +11 -13
  13. data/ext/ruby_prof/rp_measure_process_time.c +11 -13
  14. data/ext/ruby_prof/rp_measure_wall_time.c +17 -15
  15. data/ext/ruby_prof/rp_measurement.c +47 -40
  16. data/ext/ruby_prof/rp_measurement.h +7 -7
  17. data/ext/ruby_prof/rp_method.c +116 -255
  18. data/ext/ruby_prof/rp_method.h +31 -39
  19. data/ext/ruby_prof/rp_profile.c +311 -281
  20. data/ext/ruby_prof/rp_profile.h +1 -2
  21. data/ext/ruby_prof/rp_stack.c +113 -105
  22. data/ext/ruby_prof/rp_stack.h +17 -20
  23. data/ext/ruby_prof/rp_thread.c +136 -111
  24. data/ext/ruby_prof/rp_thread.h +12 -9
  25. data/ext/ruby_prof/ruby_prof.c +27 -23
  26. data/ext/ruby_prof/ruby_prof.h +9 -0
  27. data/ext/ruby_prof/vc/ruby_prof.vcxproj +11 -7
  28. data/lib/ruby-prof.rb +2 -3
  29. data/lib/ruby-prof/assets/call_stack_printer.html.erb +4 -7
  30. data/lib/ruby-prof/assets/graph_printer.html.erb +5 -6
  31. data/lib/ruby-prof/{call_info.rb → call_tree.rb} +6 -6
  32. data/lib/ruby-prof/call_tree_visitor.rb +36 -0
  33. data/lib/ruby-prof/measurement.rb +5 -2
  34. data/lib/ruby-prof/method_info.rb +3 -15
  35. data/lib/ruby-prof/printers/call_info_printer.rb +12 -10
  36. data/lib/ruby-prof/printers/call_stack_printer.rb +19 -22
  37. data/lib/ruby-prof/printers/call_tree_printer.rb +1 -1
  38. data/lib/ruby-prof/printers/dot_printer.rb +3 -3
  39. data/lib/ruby-prof/printers/graph_printer.rb +3 -4
  40. data/lib/ruby-prof/printers/multi_printer.rb +2 -2
  41. data/lib/ruby-prof/rack.rb +3 -0
  42. data/lib/ruby-prof/thread.rb +3 -18
  43. data/lib/ruby-prof/version.rb +1 -1
  44. data/ruby-prof.gemspec +7 -0
  45. data/test/alias_test.rb +42 -45
  46. data/test/basic_test.rb +0 -86
  47. data/test/{call_info_visitor_test.rb → call_tree_visitor_test.rb} +6 -5
  48. data/test/call_trees_test.rb +66 -0
  49. data/test/exclude_methods_test.rb +17 -12
  50. data/test/fiber_test.rb +197 -9
  51. data/test/gc_test.rb +36 -42
  52. data/test/inverse_call_tree_test.rb +175 -0
  53. data/test/line_number_test.rb +67 -70
  54. data/test/marshal_test.rb +7 -11
  55. data/test/measure_allocations_test.rb +224 -234
  56. data/test/measure_allocations_trace_test.rb +224 -234
  57. data/test/measure_memory_trace_test.rb +814 -469
  58. data/test/measure_process_time_test.rb +0 -64
  59. data/test/measure_times.rb +2 -0
  60. data/test/measure_wall_time_test.rb +34 -58
  61. data/test/pause_resume_test.rb +19 -10
  62. data/test/prime.rb +1 -3
  63. data/test/prime_script.rb +6 -0
  64. data/test/printers_test.rb +1 -1
  65. data/test/recursive_test.rb +50 -54
  66. data/test/start_stop_test.rb +19 -19
  67. data/test/test_helper.rb +3 -15
  68. data/test/thread_test.rb +11 -11
  69. data/test/unique_call_path_test.rb +25 -95
  70. metadata +19 -10
  71. data/ext/ruby_prof/rp_call_info.c +0 -271
  72. data/ext/ruby_prof/rp_call_info.h +0 -35
  73. data/lib/2.6.5/ruby_prof.so +0 -0
  74. data/lib/ruby-prof/call_info_visitor.rb +0 -38
  75. data/test/parser_timings.rb +0 -24
@@ -23,10 +23,6 @@ class MeasureProcessTimeTest < TestCase
23
23
  thread = result.threads.first
24
24
  assert_in_delta(0.0, thread.total_time, 0.05)
25
25
 
26
- root_methods = thread.root_methods
27
- assert_equal(1, root_methods.count)
28
- assert_equal("MeasureProcessTimeTest#test_class_methods_sleep", root_methods.first.full_name)
29
-
30
26
  methods = result.threads.first.methods.sort.reverse
31
27
  assert_equal(3, methods.length)
32
28
 
@@ -66,10 +62,6 @@ class MeasureProcessTimeTest < TestCase
66
62
  thread = result.threads.first
67
63
  assert_in_delta(0.0, thread.total_time, 0.05)
68
64
 
69
- root_methods = thread.root_methods
70
- assert_equal(1, root_methods.count)
71
- assert_equal("MeasureProcessTimeTest#test_class_methods_sleep_threaded", root_methods.first.full_name)
72
-
73
65
  methods = result.threads.first.methods.sort.reverse
74
66
  assert_equal(4, methods.length)
75
67
 
@@ -105,10 +97,6 @@ class MeasureProcessTimeTest < TestCase
105
97
  thread = result.threads.last
106
98
  assert_in_delta(0.0, thread.total_time, 0.05)
107
99
 
108
- root_methods = thread.root_methods
109
- assert_equal(1, root_methods.count)
110
- assert_equal("MeasureProcessTimeTest#test_class_methods_sleep_threaded", root_methods.first.full_name)
111
-
112
100
  methods = result.threads.first.methods.sort.reverse
113
101
  assert_equal(4, methods.length)
114
102
 
@@ -146,10 +134,6 @@ class MeasureProcessTimeTest < TestCase
146
134
  thread = result.threads.first
147
135
  assert_in_delta(0.08, thread.total_time, 0.05)
148
136
 
149
- root_methods = thread.root_methods
150
- assert_equal(1, root_methods.count)
151
- assert_equal("MeasureProcessTimeTest#test_class_methods_busy", root_methods.first.full_name)
152
-
153
137
  methods = result.threads.first.methods.sort.reverse
154
138
  assert_equal(3, methods.length)
155
139
 
@@ -189,10 +173,6 @@ class MeasureProcessTimeTest < TestCase
189
173
  thread = result.threads.first
190
174
  assert_in_delta(0.1, thread.total_time, 0.05)
191
175
 
192
- root_methods = thread.root_methods
193
- assert_equal(1, root_methods.count)
194
- assert_equal("MeasureProcessTimeTest#test_class_methods_busy_threaded", root_methods.first.full_name)
195
-
196
176
  methods = result.threads.first.methods.sort.reverse
197
177
  assert_equal(4, methods.length)
198
178
 
@@ -228,10 +208,6 @@ class MeasureProcessTimeTest < TestCase
228
208
  thread = result.threads.last
229
209
  assert_in_delta(0.1, thread.total_time, 0.05)
230
210
 
231
- root_methods = thread.root_methods
232
- assert_equal(1, root_methods.count)
233
- assert_equal("MeasureProcessTimeTest#test_class_methods_busy_threaded", root_methods.first.full_name)
234
-
235
211
  methods = result.threads.first.methods.sort.reverse
236
212
  assert_equal(4, methods.length)
237
213
 
@@ -269,10 +245,6 @@ class MeasureProcessTimeTest < TestCase
269
245
  thread = result.threads.first
270
246
  assert_in_delta(0.0, thread.total_time, 0.05)
271
247
 
272
- root_methods = thread.root_methods
273
- assert_equal(1, root_methods.count)
274
- assert_equal("MeasureProcessTimeTest#test_instance_methods_sleep", root_methods.first.full_name)
275
-
276
248
  methods = result.threads.first.methods.sort.reverse
277
249
  assert_equal(5, methods.length)
278
250
 
@@ -378,10 +350,6 @@ class MeasureProcessTimeTest < TestCase
378
350
  thread = result.threads.first
379
351
  assert_in_delta(0.0, thread.total_time, 0.05)
380
352
 
381
- root_methods = thread.root_methods
382
- assert_equal(1, root_methods.count)
383
- assert_equal("MeasureProcessTimeTest#test_instance_methods_sleep_threaded", root_methods.first.full_name)
384
-
385
353
  methods = result.threads.first.methods.sort.reverse
386
354
  assert_equal(4, methods.length)
387
355
 
@@ -417,10 +385,6 @@ class MeasureProcessTimeTest < TestCase
417
385
  thread = result.threads.last
418
386
  assert_in_delta(0.0, thread.total_time, 0.05)
419
387
 
420
- root_methods = thread.root_methods
421
- assert_equal(1, root_methods.count)
422
- assert_equal("MeasureProcessTimeTest#test_instance_methods_sleep_threaded", root_methods.first.full_name)
423
-
424
388
  methods = result.threads.first.methods.sort.reverse
425
389
  assert_equal(4, methods.length)
426
390
 
@@ -472,10 +436,6 @@ class MeasureProcessTimeTest < TestCase
472
436
  thread = result.threads.first
473
437
  assert_in_delta(0.2, thread.total_time, 0.05)
474
438
 
475
- root_methods = thread.root_methods
476
- assert_equal(1, root_methods.count)
477
- assert_equal("MeasureProcessTimeTest#test_instance_methods_busy", root_methods.first.full_name)
478
-
479
439
  methods = result.threads.first.methods.sort.reverse
480
440
  assert_equal(5, methods.length)
481
441
 
@@ -581,10 +541,6 @@ class MeasureProcessTimeTest < TestCase
581
541
  thread = result.threads.first
582
542
  assert_in_delta(0.2, thread.total_time, 0.05)
583
543
 
584
- root_methods = thread.root_methods
585
- assert_equal(1, root_methods.count)
586
- assert_equal("MeasureProcessTimeTest#test_instance_methods_busy_threaded", root_methods.first.full_name)
587
-
588
544
  methods = result.threads.first.methods.sort.reverse
589
545
  assert_equal(4, methods.length)
590
546
 
@@ -620,10 +576,6 @@ class MeasureProcessTimeTest < TestCase
620
576
  thread = result.threads.last
621
577
  assert_in_delta(0.2, thread.total_time, 0.05)
622
578
 
623
- root_methods = thread.root_methods
624
- assert_equal(1, root_methods.count)
625
- assert_equal("MeasureProcessTimeTest#test_instance_methods_busy_threaded", root_methods.first.full_name)
626
-
627
579
  methods = result.threads.first.methods.sort.reverse
628
580
  assert_equal(4, methods.length)
629
581
 
@@ -675,10 +627,6 @@ class MeasureProcessTimeTest < TestCase
675
627
  thread = result.threads.first
676
628
  assert_in_delta(0.0, thread.total_time, 0.05)
677
629
 
678
- root_methods = thread.root_methods
679
- assert_equal(1, root_methods.count)
680
- assert_equal("MeasureProcessTimeTest#test_module_methods_sleep", root_methods.first.full_name)
681
-
682
630
  methods = result.threads.first.methods.sort.reverse
683
631
  assert_equal(3, methods.length)
684
632
 
@@ -713,10 +661,6 @@ class MeasureProcessTimeTest < TestCase
713
661
  thread = result.threads.first
714
662
  assert_in_delta(0.3, thread.total_time, 0.05)
715
663
 
716
- root_methods = thread.root_methods
717
- assert_equal(1, root_methods.count)
718
- assert_equal("MeasureProcessTimeTest#test_module_methods_busy", root_methods.first.full_name)
719
-
720
664
  methods = result.threads.first.methods.sort.reverse
721
665
  assert_equal(3, methods.length)
722
666
 
@@ -751,10 +695,6 @@ class MeasureProcessTimeTest < TestCase
751
695
  thread = result.threads.first
752
696
  assert_in_delta(0.0, thread.total_time, 0.05)
753
697
 
754
- root_methods = thread.root_methods
755
- assert_equal(1, root_methods.count)
756
- assert_equal("MeasureProcessTimeTest#test_module_instance_methods_sleep", root_methods.first.full_name)
757
-
758
698
  methods = result.threads.first.methods.sort.reverse
759
699
  assert_equal(5, methods.length)
760
700
 
@@ -803,10 +743,6 @@ class MeasureProcessTimeTest < TestCase
803
743
  thread = result.threads.first
804
744
  assert_in_delta(0.3, thread.total_time, 0.05)
805
745
 
806
- root_methods = thread.root_methods
807
- assert_equal(1, root_methods.count)
808
- assert_equal("MeasureProcessTimeTest#test_module_instance_methods_busy", root_methods.first.full_name)
809
-
810
746
  methods = result.threads.first.methods.sort.reverse
811
747
  assert_equal(5, methods.length)
812
748
 
@@ -1,4 +1,6 @@
1
1
  # Some classes used in measurement tests
2
+ require 'singleton'
3
+
2
4
  module RubyProf
3
5
  class C1
4
6
  def C1.sleep_wait
@@ -8,7 +8,6 @@ class MeasureWallTimeTest < TestCase
8
8
  def setup
9
9
  # Need to use wall time for this test due to the sleep calls
10
10
  RubyProf::measure_mode = RubyProf::WALL_TIME
11
- GC.start
12
11
  end
13
12
 
14
13
  def test_mode
@@ -24,10 +23,6 @@ class MeasureWallTimeTest < TestCase
24
23
  thread = result.threads.first
25
24
  assert_in_delta(0.1, thread.total_time, 0.03)
26
25
 
27
- root_methods = thread.root_methods
28
- assert_equal(1, root_methods.count)
29
- assert_equal("MeasureWallTimeTest#test_class_methods", root_methods[0].full_name)
30
-
31
26
  methods = result.threads.first.methods.sort.reverse
32
27
  assert_equal(3, methods.length)
33
28
 
@@ -63,10 +58,6 @@ class MeasureWallTimeTest < TestCase
63
58
  thread = result.threads.first
64
59
  assert_in_delta(0.1, thread.total_time, 0.03)
65
60
 
66
- root_methods = thread.root_methods
67
- assert_equal(1, root_methods.count)
68
- assert_equal("MeasureWallTimeTest#test_class_methods_threaded", root_methods[0].full_name)
69
-
70
61
  methods = result.threads.first.methods.sort.reverse
71
62
  assert_equal(4, methods.length)
72
63
 
@@ -98,10 +89,6 @@ class MeasureWallTimeTest < TestCase
98
89
  thread = result.threads.last
99
90
  assert_in_delta(0.1, thread.total_time, 0.03)
100
91
 
101
- root_methods = thread.root_methods
102
- assert_equal(1, root_methods.count)
103
- assert_equal("MeasureWallTimeTest#test_class_methods_threaded", root_methods[0].full_name)
104
-
105
92
  methods = result.threads.first.methods.sort.reverse
106
93
  assert_equal(4, methods.length)
107
94
 
@@ -136,10 +123,6 @@ class MeasureWallTimeTest < TestCase
136
123
  thread = result.threads.first
137
124
  assert_in_delta(0.2, thread.total_time, 0.03)
138
125
 
139
- root_methods = thread.root_methods
140
- assert_equal(1, root_methods.count)
141
- assert_equal("MeasureWallTimeTest#test_instance_methods", root_methods[0].full_name)
142
-
143
126
  methods = result.threads.first.methods.sort.reverse
144
127
  assert_equal(5, methods.length)
145
128
  names = methods.map(&:full_name)
@@ -244,10 +227,6 @@ class MeasureWallTimeTest < TestCase
244
227
  thread = result.threads.first
245
228
  assert_in_delta(0.2, thread.total_time, 0.03)
246
229
 
247
- root_methods = thread.root_methods
248
- assert_equal(1, root_methods.count)
249
- assert_equal("MeasureWallTimeTest#test_instance_methods_threaded", root_methods[0].full_name)
250
-
251
230
  methods = result.threads.first.methods.sort.reverse
252
231
  assert_equal(4, methods.length)
253
232
 
@@ -279,10 +258,6 @@ class MeasureWallTimeTest < TestCase
279
258
  thread = result.threads.last
280
259
  assert_in_delta(0.2, thread.total_time, 0.03)
281
260
 
282
- root_methods = thread.root_methods
283
- assert_equal(1, root_methods.count)
284
- assert_equal("MeasureWallTimeTest#test_instance_methods_threaded", root_methods[0].full_name)
285
-
286
261
  methods = result.threads.first.methods.sort.reverse
287
262
  assert_equal(4, methods.length)
288
263
 
@@ -329,10 +304,6 @@ class MeasureWallTimeTest < TestCase
329
304
  thread = result.threads.first
330
305
  assert_in_delta(0.3, thread.total_time, 0.03)
331
306
 
332
- root_methods = thread.root_methods
333
- assert_equal(1, root_methods.count)
334
- assert_equal("MeasureWallTimeTest#test_module_methods", root_methods[0].full_name)
335
-
336
307
  methods = result.threads.first.methods.sort.reverse
337
308
  assert_equal(3, methods.length)
338
309
 
@@ -362,10 +333,6 @@ class MeasureWallTimeTest < TestCase
362
333
  thread = result.threads.first
363
334
  assert_in_delta(0.3, thread.total_time, 0.03)
364
335
 
365
- root_methods = thread.root_methods
366
- assert_equal(1, root_methods.count)
367
- assert_equal("MeasureWallTimeTest#test_module_instance_methods", root_methods[0].full_name)
368
-
369
336
  methods = result.threads.first.methods.sort.reverse
370
337
  assert_equal(5, methods.length)
371
338
  names = methods.map(&:full_name)
@@ -407,10 +374,6 @@ class MeasureWallTimeTest < TestCase
407
374
  thread = result.threads.first
408
375
  assert_in_delta(0.3, thread.total_time, 0.03)
409
376
 
410
- root_methods = thread.root_methods
411
- assert_equal(1, root_methods.count)
412
- assert_equal("MeasureWallTimeTest#test_singleton_methods", root_methods[0].full_name)
413
-
414
377
  methods = result.threads.first.methods.sort.reverse
415
378
  assert_equal(7, methods.length)
416
379
 
@@ -432,28 +395,41 @@ class MeasureWallTimeTest < TestCase
432
395
  assert_in_delta(0.3, methods[2].self_time, 0.03)
433
396
  assert_in_delta(0.0, methods[2].children_time, 0.03)
434
397
 
435
- assert_equal('<Class::RubyProf::C3>#instance', methods[3].full_name)
436
- assert_in_delta(0.0, methods[3].total_time, 0.03)
437
- assert_in_delta(0.0, methods[3].wait_time, 0.03)
438
- assert_in_delta(0.0, methods[3].self_time, 0.03)
439
- assert_in_delta(0.0, methods[3].children_time, 0.03)
398
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
399
+ method = methods.detect {|a_method| a_method.full_name == '<Class::RubyProf::C3>#instance'}
400
+ assert_equal('<Class::RubyProf::C3>#instance', method.full_name)
401
+ assert_in_delta(0.0, method.total_time, 0.03)
402
+ assert_in_delta(0.0, method.wait_time, 0.03)
403
+ assert_in_delta(0.0, method.self_time, 0.03)
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
440
413
 
441
- assert_equal('Thread::Mutex#synchronize', methods[4].full_name)
442
- assert_in_delta(0.0, methods[4].total_time, 0.03)
443
- assert_in_delta(0.0, methods[4].wait_time, 0.03)
444
- assert_in_delta(0.0, methods[4].self_time, 0.03)
445
- assert_in_delta(0.0, methods[4].children_time, 0.03)
414
+ method = methods.detect {|a_method| a_method.full_name == 'Thread::Mutex#synchronize'}
415
+ assert_equal('Thread::Mutex#synchronize', method.full_name)
416
+ assert_in_delta(0.0, method.total_time, 0.03)
417
+ assert_in_delta(0.0, method.wait_time, 0.03)
418
+ assert_in_delta(0.0, method.self_time, 0.03)
419
+ assert_in_delta(0.0, method.children_time, 0.03)
420
+
421
+ method = methods.detect {|a_method| a_method.full_name == 'Class#new'}
422
+ assert_equal('Class#new', method.full_name)
423
+ assert_in_delta(0.0, method.total_time, 0.03)
424
+ assert_in_delta(0.0, method.wait_time, 0.03)
425
+ assert_in_delta(0.0, method.self_time, 0.03)
426
+ assert_in_delta(0.0, method.children_time, 0.03)
446
427
 
447
- assert_equal('Class#new', methods[5].full_name)
448
- assert_in_delta(0.0, methods[5].total_time, 0.03)
449
- assert_in_delta(0.0, methods[5].wait_time, 0.03)
450
- assert_in_delta(0.0, methods[5].self_time, 0.03)
451
- assert_in_delta(0.0, methods[5].children_time, 0.03)
452
-
453
- assert_equal('BasicObject#initialize', methods[6].full_name)
454
- assert_in_delta(0.0, methods[6].total_time, 0.03)
455
- assert_in_delta(0.0, methods[6].wait_time, 0.03)
456
- assert_in_delta(0.0, methods[6].self_time, 0.03)
457
- assert_in_delta(0.0, methods[6].children_time, 0.03)
428
+ method = methods.detect {|a_method| a_method.full_name == 'BasicObject#initialize'}
429
+ assert_equal('BasicObject#initialize', method.full_name)
430
+ assert_in_delta(0.0, method.total_time, 0.03)
431
+ assert_in_delta(0.0, method.wait_time, 0.03)
432
+ assert_in_delta(0.0, method.self_time, 0.03)
433
+ assert_in_delta(0.0, method.children_time, 0.03)
458
434
  end
459
435
  end
@@ -2,6 +2,7 @@
2
2
  # encoding: UTF-8
3
3
 
4
4
  require File.expand_path('../test_helper', __FILE__)
5
+ require_relative 'measure_times'
5
6
 
6
7
  class PauseResumeTest < TestCase
7
8
  def setup
@@ -43,15 +44,15 @@ class PauseResumeTest < TestCase
43
44
  assert_equal('PauseResumeTest#test_pause_resume', methods[2].full_name)
44
45
 
45
46
  # Check times
46
- assert_in_delta(0.2, methods[0].total_time, 0.02)
47
+ assert_in_delta(0.22, methods[0].total_time, 0.02)
47
48
  assert_in_delta(0, methods[0].wait_time, 0.02)
48
49
  assert_in_delta(0, methods[0].self_time, 0.02)
49
50
 
50
- assert_in_delta(0.2, methods[1].total_time, 0.02)
51
+ assert_in_delta(0.22, methods[1].total_time, 0.02)
51
52
  assert_in_delta(0, methods[1].wait_time, 0.02)
52
- assert_in_delta(0.2, methods[1].self_time, 0.02)
53
+ assert_in_delta(0.22, methods[1].self_time, 0.02)
53
54
 
54
- assert_in_delta(0.2, methods[2].total_time, 0.02)
55
+ assert_in_delta(0.22, methods[2].total_time, 0.02)
55
56
  assert_in_delta(0, methods[2].wait_time, 0.02)
56
57
  assert_in_delta(0, methods[2].self_time, 0.02)
57
58
  end
@@ -70,9 +71,9 @@ class PauseResumeTest < TestCase
70
71
  method_1c
71
72
 
72
73
  result = profile.stop
73
- assert_in_delta(0.6, result.threads[0].methods.select{|m| m.full_name =~ /test_pause_resume_1$/}[0].total_time, 0.05)
74
+ assert_in_delta(0.65, result.threads[0].methods.select {|m| m.full_name =~ /test_pause_resume_1$/}[0].total_time, 0.05)
74
75
  end
75
- def method_1a; sleep 0.2 end
76
+ def method_1a; sleep 0.22 end
76
77
  def method_1b; sleep 1 end
77
78
  def method_1c; sleep 0.4 end
78
79
 
@@ -90,7 +91,7 @@ class PauseResumeTest < TestCase
90
91
  result = profile.stop
91
92
  assert_in_delta(0.6, result.threads[0].methods.select{|m| m.full_name =~ /test_pause_resume_2$/}[0].total_time, 0.05)
92
93
  end
93
- def method_2a; sleep 0.2 end
94
+ def method_2a; sleep 0.22 end
94
95
  def method_2b(profile); sleep 0.5; profile.resume; sleep 0.4 end
95
96
 
96
97
  # pause in child frame, resume in parent
@@ -105,10 +106,18 @@ class PauseResumeTest < TestCase
105
106
  method_3b
106
107
 
107
108
  result = profile.stop
108
- assert_in_delta(0.6, result.threads[0].methods.select{|m| m.full_name =~ /test_pause_resume_3$/}[0].total_time, 0.05)
109
+ assert_in_delta(0.65, result.threads[0].methods.select{|m| m.full_name =~ /test_pause_resume_3$/}[0].total_time, 0.05)
110
+ end
111
+
112
+ def method_3a(profile)
113
+ sleep 0.22
114
+ profile.pause
115
+ sleep 0.5
116
+ end
117
+
118
+ def method_3b
119
+ sleep 0.4
109
120
  end
110
- def method_3a(profile); sleep 0.2; profile.pause; sleep 0.5 end
111
- def method_3b; sleep 0.4 end
112
121
 
113
122
  def test_pause_seq
114
123
  profile = RubyProf::Profile.new
@@ -4,8 +4,6 @@
4
4
  #
5
5
  # Source from http://people.cs.uchicago.edu/~bomb154/154/maclabs/profilers-lab/
6
6
 
7
- require File.expand_path('../test_helper', __FILE__)
8
-
9
7
  def make_random_array(length, maxnum)
10
8
  result = Array.new(length)
11
9
  result.each_index do |i|
@@ -44,7 +42,7 @@ def find_largest(primes)
44
42
  largest
45
43
  end
46
44
 
47
- def run_primes(length=10, maxnum=1000)
45
+ def run_primes(length=10, maxnum=1_000)
48
46
  # Create random numbers
49
47
  random_array = make_random_array(length, maxnum)
50
48
 
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # This file is used to test bin/ruby-prof
5
+ require_relative './prime'
6
+ run_primes(100, 1_000_000)
@@ -20,7 +20,7 @@ class PrintersTest < TestCase
20
20
  def test_printers
21
21
  output = ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT'] == "1" ? STDOUT : StringIO.new('')
22
22
 
23
- printer = RubyProf::CallInfoPrinter.new(@result)
23
+ printer = RubyProf::CallStackPrinter.new(@result)
24
24
  printer.print(output)
25
25
 
26
26
  printer = RubyProf::CallTreePrinter.new(@result)
@@ -58,13 +58,11 @@ class RecursiveTest < TestCase
58
58
  assert_in_delta(0, method.wait_time, 0.01)
59
59
  assert_in_delta(2, method.children_time, 0.1)
60
60
 
61
- assert_equal(1, method.callers.length)
62
- call_info = method.callers[0]
63
- assert_nil(call_info.parent)
61
+ assert_equal(0, method.call_trees.callers.length)
64
62
 
65
- assert_equal(1, method.callees.length)
66
- call_info = method.callees[0]
67
- assert_equal('SimpleRecursion#simple', call_info.target.full_name)
63
+ assert_equal(1, method.call_trees.callees.length)
64
+ call_tree = method.call_trees.callees[0]
65
+ assert_equal('SimpleRecursion#simple', call_tree.target.full_name)
68
66
 
69
67
  # Method 1: SimpleRecursion#simple
70
68
  method = methods[1]
@@ -76,19 +74,19 @@ class RecursiveTest < TestCase
76
74
  assert_in_delta(0, method.wait_time, 0.1)
77
75
  assert_in_delta(2, method.children_time, 0.1)
78
76
 
79
- assert_equal(2, method.callers.length)
80
- call_info = method.callers[0]
81
- assert_equal('RecursiveTest#test_simple', call_info.parent.full_name)
77
+ assert_equal(2, method.call_trees.callers.length)
78
+ call_tree = method.call_trees.callers[0]
79
+ assert_equal('RecursiveTest#test_simple', call_tree.parent.target.full_name)
82
80
 
83
- call_info = method.callers[1]
84
- assert_equal('SimpleRecursion#simple', call_info.parent.full_name)
81
+ call_tree = method.call_trees.callers[1]
82
+ assert_equal('SimpleRecursion#simple', call_tree.parent.target.full_name)
85
83
 
86
- assert_equal(2, method.callees.length)
87
- call_info = method.callees[0]
88
- assert_equal('Kernel#sleep', call_info.target.full_name)
84
+ assert_equal(2, method.call_trees.callees.length)
85
+ call_tree = method.call_trees.callees[0]
86
+ assert_equal('Kernel#sleep', call_tree.target.full_name)
89
87
 
90
- call_info = method.callees[1]
91
- assert_equal('SimpleRecursion#simple', call_info.target.full_name)
88
+ call_tree = method.call_trees.callees[1]
89
+ assert_equal('SimpleRecursion#simple', call_tree.target.full_name)
92
90
 
93
91
  # Method 2: Kernel#sleep
94
92
  method = methods[2]
@@ -100,12 +98,12 @@ class RecursiveTest < TestCase
100
98
  assert_in_delta(0, method.wait_time, 0.1)
101
99
  assert_in_delta(0, method.children_time, 0.1)
102
100
 
103
- assert_equal(1, method.callers.length)
104
- call_info = method.callers[0]
105
- assert_equal('SimpleRecursion#simple', call_info.parent.full_name)
106
- assert_equal(0, method.callees.length)
101
+ assert_equal(1, method.call_trees.callers.length)
102
+ call_tree = method.call_trees.callers[0]
103
+ assert_equal('SimpleRecursion#simple', call_tree.parent.target.full_name)
104
+ assert_equal(0, method.call_trees.callees.length)
107
105
 
108
- assert_equal(0, method.callees.length)
106
+ assert_equal(0, method.call_trees.callees.length)
109
107
  end
110
108
 
111
109
  def test_cycle
@@ -125,13 +123,11 @@ class RecursiveTest < TestCase
125
123
  assert_in_delta(0, method.wait_time, 0.01)
126
124
  assert_in_delta(5, method.children_time, 0.1)
127
125
 
128
- assert_equal(1, method.callers.length)
129
- call_info = method.callers[0]
130
- assert_nil(call_info.parent)
126
+ assert_equal(0, method.call_trees.callers.length)
131
127
 
132
- assert_equal(1, method.callees.length)
133
- call_info = method.callees[0]
134
- assert_equal('SimpleRecursion#render', call_info.target.full_name)
128
+ assert_equal(1, method.call_trees.callees.length)
129
+ call_tree = method.call_trees.callees[0]
130
+ assert_equal('SimpleRecursion#render', call_tree.target.full_name)
135
131
 
136
132
  method = methods[1]
137
133
  assert_equal('SimpleRecursion#render', method.full_name)
@@ -142,13 +138,13 @@ class RecursiveTest < TestCase
142
138
  assert_in_delta(0, method.wait_time, 0.01)
143
139
  assert_in_delta(5, method.children_time, 0.1)
144
140
 
145
- assert_equal(1, method.callers.length)
146
- call_info = method.callers[0]
147
- assert_equal('RecursiveTest#test_cycle', call_info.parent.full_name)
141
+ assert_equal(1, method.call_trees.callers.length)
142
+ call_tree = method.call_trees.callers[0]
143
+ assert_equal('RecursiveTest#test_cycle', call_tree.parent.target.full_name)
148
144
 
149
- assert_equal(1, method.callees.length)
150
- call_info = method.callees[0]
151
- assert_equal('Integer#times', call_info.target.full_name)
145
+ assert_equal(1, method.call_trees.callees.length)
146
+ call_tree = method.call_trees.callees[0]
147
+ assert_equal('Integer#times', call_tree.target.full_name)
152
148
 
153
149
  method = methods[2]
154
150
  assert_equal('Integer#times', method.full_name)
@@ -159,16 +155,16 @@ class RecursiveTest < TestCase
159
155
  assert_in_delta(0, method.wait_time, 0.1)
160
156
  assert_in_delta(5, method.children_time, 0.1)
161
157
 
162
- assert_equal(2, method.callers.length)
163
- call_info = method.callers[0]
164
- assert_equal('SimpleRecursion#render', call_info.parent.full_name)
158
+ assert_equal(2, method.call_trees.callers.length)
159
+ call_tree = method.call_trees.callers[0]
160
+ assert_equal('SimpleRecursion#render', call_tree.parent.target.full_name)
165
161
 
166
- call_info = method.callers[1]
167
- assert_equal('SimpleRecursion#render_partial', call_info.parent.full_name)
162
+ call_tree = method.call_trees.callers[1]
163
+ assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
168
164
 
169
- assert_equal(1, method.callees.length)
170
- call_info = method.callees[0]
171
- assert_equal('SimpleRecursion#render_partial', call_info.target.full_name)
165
+ assert_equal(1, method.call_trees.callees.length)
166
+ call_tree = method.call_trees.callees[0]
167
+ assert_equal('SimpleRecursion#render_partial', call_tree.target.full_name)
172
168
 
173
169
  method = methods[3]
174
170
  assert_equal('SimpleRecursion#render_partial', method.full_name)
@@ -179,22 +175,22 @@ class RecursiveTest < TestCase
179
175
  assert_in_delta(0, method.wait_time, 0.01)
180
176
  assert_in_delta(5, method.children_time, 0.05)
181
177
 
182
- assert_equal(2, method.callers.length)
183
- call_info = method.callers[0]
184
- assert_equal('Integer#times', call_info.parent.full_name)
178
+ assert_equal(2, method.call_trees.callers.length)
179
+ call_tree = method.call_trees.callers[0]
180
+ assert_equal('Integer#times', call_tree.parent.target.full_name)
185
181
 
186
- call_info = method.callers[1]
187
- assert_equal('SimpleRecursion#render_partial', call_info.parent.full_name)
182
+ call_tree = method.call_trees.callers[1]
183
+ assert_equal('SimpleRecursion#render_partial', call_tree.parent.target.full_name)
188
184
 
189
- assert_equal(3, method.callees.length)
190
- call_info = method.callees[0]
191
- assert_equal('Kernel#sleep', call_info.target.full_name)
185
+ assert_equal(3, method.call_trees.callees.length)
186
+ call_tree = method.call_trees.callees[0]
187
+ assert_equal('Kernel#sleep', call_tree.target.full_name)
192
188
 
193
- call_info = method.callees[1]
194
- assert_equal('SimpleRecursion#render_partial', call_info.target.full_name)
189
+ call_tree = method.call_trees.callees[1]
190
+ assert_equal('SimpleRecursion#render_partial', call_tree.target.full_name)
195
191
 
196
- call_info = method.callees[2]
197
- assert_equal('Integer#times', call_info.target.full_name)
192
+ call_tree = method.call_trees.callees[2]
193
+ assert_equal('Integer#times', call_tree.target.full_name)
198
194
 
199
195
  method = methods[4]
200
196
  assert_equal('Kernel#sleep', method.full_name)
@@ -205,6 +201,6 @@ class RecursiveTest < TestCase
205
201
  assert_in_delta(0, method.wait_time, 0.01)
206
202
  assert_in_delta(0, method.children_time, 0.01)
207
203
 
208
- assert_equal(0, method.callees.length)
204
+ assert_equal(0, method.call_trees.callees.length)
209
205
  end
210
206
  end