ruby-prof 0.18.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +23 -0
  3. data/LICENSE +2 -2
  4. data/README.rdoc +1 -483
  5. data/Rakefile +3 -6
  6. data/bin/ruby-prof +65 -30
  7. data/ext/ruby_prof/extconf.rb +6 -38
  8. data/ext/ruby_prof/rp_allocation.c +292 -0
  9. data/ext/ruby_prof/rp_allocation.h +31 -0
  10. data/ext/ruby_prof/rp_call_info.c +137 -279
  11. data/ext/ruby_prof/rp_call_info.h +16 -34
  12. data/ext/ruby_prof/rp_measure_allocations.c +25 -49
  13. data/ext/ruby_prof/rp_measure_memory.c +21 -56
  14. data/ext/ruby_prof/rp_measure_process_time.c +28 -36
  15. data/ext/ruby_prof/rp_measure_wall_time.c +36 -19
  16. data/ext/ruby_prof/rp_measurement.c +236 -0
  17. data/ext/ruby_prof/rp_measurement.h +49 -0
  18. data/ext/ruby_prof/rp_method.c +395 -383
  19. data/ext/ruby_prof/rp_method.h +34 -39
  20. data/ext/ruby_prof/rp_profile.c +881 -0
  21. data/ext/ruby_prof/rp_profile.h +36 -0
  22. data/ext/ruby_prof/rp_stack.c +103 -80
  23. data/ext/ruby_prof/rp_stack.h +5 -12
  24. data/ext/ruby_prof/rp_thread.c +149 -88
  25. data/ext/ruby_prof/rp_thread.h +15 -6
  26. data/ext/ruby_prof/ruby_prof.c +11 -757
  27. data/ext/ruby_prof/ruby_prof.h +4 -47
  28. data/ext/ruby_prof/vc/ruby_prof.vcxproj +10 -8
  29. data/lib/ruby-prof.rb +2 -17
  30. data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
  31. data/lib/ruby-prof/call_info.rb +35 -93
  32. data/lib/ruby-prof/call_info_visitor.rb +19 -21
  33. data/lib/ruby-prof/compatibility.rb +37 -107
  34. data/lib/ruby-prof/exclude_common_methods.rb +198 -0
  35. data/lib/ruby-prof/measurement.rb +14 -0
  36. data/lib/ruby-prof/method_info.rb +52 -83
  37. data/lib/ruby-prof/printers/abstract_printer.rb +66 -52
  38. data/lib/ruby-prof/printers/call_info_printer.rb +13 -3
  39. data/lib/ruby-prof/printers/call_stack_printer.rb +32 -28
  40. data/lib/ruby-prof/printers/call_tree_printer.rb +20 -12
  41. data/lib/ruby-prof/printers/dot_printer.rb +5 -5
  42. data/lib/ruby-prof/printers/flat_printer.rb +6 -24
  43. data/lib/ruby-prof/printers/graph_html_printer.rb +7 -192
  44. data/lib/ruby-prof/printers/graph_printer.rb +13 -15
  45. data/lib/ruby-prof/printers/multi_printer.rb +66 -23
  46. data/lib/ruby-prof/profile.rb +10 -3
  47. data/lib/ruby-prof/rack.rb +0 -3
  48. data/lib/ruby-prof/thread.rb +12 -12
  49. data/lib/ruby-prof/version.rb +1 -1
  50. data/ruby-prof.gemspec +2 -2
  51. data/test/abstract_printer_test.rb +0 -27
  52. data/test/alias_test.rb +129 -0
  53. data/test/basic_test.rb +41 -40
  54. data/test/call_info_visitor_test.rb +3 -3
  55. data/test/dynamic_method_test.rb +0 -2
  56. data/test/line_number_test.rb +120 -39
  57. data/test/marshal_test.rb +119 -0
  58. data/test/measure_allocations.rb +30 -0
  59. data/test/measure_allocations_test.rb +371 -12
  60. data/test/measure_allocations_trace_test.rb +385 -0
  61. data/test/measure_memory_trace_test.rb +756 -0
  62. data/test/measure_process_time_test.rb +821 -33
  63. data/test/measure_times.rb +54 -0
  64. data/test/measure_wall_time_test.rb +349 -145
  65. data/test/multi_printer_test.rb +1 -34
  66. data/test/parser_timings.rb +24 -0
  67. data/test/pause_resume_test.rb +5 -5
  68. data/test/prime.rb +2 -0
  69. data/test/printer_call_tree_test.rb +31 -0
  70. data/test/printer_flat_test.rb +68 -0
  71. data/test/printer_graph_html_test.rb +60 -0
  72. data/test/printer_graph_test.rb +41 -0
  73. data/test/printers_test.rb +32 -166
  74. data/test/printing_recursive_graph_test.rb +26 -72
  75. data/test/recursive_test.rb +72 -77
  76. data/test/stack_printer_test.rb +2 -15
  77. data/test/start_stop_test.rb +22 -25
  78. data/test/test_helper.rb +5 -248
  79. data/test/thread_test.rb +11 -54
  80. data/test/unique_call_path_test.rb +16 -28
  81. data/test/yarv_test.rb +1 -0
  82. metadata +24 -34
  83. data/examples/flat.txt +0 -50
  84. data/examples/graph.dot +0 -84
  85. data/examples/graph.html +0 -823
  86. data/examples/graph.txt +0 -139
  87. data/examples/multi.flat.txt +0 -23
  88. data/examples/multi.graph.html +0 -760
  89. data/examples/multi.grind.dat +0 -114
  90. data/examples/multi.stack.html +0 -547
  91. data/examples/stack.html +0 -547
  92. data/ext/ruby_prof/rp_measure.c +0 -40
  93. data/ext/ruby_prof/rp_measure.h +0 -45
  94. data/ext/ruby_prof/rp_measure_cpu_time.c +0 -136
  95. data/ext/ruby_prof/rp_measure_gc_runs.c +0 -73
  96. data/ext/ruby_prof/rp_measure_gc_time.c +0 -60
  97. data/lib/ruby-prof/aggregate_call_info.rb +0 -76
  98. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -83
  99. data/lib/ruby-prof/profile/exclude_common_methods.rb +0 -207
  100. data/lib/ruby-prof/profile/legacy_method_elimination.rb +0 -50
  101. data/test/aggregate_test.rb +0 -136
  102. data/test/block_test.rb +0 -74
  103. data/test/call_info_test.rb +0 -78
  104. data/test/fiber_test.rb +0 -79
  105. data/test/issue137_test.rb +0 -63
  106. data/test/measure_cpu_time_test.rb +0 -212
  107. data/test/measure_gc_runs_test.rb +0 -32
  108. data/test/measure_gc_time_test.rb +0 -36
  109. data/test/measure_memory_test.rb +0 -33
  110. data/test/method_elimination_test.rb +0 -84
  111. data/test/module_test.rb +0 -45
  112. data/test/stack_test.rb +0 -138
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- require File.expand_path('../test_helper', __FILE__)
5
-
6
- class CallInfoTest < TestCase
7
- def setup
8
- # Need to use wall time for this test due to the sleep calls
9
- RubyProf::measure_mode = RubyProf::WALL_TIME
10
- end
11
-
12
- # def test_clone
13
- # result = RubyProf.profile do
14
- # RubyProf::C1.hello
15
- # end
16
- #
17
- # method = result.threads.first.top_methods.first
18
- # call_info = method.call_infos.first
19
- # call_info_clone = call_info.clone
20
- #
21
- ## assert_equal(call_info.target, call_info_clone.target)
22
- # assert_equal(call_info.total_time, call_info_clone.total_time)
23
- # end
24
-
25
- def test_merge
26
- result1 = RubyProf.profile do
27
- RubyProf::C1.hello
28
- end
29
-
30
- methods = result1.threads.first.methods.sort.reverse
31
- assert_equal(3, methods.length)
32
-
33
- assert_equal('CallInfoTest#test_merge', methods[0].full_name)
34
- assert_in_delta(0.1, methods[0].total_time, 0.01)
35
- assert_in_delta(0, methods[0].wait_time, 0.01)
36
- assert_in_delta(0, methods[0].self_time, 0.01)
37
- assert_equal(1, methods[0].called)
38
-
39
- assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
40
- assert_in_delta(0.1, methods[1].total_time, 0.01)
41
- assert_in_delta(0, methods[1].wait_time, 0.01)
42
- assert_in_delta(0, methods[1].self_time, 0.01)
43
- assert_equal(1, methods[1].called)
44
-
45
- assert_equal('Kernel#sleep', methods[2].full_name)
46
- assert_in_delta(0.1, methods[2].total_time, 0.01)
47
- assert_in_delta(0, methods[2].wait_time, 0.01)
48
- assert_in_delta(0.1, methods[2].self_time, 0.01)
49
- assert_equal(1, methods[2].called)
50
-
51
- RubyProf.profile do
52
- RubyProf::C1.hello
53
- end
54
-
55
- # Merge the trees
56
- methods = result1.threads.first.methods.sort.reverse
57
- assert_equal(3, methods.length)
58
-
59
- assert_equal('CallInfoTest#test_merge', methods[0].full_name)
60
- assert_in_delta(0.1, methods[0].total_time, 0.01)
61
- assert_in_delta(0, methods[0].wait_time, 0.01)
62
- assert_in_delta(0, methods[0].self_time, 0.01)
63
- assert_equal(1, methods[0].called)
64
-
65
- assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
66
- assert_in_delta(0.1, methods[1].total_time, 0.01)
67
- assert_in_delta(0, methods[1].wait_time, 0.01)
68
- assert_in_delta(0, methods[1].self_time, 0.01)
69
- assert_equal(1, methods[1].called)
70
-
71
- assert_equal('Kernel#sleep', methods[2].full_name)
72
- assert_in_delta(0.1, methods[2].total_time, 0.01)
73
- assert_in_delta(0, methods[2].wait_time, 0.01)
74
- assert_in_delta(0.1, methods[2].self_time, 0.01)
75
- assert_equal(1, methods[2].called)
76
- end
77
- end
78
-
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- require File.expand_path('../test_helper', __FILE__)
5
- require 'timeout'
6
- require 'set'
7
- begin
8
- require 'fiber'
9
- rescue LoadError
10
- end
11
-
12
- # -- Tests ----
13
- class FiberTest < TestCase
14
-
15
- def fiber_test
16
- @fiber_ids << Fiber.current.object_id
17
- enum = Enumerator.new do |yielder|
18
- [1,2].each do |x|
19
- @fiber_ids << Fiber.current.object_id
20
- sleep 0.1
21
- yielder.yield x
22
- end
23
- end
24
- while true
25
- begin
26
- enum.next
27
- rescue StopIteration
28
- break
29
- end
30
- end
31
- sleep 0.1
32
- end
33
-
34
- def setup
35
- # Need to use wall time for this test due to the sleep calls
36
- RubyProf::measure_mode = RubyProf::WALL_TIME
37
- @fiber_ids = Set.new
38
- @root_fiber = Fiber.current.object_id
39
- @thread_id = Thread.current.object_id
40
- end
41
-
42
- def test_fibers
43
- result = RubyProf.profile { fiber_test }
44
- profiled_fiber_ids = result.threads.map(&:fiber_id)
45
- assert_equal(2, result.threads.length)
46
- assert_equal([@thread_id], result.threads.map(&:id).uniq)
47
- assert_equal(@fiber_ids, Set.new(profiled_fiber_ids))
48
-
49
- assert profiled_fiber_ids.include?(@root_fiber)
50
- assert(root_fiber_profile = result.threads.detect{|t| t.fiber_id == @root_fiber})
51
- assert(enum_fiber_profile = result.threads.detect{|t| t.fiber_id != @root_fiber})
52
-
53
- assert_in_delta(0.3, root_fiber_profile.total_time, 0.05)
54
- assert_in_delta(0.2, enum_fiber_profile.total_time, 0.05)
55
-
56
- assert(method_next = root_fiber_profile.methods.detect{|m| m.full_name == "Enumerator#next"})
57
- assert(method_each = enum_fiber_profile.methods.detect{|m| m.full_name == "Enumerator#each"})
58
-
59
- assert_in_delta(0.2, method_next.total_time, 0.05)
60
- assert_in_delta(0.2, method_each.total_time, 0.05)
61
- end
62
-
63
- def test_merged_fibers
64
- result = RubyProf.profile(merge_fibers: true) { fiber_test }
65
- assert_equal(1, result.threads.length)
66
-
67
- profile = result.threads.first
68
- assert_equal 0, profile.fiber_id
69
-
70
- assert_in_delta(0.3, profile.total_time, 0.05)
71
-
72
- assert(method_next = profile.methods.detect{|m| m.full_name == "Enumerator#next"})
73
- assert(method_each = profile.methods.detect{|m| m.full_name == "Enumerator#each"})
74
-
75
- assert_in_delta(0.2, method_next.total_time, 0.05)
76
- assert_in_delta(0.2, method_each.total_time, 0.05)
77
- end
78
-
79
- end
@@ -1,63 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- require File.expand_path('../test_helper', __FILE__)
5
-
6
- # issue 137 is about correctly attributing time of recursive children
7
-
8
- class RecursiveChildrenTest < TestCase
9
- class SlowClass
10
- def time_sink
11
- 1234567890 ** 100 == 0
12
- end
13
- end
14
-
15
- class SlowSearcher
16
- def do_find(slow_objects)
17
- slow_objects.find(&:time_sink)
18
- end
19
- end
20
-
21
- class MainClass
22
- def self.main_method
23
- slow_objects = [SlowClass.new] * 100_000
24
- slow_searcher = SlowSearcher.new
25
- slow_searcher.do_find(slow_objects)
26
- end
27
- end
28
-
29
- include PrinterTestHelper
30
-
31
- def setup
32
- # Need to use wall time for this test due to the sleep calls
33
- RubyProf::measure_mode = RubyProf::WALL_TIME
34
- end
35
-
36
- def test_simple
37
- result = RubyProf.profile do
38
- # make array each recursive
39
- [1].each do
40
- MainClass.main_method
41
- end
42
- end
43
-
44
- # methods = result.threads.first.methods.sort.reverse
45
-
46
- printer = RubyProf::GraphPrinter.new(result)
47
-
48
- buffer = ''
49
- printer.print(StringIO.new(buffer))
50
-
51
- puts buffer if ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT'] == "1"
52
-
53
- parsed_output = MetricsArray.parse(buffer)
54
-
55
- assert( enum_find = parsed_output.metrics_for("Enumerable#find") )
56
- assert( array_each = enum_find.child("Array#each") )
57
-
58
- assert_operator enum_find.metrics.total, :>=, array_each.total
59
- assert_operator enum_find.metrics.total, :>, 0
60
- assert_in_delta enum_find.metrics.total, array_each.total, 0.02
61
- end
62
-
63
- end
@@ -1,212 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- require File.expand_path('../test_helper', __FILE__)
5
-
6
- class MeasureCpuTimeTest < TestCase
7
- def setup
8
- RubyProf::measure_mode = RubyProf::CPU_TIME
9
- end
10
-
11
- def teardown
12
- RubyProf::measure_mode = RubyProf::WALL_TIME
13
- end
14
-
15
- def test_mode
16
- assert_equal(RubyProf::CPU_TIME, RubyProf::measure_mode)
17
- end
18
-
19
- def test_cpu_time_enabled_defined
20
- assert(defined?(RubyProf::CPU_TIME_ENABLED))
21
- end
22
-
23
- def test_class_methods
24
- result = RubyProf.profile do
25
- RubyProf::C7.busy_wait
26
- end
27
-
28
- # Length should be greater 2:
29
- # MeasureCpuTimeTest#test_class_methods
30
- # <Class::RubyProf::C1>#busy_wait
31
- # ....
32
-
33
- methods = result.threads.first.methods.sort.reverse[0..1]
34
- assert_equal(2, methods.length)
35
-
36
- # Check the names
37
- assert_equal('MeasureCpuTimeTest#test_class_methods', methods[0].full_name)
38
- assert_equal('<Class::RubyProf::C7>#busy_wait', methods[1].full_name)
39
-
40
- # Check times
41
- assert_in_delta(0.1, methods[0].total_time, 0.05)
42
- assert_in_delta(0, methods[0].wait_time, 0.05)
43
- assert_in_delta(0, methods[0].self_time, 0.05)
44
-
45
- assert_in_delta(0.1, methods[1].total_time, 0.05)
46
- assert_in_delta(0, methods[1].wait_time, 0.05)
47
- assert_in_delta(0, methods[1].self_time, 0.05)
48
- end
49
-
50
- def test_instance_methods
51
- result = RubyProf.profile do
52
- RubyProf::C7.new.busy_wait
53
- end
54
-
55
- methods = result.threads.first.methods.sort.reverse[0..1]
56
- assert_equal(2, methods.length)
57
-
58
- # Methods at this point:
59
- # MeasureCpuTimeTest#test_instance_methods
60
- # C7#busy_wait
61
- # ...
62
-
63
- names = methods.map(&:full_name)
64
- assert_equal('MeasureCpuTimeTest#test_instance_methods', names[0])
65
- assert_equal('RubyProf::C7#busy_wait', names[1])
66
-
67
-
68
- # Check times
69
- assert_in_delta(0.2, methods[0].total_time, 0.03)
70
- assert_in_delta(0, methods[0].wait_time, 0.03)
71
- assert_in_delta(0, methods[0].self_time, 0.03)
72
-
73
- assert_in_delta(0.2, methods[1].total_time, 0.03)
74
- assert_in_delta(0, methods[1].wait_time, 0.03)
75
- assert_in_delta(0, methods[1].self_time, 0.2)
76
- end
77
-
78
- def test_module_methods
79
- result = RubyProf.profile do
80
- RubyProf::C8.busy_wait
81
- end
82
-
83
- # Methods:
84
- # MeasureCpuTimeTest#test_module_methods
85
- # M1#busy_wait
86
- # ...
87
-
88
- methods = result.threads.first.methods.sort.reverse[0..1]
89
- assert_equal(2, methods.length)
90
-
91
- assert_equal('MeasureCpuTimeTest#test_module_methods', methods[0].full_name)
92
- assert_equal('RubyProf::M7#busy_wait', methods[1].full_name)
93
-
94
- # Check times
95
- assert_in_delta(0.3, methods[0].total_time, 0.1)
96
- assert_in_delta(0, methods[0].wait_time, 0.02)
97
- assert_in_delta(0, methods[0].self_time, 0.02)
98
-
99
- assert_in_delta(0.3, methods[1].total_time, 0.1)
100
- assert_in_delta(0, methods[1].wait_time, 0.02)
101
- assert_in_delta(0, methods[1].self_time, 0.1)
102
- end
103
-
104
- def test_module_instance_methods
105
- result = RubyProf.profile do
106
- RubyProf::C8.new.busy_wait
107
- end
108
-
109
- # Methods:
110
- # MeasureCpuTimeTest#test_module_instance_methods
111
- # M7#busy_wait
112
- # ...
113
-
114
- methods = result.threads.first.methods.sort.reverse[0..1]
115
- assert_equal(2, methods.length)
116
- names = methods.map(&:full_name)
117
- assert_equal('MeasureCpuTimeTest#test_module_instance_methods', names[0])
118
- assert_equal('RubyProf::M7#busy_wait', names[1])
119
-
120
- # Check times
121
- assert_in_delta(0.3, methods[0].total_time, 0.1)
122
- assert_in_delta(0, methods[0].wait_time, 0.1)
123
- assert_in_delta(0, methods[0].self_time, 0.1)
124
-
125
- assert_in_delta(0.3, methods[1].total_time, 0.1)
126
- assert_in_delta(0, methods[1].wait_time, 0.01)
127
- assert_in_delta(0, methods[1].self_time, 0.1)
128
- end
129
-
130
- def test_singleton
131
- c3 = RubyProf::C3.new
132
-
133
- class << c3
134
- def busy_wait
135
- end
136
- end
137
-
138
- result = RubyProf.profile do
139
- c3.busy_wait
140
- end
141
-
142
- methods = result.threads.first.methods.sort.reverse
143
- assert_equal(2, methods.length)
144
-
145
- assert_equal('MeasureCpuTimeTest#test_singleton', methods[0].full_name)
146
- assert_equal('<Object::RubyProf::C3>#busy_wait', methods[1].full_name)
147
-
148
- assert_in_delta(0, methods[0].total_time, 0.01)
149
- assert_in_delta(0, methods[0].wait_time, 0.01)
150
- assert_in_delta(0, methods[0].self_time, 0.01)
151
-
152
- assert_in_delta(0, methods[1].total_time, 0.01)
153
- assert_in_delta(0, methods[1].wait_time, 0.01)
154
- assert_in_delta(0, methods[1].self_time, 0.01)
155
- end
156
-
157
-
158
- def test_sleeping_does_accumulate_wall_time
159
- RubyProf::measure_mode = RubyProf::WALL_TIME
160
- result = RubyProf.profile do
161
- sleep 0.1
162
- end
163
- methods = result.threads.first.methods.sort.reverse
164
- assert_equal(["MeasureCpuTimeTest#test_sleeping_does_accumulate_wall_time", "Kernel#sleep"], methods.map(&:full_name))
165
- assert_in_delta(0.1, methods[1].total_time, 0.01)
166
- assert_equal(0, methods[1].wait_time)
167
- assert_in_delta(0.1, methods[1].self_time, 0.01)
168
- end
169
-
170
- def test_sleeping_does_not_accumulate_significant_cpu_time
171
- result = RubyProf.profile do
172
- sleep 0.1
173
- end
174
- methods = result.threads.first.methods.sort.reverse
175
- assert_equal(["MeasureCpuTimeTest#test_sleeping_does_not_accumulate_significant_cpu_time", "Kernel#sleep"], methods.map(&:full_name))
176
- assert_in_delta(0, methods[1].total_time, 0.01)
177
- assert_equal(0, methods[1].wait_time)
178
- assert_in_delta(0, methods[1].self_time, 0.01)
179
- end
180
-
181
- def test_waiting_for_threads_does_not_accumulate_cpu_time
182
- background_thread = nil
183
- result = RubyProf.profile do
184
- background_thread = Thread.new{ sleep 0.1 }
185
- background_thread.join
186
- end
187
- # check number of threads
188
- assert_equal(2, result.threads.length)
189
- fg, bg = result.threads
190
- assert(fg.methods.map(&:full_name).include?("Thread#join"))
191
- assert(bg.methods.map(&:full_name).include?("Kernel#sleep"))
192
- assert_in_delta(0, fg.total_time, 0.01)
193
- assert_in_delta(0, bg.total_time, 0.01)
194
- end
195
-
196
- def test_waiting_for_threads_does_accumulate_wall_time
197
- RubyProf::measure_mode = RubyProf::WALL_TIME
198
- background_thread = nil
199
- result = RubyProf.profile do
200
- background_thread = Thread.new{ sleep 0.1 }
201
- background_thread.join
202
- end
203
- # check number of threads
204
- assert_equal(2, result.threads.length)
205
- fg, bg = result.threads
206
- assert(fg.methods.map(&:full_name).include?("Thread#join"))
207
- assert(bg.methods.map(&:full_name).include?("Kernel#sleep"))
208
- assert_in_delta(0.1, fg.total_time, 0.01)
209
- assert_in_delta(0.1, fg.wait_time, 0.01)
210
- assert_in_delta(0.1, bg.total_time, 0.01)
211
- end
212
- end
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- require File.expand_path('../test_helper', __FILE__)
5
-
6
- class MeasureGCRunsTest < TestCase
7
- include MemoryTestHelper
8
-
9
- def test_gc_runs_mode
10
- RubyProf::measure_mode = RubyProf::GC_RUNS
11
- assert_equal(RubyProf::GC_RUNS, RubyProf::measure_mode)
12
- end
13
-
14
- def test_gc_runs_enabled_defined
15
- assert(defined?(RubyProf::GC_RUNS_ENABLED))
16
- end
17
-
18
- if RubyProf::GC_RUNS_ENABLED
19
- def test_gc_runs
20
- t = RubyProf.measure_gc_runs
21
- assert_kind_of Integer, t
22
-
23
- GC.enable_stats if GC.respond_to?(:enable_stats)
24
- GC.start
25
-
26
- u = RubyProf.measure_gc_runs
27
- assert u > t, [t, u].inspect
28
- RubyProf::measure_mode = RubyProf::GC_RUNS
29
- memory_test_helper
30
- end
31
- end
32
- end