ruby-prof 0.10.8 → 0.11.0.rc1

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 (105) hide show
  1. data/CHANGES +38 -18
  2. data/LICENSE +4 -3
  3. data/README.rdoc +30 -66
  4. data/Rakefile +47 -54
  5. data/bin/ruby-prof +24 -4
  6. data/ext/ruby_prof/extconf.rb +9 -16
  7. data/ext/ruby_prof/rp_call_info.c +369 -0
  8. data/ext/ruby_prof/rp_call_info.h +46 -0
  9. data/ext/ruby_prof/rp_measure.c +48 -0
  10. data/ext/ruby_prof/rp_measure.h +45 -0
  11. data/ext/ruby_prof/rp_measure_allocations.c +86 -0
  12. data/ext/ruby_prof/rp_measure_cpu_time.c +112 -0
  13. data/ext/ruby_prof/rp_measure_gc_runs.c +87 -0
  14. data/ext/ruby_prof/rp_measure_gc_time.c +73 -0
  15. data/ext/ruby_prof/rp_measure_memory.c +81 -0
  16. data/ext/ruby_prof/rp_measure_process_time.c +71 -0
  17. data/ext/ruby_prof/rp_measure_wall_time.c +42 -0
  18. data/ext/ruby_prof/rp_method.c +363 -0
  19. data/ext/ruby_prof/rp_method.h +55 -0
  20. data/ext/ruby_prof/rp_stack.c +61 -0
  21. data/ext/ruby_prof/rp_stack.h +40 -0
  22. data/ext/ruby_prof/rp_thread.c +113 -0
  23. data/ext/ruby_prof/rp_thread.h +20 -0
  24. data/ext/ruby_prof/ruby_prof.c +259 -1398
  25. data/ext/ruby_prof/ruby_prof.h +54 -190
  26. data/ext/ruby_prof/version.h +6 -3
  27. data/lib/1.8/ruby_prof.so +0 -0
  28. data/lib/1.9/ruby_prof.exp +0 -0
  29. data/lib/1.9/ruby_prof.ilk +0 -0
  30. data/lib/1.9/ruby_prof.lib +0 -0
  31. data/lib/1.9/ruby_prof.pdb +0 -0
  32. data/lib/1.9/ruby_prof.so +0 -0
  33. data/lib/ruby-prof.rb +14 -11
  34. data/lib/ruby-prof/abstract_printer.rb +10 -0
  35. data/lib/ruby-prof/aggregate_call_info.rb +2 -0
  36. data/lib/ruby-prof/call_info.rb +2 -0
  37. data/lib/ruby-prof/call_stack_printer.rb +2 -4
  38. data/lib/ruby-prof/call_tree_printer.rb +1 -0
  39. data/lib/ruby-prof/compatibility.rb +134 -0
  40. data/lib/ruby-prof/dot_printer.rb +7 -7
  41. data/lib/ruby-prof/flat_printer.rb +7 -7
  42. data/lib/ruby-prof/flat_printer_with_line_numbers.rb +2 -5
  43. data/lib/ruby-prof/graph_html_printer.rb +4 -2
  44. data/lib/ruby-prof/graph_printer.rb +4 -3
  45. data/lib/ruby-prof/method_info.rb +2 -0
  46. data/lib/ruby-prof/multi_printer.rb +2 -0
  47. data/lib/ruby-prof/{result.rb → profile.rb} +3 -1
  48. data/lib/ruby-prof/rack.rb +1 -0
  49. data/lib/ruby-prof/symbol_to_proc.rb +2 -0
  50. data/lib/ruby-prof/task.rb +1 -0
  51. data/lib/ruby-prof/test.rb +2 -0
  52. data/lib/ruby_prof.exp +0 -0
  53. data/lib/ruby_prof.ilk +0 -0
  54. data/lib/ruby_prof.lib +0 -0
  55. data/lib/ruby_prof.pdb +0 -0
  56. data/lib/ruby_prof.so +0 -0
  57. data/lib/unprof.rb +2 -0
  58. data/test/aggregate_test.rb +8 -8
  59. data/test/basic_test.rb +3 -251
  60. data/test/bug_test.rb +6 -0
  61. data/test/duplicate_names_test.rb +2 -2
  62. data/test/dynamic_method_test.rb +61 -0
  63. data/test/enumerable_test.rb +2 -2
  64. data/test/exceptions_test.rb +4 -3
  65. data/test/exclude_threads_test.rb +2 -2
  66. data/test/exec_test.rb +3 -3
  67. data/test/line_number_test.rb +5 -5
  68. data/test/measure_allocations_test.rb +25 -0
  69. data/test/measure_cpu_time_test.rb +212 -0
  70. data/test/measure_gc_runs_test.rb +29 -0
  71. data/test/measure_gc_time_test.rb +29 -0
  72. data/test/measure_memory_test.rb +36 -0
  73. data/test/measure_process_time_test.rb +205 -0
  74. data/test/measure_wall_time_test.rb +209 -0
  75. data/test/method_elimination_test.rb +2 -2
  76. data/test/module_test.rb +3 -2
  77. data/test/multi_printer_test.rb +2 -2
  78. data/test/no_method_class_test.rb +3 -1
  79. data/test/prime_test.rb +3 -3
  80. data/test/printers_test.rb +106 -8
  81. data/test/recursive_test.rb +7 -6
  82. data/test/singleton_test.rb +2 -2
  83. data/test/stack_printer_test.rb +2 -3
  84. data/test/stack_test.rb +2 -2
  85. data/test/start_stop_test.rb +2 -2
  86. data/test/test_helper.rb +81 -0
  87. data/test/test_suite.rb +34 -29
  88. data/test/thread_test.rb +24 -23
  89. data/test/unique_call_path_test.rb +2 -2
  90. metadata +101 -69
  91. data/ext/ruby_prof/measure_allocations.h +0 -83
  92. data/ext/ruby_prof/measure_cpu_time.h +0 -152
  93. data/ext/ruby_prof/measure_gc_runs.h +0 -76
  94. data/ext/ruby_prof/measure_gc_time.h +0 -57
  95. data/ext/ruby_prof/measure_memory.h +0 -101
  96. data/ext/ruby_prof/measure_process_time.h +0 -63
  97. data/ext/ruby_prof/measure_wall_time.h +0 -53
  98. data/ext/ruby_prof/mingw/Rakefile +0 -23
  99. data/ext/ruby_prof/mingw/build.rake +0 -38
  100. data/rails/environment/profile.rb +0 -24
  101. data/rails/example/example_test.rb +0 -9
  102. data/rails/profile_test_helper.rb +0 -21
  103. data/test/current_failures_windows +0 -8
  104. data/test/measurement_test.rb +0 -132
  105. data/test/ruby-prof-bin +0 -20
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require File.expand_path('../test_helper', __FILE__)
5
+
6
+ class MeasureMemoryTest < Test::Unit::TestCase
7
+ def memory_test_helper
8
+ result = RubyProf.profile {Array.new}
9
+ total = result.threads.values.first.inject(0) { |sum, m| sum + m.total_time }
10
+ assert(total < 1_000_000, 'Total should not have subtract overflow error')
11
+ total
12
+ end
13
+
14
+ def test_memory_mode
15
+ RubyProf::measure_mode = RubyProf::MEMORY
16
+ assert_equal(RubyProf::MEMORY, RubyProf::measure_mode)
17
+ end
18
+
19
+ def test_memory_enabled_defined
20
+ assert(defined?(RubyProf::MEMORY_ENABLED))
21
+ end
22
+
23
+ if RubyProf::MEMORY_ENABLED
24
+ def test_memory
25
+ t = RubyProf.measure_memory
26
+ assert_kind_of Integer, t
27
+
28
+ u = RubyProf.measure_memory
29
+ assert(u >= t, [t, u].inspect)
30
+ RubyProf::measure_mode = RubyProf::MEMORY
31
+ total = memory_test_helper
32
+ assert(total > 0, 'Should measure more than zero kilobytes of memory usage')
33
+ assert_not_equal(0, total % 1, 'Should not truncate fractional kilobyte measurements')
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require File.expand_path('../test_helper', __FILE__)
5
+
6
+ class MeasureProcessTimeTest < Test::Unit::TestCase
7
+ def setup
8
+ # Need to use wall time for this test due to the sleep calls
9
+ RubyProf::measure_mode = RubyProf::PROCESS_TIME
10
+ end
11
+
12
+ def test_mode
13
+ RubyProf::measure_mode = RubyProf::PROCESS_TIME
14
+ assert_equal(RubyProf::PROCESS_TIME, RubyProf::measure_mode)
15
+ end
16
+
17
+ def test_process_time_enabled_defined
18
+ assert(defined?(RubyProf::PROCESS_TIME_ENABLED))
19
+ end
20
+
21
+ def test_class_methods
22
+ result = RubyProf.profile do
23
+ RubyProf::C1.hello
24
+ end
25
+
26
+ # Length should be 3:
27
+ # MeasureProcessTimeTest#test_class_methods
28
+ # <Class::RubyProf::C1>#hello
29
+ # Kernel#sleep
30
+
31
+ methods = result.threads.values.first.sort.reverse
32
+ puts methods[0].total_time
33
+
34
+ assert_equal(3, methods.length)
35
+
36
+ # Check times
37
+ assert_equal("MeasureProcessTimeTest#test_class_methods", methods[0].full_name)
38
+ assert_in_delta(0.1, methods[0].total_time, 0.01)
39
+ assert_in_delta(0.0, methods[0].wait_time, 0.01)
40
+ assert_in_delta(0.0, methods[0].self_time, 0.01)
41
+
42
+ assert_equal("<Class::RubyProf::C1>#hello", methods[1].full_name)
43
+ assert_in_delta(0.1, methods[1].total_time, 0.01)
44
+ assert_in_delta(0.0, methods[1].wait_time, 0.01)
45
+ assert_in_delta(0.0, methods[1].self_time, 0.01)
46
+
47
+ assert_equal("Kernel#sleep", methods[2].full_name)
48
+ assert_in_delta(0.1, methods[2].total_time, 0.01)
49
+ assert_in_delta(0.0, methods[2].wait_time, 0.01)
50
+ assert_in_delta(0.1, methods[2].self_time, 0.01)
51
+ end
52
+
53
+ def test_instance_methods
54
+ result = RubyProf.profile do
55
+ RubyProf::C1.new.hello
56
+ end
57
+
58
+ # Methods called
59
+ # MeasureProcessTimeTest#test_instance_methods
60
+ # Class.new
61
+ # Class:Object#allocate
62
+ # for Object#initialize
63
+ # C1#hello
64
+ # Kernel#sleep
65
+
66
+ methods = result.threads.values.first.sort.reverse
67
+ assert_equal(6, methods.length)
68
+
69
+ # Check times
70
+ assert_equal("MeasureProcessTimeTest#test_instance_methods", methods[0].full_name)
71
+ assert_in_delta(0.2, methods[0].total_time, 0.02)
72
+ assert_in_delta(0.0, methods[0].wait_time, 0.02)
73
+ assert_in_delta(0.0, methods[0].self_time, 0.02)
74
+
75
+ assert_equal("RubyProf::C1#hello", methods[1].full_name)
76
+ assert_in_delta(0.2, methods[1].total_time, 0.02)
77
+ assert_in_delta(0.0, methods[1].wait_time, 0.02)
78
+ assert_in_delta(0.0, methods[1].self_time, 0.02)
79
+
80
+ assert_equal("Kernel#sleep", methods[2].full_name)
81
+ assert_in_delta(0.2, methods[2].total_time, 0.02)
82
+ assert_in_delta(0.0, methods[2].wait_time, 0.02)
83
+ assert_in_delta(0.2, methods[2].self_time, 0.02)
84
+
85
+ assert_equal("Class#new", methods[3].full_name)
86
+ assert_in_delta(0.0, methods[3].total_time, 0.01)
87
+ assert_in_delta(0.0, methods[3].wait_time, 0.01)
88
+ assert_in_delta(0.0, methods[3].self_time, 0.01)
89
+
90
+ assert_equal("<Class::#{RubyProf::PARENT}>#allocate", methods[4].full_name)
91
+ assert_in_delta(0.0, methods[4].total_time, 0.01)
92
+ assert_in_delta(0.0, methods[4].wait_time, 0.01)
93
+ assert_in_delta(0.0, methods[4].self_time, 0.01)
94
+
95
+ assert_equal("#{RubyProf::PARENT}#initialize", methods[5].full_name)
96
+ assert_in_delta(0.0, methods[5].total_time, 0.01)
97
+ assert_in_delta(0.0, methods[5].wait_time, 0.01)
98
+ assert_in_delta(0.0, methods[5].self_time, 0.01)
99
+ end
100
+
101
+ def test_module_methods
102
+ result = RubyProf.profile do
103
+ RubyProf::C2.hello
104
+ end
105
+
106
+ # Methods:
107
+ # MeasureProcessTimeTest#test_module_methods
108
+ # M1#hello
109
+ # Kernel#sleep
110
+
111
+ methods = result.threads.values.first.sort.reverse
112
+ assert_equal(3, methods.length)
113
+
114
+ # Check times
115
+ assert_equal("MeasureProcessTimeTest#test_module_methods", methods[0].full_name)
116
+ assert_in_delta(0.3, methods[0].total_time, 0.1)
117
+ assert_in_delta(0.0, methods[0].wait_time, 0.02)
118
+ assert_in_delta(0.0, methods[0].self_time, 0.02)
119
+
120
+ assert_equal("RubyProf::M1#hello", methods[1].full_name)
121
+ assert_in_delta(0.3, methods[1].total_time, 0.1)
122
+ assert_in_delta(0.0, methods[1].wait_time, 0.02)
123
+ assert_in_delta(0.0, methods[1].self_time, 0.02)
124
+
125
+ assert_equal("Kernel#sleep", methods[2].full_name)
126
+ assert_in_delta(0.3, methods[2].total_time, 0.1)
127
+ assert_in_delta(0.0, methods[2].wait_time, 0.02)
128
+ assert_in_delta(0.3, methods[2].self_time, 0.1)
129
+ end
130
+
131
+ def test_module_instance_methods
132
+ result = RubyProf.profile do
133
+ RubyProf::C2.new.hello
134
+ end
135
+
136
+ # Methods:
137
+ # MeasureProcessTimeTest#test_module_instance_methods
138
+ # Class#new
139
+ # <Class::Object>#allocate
140
+ # Object#initialize
141
+ # M1#hello
142
+ # Kernel#sleep
143
+
144
+ methods = result.threads.values.first.sort.reverse
145
+ assert_equal(6, methods.length)
146
+
147
+ # Check times
148
+ assert_equal("MeasureProcessTimeTest#test_module_instance_methods", methods[0].full_name)
149
+ assert_in_delta(0.3, methods[0].total_time, 0.1)
150
+ assert_in_delta(0.0, methods[0].wait_time, 0.1)
151
+ assert_in_delta(0.0, methods[0].self_time, 0.1)
152
+
153
+ assert_equal("RubyProf::M1#hello", methods[1].full_name)
154
+ assert_in_delta(0.3, methods[1].total_time, 0.02)
155
+ assert_in_delta(0.0, methods[1].wait_time, 0.01)
156
+ assert_in_delta(0.0, methods[1].self_time, 0.01)
157
+
158
+ assert_equal("Kernel#sleep", methods[2].full_name)
159
+ assert_in_delta(0.3, methods[2].total_time, 0.02)
160
+ assert_in_delta(0.0, methods[2].wait_time, 0.01)
161
+ assert_in_delta(0.3, methods[2].self_time, 0.02)
162
+
163
+ assert_equal("Class#new", methods[3].full_name)
164
+ assert_in_delta(0.0, methods[3].total_time, 0.01)
165
+ assert_in_delta(0.0, methods[3].wait_time, 0.01)
166
+ assert_in_delta(0.0, methods[3].self_time, 0.01)
167
+
168
+ assert_equal("<Class::#{RubyProf::PARENT}>#allocate", methods[4].full_name)
169
+ assert_in_delta(0.0, methods[4].total_time, 0.01)
170
+ assert_in_delta(0.0, methods[4].wait_time, 0.01)
171
+ assert_in_delta(0.0, methods[4].self_time, 0.01)
172
+
173
+ assert_equal("#{RubyProf::PARENT}#initialize", methods[5].full_name)
174
+ assert_in_delta(0.0, methods[5].total_time, 0.01)
175
+ assert_in_delta(0.0, methods[5].wait_time, 0.01)
176
+ assert_in_delta(0.0, methods[5].self_time, 0.01)
177
+ end
178
+
179
+ def test_singleton
180
+ c3 = RubyProf::C3.new
181
+
182
+ class << c3
183
+ def hello
184
+ end
185
+ end
186
+
187
+ result = RubyProf.profile do
188
+ c3.hello
189
+ end
190
+
191
+ methods = result.threads.values.first.sort.reverse
192
+ assert_equal(2, methods.length)
193
+
194
+ assert_equal("MeasureProcessTimeTest#test_singleton", methods[0].full_name)
195
+ assert_equal("<Object::RubyProf::C3>#hello", methods[1].full_name)
196
+
197
+ assert_in_delta(0.0, methods[0].total_time, 0.01)
198
+ assert_in_delta(0.0, methods[0].wait_time, 0.01)
199
+ assert_in_delta(0.0, methods[0].self_time, 0.01)
200
+
201
+ assert_in_delta(0.0, methods[1].total_time, 0.01)
202
+ assert_in_delta(0.0, methods[1].wait_time, 0.01)
203
+ assert_in_delta(0.0, methods[1].self_time, 0.01)
204
+ end
205
+ end
@@ -0,0 +1,209 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require File.expand_path('../test_helper', __FILE__)
5
+
6
+ class MeasureWallTimeTest < Test::Unit::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_mode
13
+ RubyProf::measure_mode = RubyProf::WALL_TIME
14
+ assert_equal(RubyProf::WALL_TIME, RubyProf::measure_mode)
15
+ end
16
+
17
+ def test_wall_time_enabled_defined
18
+ assert(defined?(RubyProf::WALL_TIME_ENABLED))
19
+ end
20
+
21
+ def test_class_methods
22
+ result = RubyProf.profile do
23
+ RubyProf::C1.hello
24
+ end
25
+
26
+ # Length should be 3:
27
+ # MeasureWallTimeTest#test_class_methods
28
+ # <Class::RubyProf::C1>#hello
29
+ # Kernel#sleep
30
+
31
+ methods = result.threads.values.first.sort.reverse
32
+ assert_equal(3, methods.length)
33
+
34
+ # Check the names
35
+ assert_equal('MeasureWallTimeTest#test_class_methods', methods[0].full_name)
36
+ assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
37
+ assert_equal('Kernel#sleep', methods[2].full_name)
38
+
39
+ # Check times
40
+ assert_in_delta(0.1, methods[0].total_time, 0.01)
41
+ assert_in_delta(0, methods[0].wait_time, 0.01)
42
+ assert_in_delta(0, methods[0].self_time, 0.01)
43
+
44
+ assert_in_delta(0.1, methods[1].total_time, 0.01)
45
+ assert_in_delta(0, methods[1].wait_time, 0.01)
46
+ assert_in_delta(0, methods[1].self_time, 0.01)
47
+
48
+ assert_in_delta(0.1, methods[2].total_time, 0.01)
49
+ assert_in_delta(0, methods[2].wait_time, 0.01)
50
+ assert_in_delta(0.1, methods[2].self_time, 0.01)
51
+ end
52
+
53
+ def test_instance_methods
54
+ result = RubyProf.profile do
55
+ RubyProf::C1.new.hello
56
+ end
57
+
58
+ # Methods called
59
+ # MeasureWallTimeTest#test_instance_methods
60
+ # Class.new
61
+ # Class:Object#allocate
62
+ # for Object#initialize
63
+ # C1#hello
64
+ # Kernel#sleep
65
+
66
+ methods = result.threads.values.first.sort.reverse
67
+ assert_equal(6, methods.length)
68
+ names = methods.map(&:full_name)
69
+ assert_equal('MeasureWallTimeTest#test_instance_methods', names[0])
70
+ assert_equal('RubyProf::C1#hello', names[1])
71
+ assert_equal('Kernel#sleep', names[2])
72
+ assert_equal('Class#new', names[3])
73
+ # order can differ
74
+ assert(names.include?("<Class::#{RubyProf::PARENT}>#allocate"))
75
+ assert(names.include?("#{RubyProf::PARENT}#initialize"))
76
+
77
+ # Check times
78
+ assert_in_delta(0.2, methods[0].total_time, 0.02)
79
+ assert_in_delta(0, methods[0].wait_time, 0.02)
80
+ assert_in_delta(0, methods[0].self_time, 0.02)
81
+
82
+ assert_in_delta(0.2, methods[1].total_time, 0.02)
83
+ assert_in_delta(0, methods[1].wait_time, 0.02)
84
+ assert_in_delta(0, methods[1].self_time, 0.02)
85
+
86
+ assert_in_delta(0.2, methods[2].total_time, 0.02)
87
+ assert_in_delta(0, methods[2].wait_time, 0.02)
88
+ assert_in_delta(0.2, methods[2].self_time, 0.02)
89
+
90
+ assert_in_delta(0, methods[3].total_time, 0.01)
91
+ assert_in_delta(0, methods[3].wait_time, 0.01)
92
+ assert_in_delta(0, methods[3].self_time, 0.01)
93
+
94
+ assert_in_delta(0, methods[4].total_time, 0.01)
95
+ assert_in_delta(0, methods[4].wait_time, 0.01)
96
+ assert_in_delta(0, methods[4].self_time, 0.01)
97
+
98
+ assert_in_delta(0, methods[5].total_time, 0.01)
99
+ assert_in_delta(0, methods[5].wait_time, 0.01)
100
+ assert_in_delta(0, methods[5].self_time, 0.01)
101
+ end
102
+
103
+ def test_module_methods
104
+ result = RubyProf.profile do
105
+ RubyProf::C2.hello
106
+ end
107
+
108
+ # Methods:
109
+ # MeasureWallTimeTest#test_module_methods
110
+ # M1#hello
111
+ # Kernel#sleep
112
+
113
+ methods = result.threads.values.first.sort.reverse
114
+ assert_equal(3, methods.length)
115
+
116
+ assert_equal('MeasureWallTimeTest#test_module_methods', methods[0].full_name)
117
+ assert_equal('RubyProf::M1#hello', methods[1].full_name)
118
+ assert_equal('Kernel#sleep', methods[2].full_name)
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.02)
123
+ assert_in_delta(0, methods[0].self_time, 0.02)
124
+
125
+ assert_in_delta(0.3, methods[1].total_time, 0.1)
126
+ assert_in_delta(0, methods[1].wait_time, 0.02)
127
+ assert_in_delta(0, methods[1].self_time, 0.02)
128
+
129
+ assert_in_delta(0.3, methods[2].total_time, 0.1)
130
+ assert_in_delta(0, methods[2].wait_time, 0.02)
131
+ assert_in_delta(0.3, methods[2].self_time, 0.1)
132
+ end
133
+
134
+ def test_module_instance_methods
135
+ result = RubyProf.profile do
136
+ RubyProf::C2.new.hello
137
+ end
138
+
139
+ # Methods:
140
+ # MeasureWallTimeTest#test_module_instance_methods
141
+ # Class#new
142
+ # <Class::Object>#allocate
143
+ # Object#initialize
144
+ # M1#hello
145
+ # Kernel#sleep
146
+
147
+ methods = result.threads.values.first.sort.reverse
148
+ assert_equal(6, methods.length)
149
+ names = methods.map(&:full_name)
150
+ assert_equal('MeasureWallTimeTest#test_module_instance_methods', names[0])
151
+ assert_equal('RubyProf::M1#hello', names[1])
152
+ assert_equal('Kernel#sleep', names[2])
153
+ assert_equal('Class#new', names[3])
154
+ assert(names.include?("<Class::#{RubyProf::PARENT}>#allocate"))
155
+ assert(names.include?("#{RubyProf::PARENT}#initialize"))
156
+
157
+ # Check times
158
+ assert_in_delta(0.3, methods[0].total_time, 0.1)
159
+ assert_in_delta(0, methods[0].wait_time, 0.1)
160
+ assert_in_delta(0, methods[0].self_time, 0.1)
161
+
162
+ assert_in_delta(0.3, methods[1].total_time, 0.02)
163
+ assert_in_delta(0, methods[1].wait_time, 0.01)
164
+ assert_in_delta(0, methods[1].self_time, 0.01)
165
+
166
+ assert_in_delta(0.3, methods[2].total_time, 0.02)
167
+ assert_in_delta(0, methods[2].wait_time, 0.01)
168
+ assert_in_delta(0.3, methods[2].self_time, 0.02)
169
+
170
+ assert_in_delta(0, methods[3].total_time, 0.01)
171
+ assert_in_delta(0, methods[3].wait_time, 0.01)
172
+ assert_in_delta(0, methods[3].self_time, 0.01)
173
+
174
+ assert_in_delta(0, methods[4].total_time, 0.01)
175
+ assert_in_delta(0, methods[4].wait_time, 0.01)
176
+ assert_in_delta(0, methods[4].self_time, 0.01)
177
+
178
+ assert_in_delta(0, methods[5].total_time, 0.01)
179
+ assert_in_delta(0, methods[5].wait_time, 0.01)
180
+ assert_in_delta(0, methods[5].self_time, 0.01)
181
+ end
182
+
183
+ def test_singleton
184
+ c3 = RubyProf::C3.new
185
+
186
+ class << c3
187
+ def hello
188
+ end
189
+ end
190
+
191
+ result = RubyProf.profile do
192
+ c3.hello
193
+ end
194
+
195
+ methods = result.threads.values.first.sort.reverse
196
+ assert_equal(2, methods.length)
197
+
198
+ assert_equal('MeasureWallTimeTest#test_singleton', methods[0].full_name)
199
+ assert_equal('<Object::RubyProf::C3>#hello', methods[1].full_name)
200
+
201
+ assert_in_delta(0, methods[0].total_time, 0.01)
202
+ assert_in_delta(0, methods[0].wait_time, 0.01)
203
+ assert_in_delta(0, methods[0].self_time, 0.01)
204
+
205
+ assert_in_delta(0, methods[1].total_time, 0.01)
206
+ assert_in_delta(0, methods[1].wait_time, 0.01)
207
+ assert_in_delta(0, methods[1].self_time, 0.01)
208
+ end
209
+ end