ruby-prof 1.1.0-x64-mingw32 → 1.4.2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +48 -1
  3. data/Rakefile +2 -14
  4. data/bin/ruby-prof +100 -152
  5. data/ext/ruby_prof/extconf.rb +8 -28
  6. data/ext/ruby_prof/rp_aggregate_call_tree.c +59 -0
  7. data/ext/ruby_prof/rp_aggregate_call_tree.h +13 -0
  8. data/ext/ruby_prof/rp_allocation.c +67 -59
  9. data/ext/ruby_prof/rp_allocation.h +3 -3
  10. data/ext/ruby_prof/rp_call_tree.c +369 -0
  11. data/ext/ruby_prof/rp_call_tree.h +43 -0
  12. data/ext/ruby_prof/rp_call_trees.c +288 -0
  13. data/ext/ruby_prof/rp_call_trees.h +28 -0
  14. data/ext/ruby_prof/rp_measure_allocations.c +12 -14
  15. data/ext/ruby_prof/rp_measure_process_time.c +12 -14
  16. data/ext/ruby_prof/rp_measure_wall_time.c +17 -15
  17. data/ext/ruby_prof/rp_measurement.c +47 -40
  18. data/ext/ruby_prof/rp_measurement.h +7 -7
  19. data/ext/ruby_prof/rp_method.c +116 -255
  20. data/ext/ruby_prof/rp_method.h +31 -39
  21. data/ext/ruby_prof/rp_profile.c +316 -303
  22. data/ext/ruby_prof/rp_profile.h +1 -3
  23. data/ext/ruby_prof/rp_stack.c +122 -106
  24. data/ext/ruby_prof/rp_stack.h +17 -20
  25. data/ext/ruby_prof/rp_thread.c +136 -111
  26. data/ext/ruby_prof/rp_thread.h +12 -9
  27. data/ext/ruby_prof/ruby_prof.c +27 -23
  28. data/ext/ruby_prof/ruby_prof.h +9 -0
  29. data/ext/ruby_prof/vc/ruby_prof.sln +8 -0
  30. data/ext/ruby_prof/vc/ruby_prof.vcxproj +22 -7
  31. data/lib/2.7/ruby_prof.so +0 -0
  32. data/lib/ruby-prof.rb +5 -5
  33. data/lib/ruby-prof/assets/call_stack_printer.html.erb +4 -7
  34. data/lib/ruby-prof/assets/graph_printer.html.erb +5 -6
  35. data/lib/ruby-prof/{call_info.rb → call_tree.rb} +6 -6
  36. data/lib/ruby-prof/call_tree_visitor.rb +36 -0
  37. data/lib/ruby-prof/compatibility.rb +0 -10
  38. data/lib/ruby-prof/measurement.rb +5 -2
  39. data/lib/ruby-prof/method_info.rb +3 -15
  40. data/lib/ruby-prof/printers/abstract_printer.rb +12 -2
  41. data/lib/ruby-prof/printers/call_info_printer.rb +12 -10
  42. data/lib/ruby-prof/printers/call_stack_printer.rb +20 -22
  43. data/lib/ruby-prof/printers/call_tree_printer.rb +1 -1
  44. data/lib/ruby-prof/printers/dot_printer.rb +3 -3
  45. data/lib/ruby-prof/printers/flat_printer.rb +3 -2
  46. data/lib/ruby-prof/printers/graph_printer.rb +4 -5
  47. data/lib/ruby-prof/printers/multi_printer.rb +2 -2
  48. data/lib/ruby-prof/profile.rb +8 -4
  49. data/lib/ruby-prof/rack.rb +51 -127
  50. data/lib/ruby-prof/thread.rb +3 -18
  51. data/lib/ruby-prof/version.rb +1 -1
  52. data/ruby-prof.gemspec +7 -0
  53. data/test/alias_test.rb +42 -45
  54. data/test/basic_test.rb +0 -86
  55. data/test/{call_info_visitor_test.rb → call_tree_visitor_test.rb} +6 -5
  56. data/test/call_trees_test.rb +66 -0
  57. data/test/exclude_methods_test.rb +17 -12
  58. data/test/fiber_test.rb +95 -39
  59. data/test/gc_test.rb +36 -42
  60. data/test/inverse_call_tree_test.rb +175 -0
  61. data/test/line_number_test.rb +67 -70
  62. data/test/marshal_test.rb +7 -13
  63. data/test/measure_allocations_test.rb +224 -234
  64. data/test/measure_allocations_trace_test.rb +224 -234
  65. data/test/measure_memory_trace_test.rb +814 -469
  66. data/test/measure_process_time_test.rb +0 -64
  67. data/test/measure_times.rb +2 -0
  68. data/test/measure_wall_time_test.rb +34 -58
  69. data/test/pause_resume_test.rb +19 -10
  70. data/test/prime.rb +1 -3
  71. data/test/prime_script.rb +6 -0
  72. data/test/printer_call_stack_test.rb +0 -1
  73. data/test/printer_call_tree_test.rb +0 -1
  74. data/test/printer_flat_test.rb +61 -30
  75. data/test/printer_graph_html_test.rb +0 -1
  76. data/test/printer_graph_test.rb +3 -4
  77. data/test/printers_test.rb +2 -2
  78. data/test/printing_recursive_graph_test.rb +1 -1
  79. data/test/profile_test.rb +16 -0
  80. data/test/rack_test.rb +0 -64
  81. data/test/recursive_test.rb +50 -54
  82. data/test/start_stop_test.rb +19 -19
  83. data/test/test_helper.rb +6 -17
  84. data/test/thread_test.rb +11 -11
  85. data/test/unique_call_path_test.rb +25 -95
  86. metadata +22 -11
  87. data/ext/ruby_prof/rp_call_info.c +0 -271
  88. data/ext/ruby_prof/rp_call_info.h +0 -35
  89. data/lib/2.6.5/ruby_prof.so +0 -0
  90. data/lib/ruby-prof/call_info_visitor.rb +0 -38
  91. 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)
@@ -2,7 +2,6 @@
2
2
  # encoding: UTF-8
3
3
 
4
4
  require File.expand_path('../test_helper', __FILE__)
5
- require 'stringio'
6
5
  require 'fileutils'
7
6
  require 'tmpdir'
8
7
  require_relative 'prime'
@@ -2,7 +2,6 @@
2
2
  # encoding: UTF-8
3
3
 
4
4
  require File.expand_path('../test_helper', __FILE__)
5
- require 'stringio'
6
5
  require 'fileutils'
7
6
  require 'tmpdir'
8
7
  require_relative 'prime'