ruby-prof 0.18.0-x64-mingw32 → 1.1.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +32 -0
- data/LICENSE +2 -2
- data/README.rdoc +1 -483
- data/Rakefile +3 -6
- data/bin/ruby-prof +65 -30
- data/ext/ruby_prof/extconf.rb +6 -38
- data/ext/ruby_prof/rp_allocation.c +279 -0
- data/ext/ruby_prof/rp_allocation.h +31 -0
- data/ext/ruby_prof/rp_call_info.c +129 -283
- data/ext/ruby_prof/rp_call_info.h +16 -34
- data/ext/ruby_prof/rp_measure_allocations.c +25 -49
- data/ext/ruby_prof/rp_measure_memory.c +21 -56
- data/ext/ruby_prof/rp_measure_process_time.c +35 -39
- data/ext/ruby_prof/rp_measure_wall_time.c +36 -19
- data/ext/ruby_prof/rp_measurement.c +230 -0
- data/ext/ruby_prof/rp_measurement.h +50 -0
- data/ext/ruby_prof/rp_method.c +389 -389
- data/ext/ruby_prof/rp_method.h +34 -39
- data/ext/ruby_prof/rp_profile.c +895 -0
- data/ext/ruby_prof/rp_profile.h +37 -0
- data/ext/ruby_prof/rp_stack.c +103 -80
- data/ext/ruby_prof/rp_stack.h +5 -12
- data/ext/ruby_prof/rp_thread.c +143 -83
- data/ext/ruby_prof/rp_thread.h +15 -6
- data/ext/ruby_prof/ruby_prof.c +11 -757
- data/ext/ruby_prof/ruby_prof.h +4 -47
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +10 -8
- data/lib/{2.6.3 → 2.6.5}/ruby_prof.so +0 -0
- data/lib/ruby-prof.rb +2 -18
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +713 -0
- data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
- data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
- data/lib/ruby-prof/call_info.rb +35 -93
- data/lib/ruby-prof/call_info_visitor.rb +19 -21
- data/lib/ruby-prof/compatibility.rb +37 -107
- data/lib/ruby-prof/exclude_common_methods.rb +198 -0
- data/lib/ruby-prof/measurement.rb +14 -0
- data/lib/ruby-prof/method_info.rb +52 -83
- data/lib/ruby-prof/printers/abstract_printer.rb +73 -50
- data/lib/ruby-prof/printers/call_info_printer.rb +13 -3
- data/lib/ruby-prof/printers/call_stack_printer.rb +62 -145
- data/lib/ruby-prof/printers/call_tree_printer.rb +20 -12
- data/lib/ruby-prof/printers/dot_printer.rb +5 -5
- data/lib/ruby-prof/printers/flat_printer.rb +6 -24
- data/lib/ruby-prof/printers/graph_html_printer.rb +6 -192
- data/lib/ruby-prof/printers/graph_printer.rb +13 -15
- data/lib/ruby-prof/printers/multi_printer.rb +66 -23
- data/lib/ruby-prof/profile.rb +10 -3
- data/lib/ruby-prof/rack.rb +0 -3
- data/lib/ruby-prof/thread.rb +12 -12
- data/lib/ruby-prof/version.rb +1 -1
- data/ruby-prof.gemspec +2 -2
- data/test/abstract_printer_test.rb +0 -27
- data/test/alias_test.rb +129 -0
- data/test/basic_test.rb +41 -40
- data/test/call_info_visitor_test.rb +3 -3
- data/test/dynamic_method_test.rb +0 -2
- data/test/fiber_test.rb +11 -17
- data/test/gc_test.rb +96 -0
- data/test/line_number_test.rb +120 -39
- data/test/marshal_test.rb +119 -0
- data/test/measure_allocations.rb +30 -0
- data/test/measure_allocations_test.rb +371 -12
- data/test/measure_allocations_trace_test.rb +385 -0
- data/test/measure_memory_trace_test.rb +756 -0
- data/test/measure_process_time_test.rb +821 -33
- data/test/measure_times.rb +54 -0
- data/test/measure_wall_time_test.rb +349 -145
- data/test/multi_printer_test.rb +1 -34
- data/test/parser_timings.rb +24 -0
- data/test/pause_resume_test.rb +5 -5
- data/test/prime.rb +2 -0
- data/test/printer_call_stack_test.rb +28 -0
- data/test/printer_call_tree_test.rb +31 -0
- data/test/printer_flat_test.rb +68 -0
- data/test/printer_graph_html_test.rb +60 -0
- data/test/printer_graph_test.rb +41 -0
- data/test/printers_test.rb +32 -166
- data/test/printing_recursive_graph_test.rb +26 -72
- data/test/recursive_test.rb +72 -77
- data/test/stack_printer_test.rb +2 -15
- data/test/start_stop_test.rb +22 -25
- data/test/test_helper.rb +5 -248
- data/test/thread_test.rb +11 -54
- data/test/unique_call_path_test.rb +16 -28
- data/test/yarv_test.rb +1 -0
- metadata +28 -36
- data/examples/flat.txt +0 -50
- data/examples/graph.dot +0 -84
- data/examples/graph.html +0 -823
- data/examples/graph.txt +0 -139
- data/examples/multi.flat.txt +0 -23
- data/examples/multi.graph.html +0 -760
- data/examples/multi.grind.dat +0 -114
- data/examples/multi.stack.html +0 -547
- data/examples/stack.html +0 -547
- data/ext/ruby_prof/rp_measure.c +0 -40
- data/ext/ruby_prof/rp_measure.h +0 -45
- data/ext/ruby_prof/rp_measure_cpu_time.c +0 -136
- data/ext/ruby_prof/rp_measure_gc_runs.c +0 -73
- data/ext/ruby_prof/rp_measure_gc_time.c +0 -60
- data/lib/ruby-prof/aggregate_call_info.rb +0 -76
- data/lib/ruby-prof/assets/call_stack_printer.css.html +0 -117
- data/lib/ruby-prof/assets/call_stack_printer.js.html +0 -385
- data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -83
- data/lib/ruby-prof/profile/exclude_common_methods.rb +0 -207
- data/lib/ruby-prof/profile/legacy_method_elimination.rb +0 -50
- data/test/aggregate_test.rb +0 -136
- data/test/block_test.rb +0 -74
- data/test/call_info_test.rb +0 -78
- data/test/issue137_test.rb +0 -63
- data/test/measure_cpu_time_test.rb +0 -212
- data/test/measure_gc_runs_test.rb +0 -32
- data/test/measure_gc_time_test.rb +0 -36
- data/test/measure_memory_test.rb +0 -33
- data/test/method_elimination_test.rb +0 -84
- data/test/module_test.rb +0 -45
- data/test/stack_test.rb +0 -138
@@ -2,60 +2,848 @@
|
|
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 MeasureProcessTimeTest < TestCase
|
7
8
|
def setup
|
8
9
|
# Need to fix this for linux (windows works since PROCESS_TIME is WALL_TIME anyway)
|
9
10
|
RubyProf::measure_mode = RubyProf::PROCESS_TIME
|
11
|
+
GC.start
|
10
12
|
end
|
11
13
|
|
12
14
|
def test_mode
|
13
15
|
assert_equal(RubyProf::PROCESS_TIME, RubyProf::measure_mode)
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
17
|
-
|
18
|
+
def test_class_methods_sleep
|
19
|
+
result = RubyProf.profile do
|
20
|
+
RubyProf::C1.sleep_wait
|
21
|
+
end
|
22
|
+
|
23
|
+
thread = result.threads.first
|
24
|
+
assert_in_delta(0.0, thread.total_time, 0.05)
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
31
|
+
assert_equal(3, methods.length)
|
32
|
+
|
33
|
+
# Check times
|
34
|
+
method = methods[0]
|
35
|
+
assert_equal('MeasureProcessTimeTest#test_class_methods_sleep', method.full_name)
|
36
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
37
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
38
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
39
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
40
|
+
|
41
|
+
method = methods[1]
|
42
|
+
assert_equal('<Class::RubyProf::C1>#sleep_wait', method.full_name)
|
43
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
44
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
45
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
46
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
47
|
+
|
48
|
+
method = methods[2]
|
49
|
+
assert_equal('Kernel#sleep', method.full_name)
|
50
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
51
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
52
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
53
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
18
54
|
end
|
19
55
|
|
20
|
-
def
|
21
|
-
start = Process.times
|
56
|
+
def test_class_methods_sleep_threaded
|
22
57
|
result = RubyProf.profile do
|
23
|
-
|
58
|
+
background_thread = Thread.new do
|
59
|
+
RubyProf::C1.sleep_wait
|
60
|
+
end
|
61
|
+
background_thread.join
|
24
62
|
end
|
25
|
-
finish = Process.times
|
26
63
|
|
27
|
-
|
64
|
+
assert_equal(2, result.threads.count)
|
65
|
+
|
66
|
+
thread = result.threads.first
|
67
|
+
assert_in_delta(0.0, thread.total_time, 0.05)
|
68
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
74
|
+
assert_equal(4, methods.length)
|
75
|
+
|
76
|
+
# Check times
|
77
|
+
method = methods[0]
|
78
|
+
assert_equal('MeasureProcessTimeTest#test_class_methods_sleep_threaded', method.full_name)
|
79
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
80
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
81
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
82
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
83
|
+
|
84
|
+
method = methods[1]
|
85
|
+
assert_equal('Thread#join', method.full_name)
|
86
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
87
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
88
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
89
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
90
|
+
|
91
|
+
method = methods[2]
|
92
|
+
assert_equal('<Class::Thread>#new', method.full_name)
|
93
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
94
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
95
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
96
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
97
|
+
|
98
|
+
method = methods[3]
|
99
|
+
assert_equal('Thread#initialize', method.full_name)
|
100
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
101
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
102
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
103
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
104
|
+
|
105
|
+
thread = result.threads.last
|
106
|
+
assert_in_delta(0.0, thread.total_time, 0.05)
|
107
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
113
|
+
assert_equal(4, methods.length)
|
114
|
+
|
115
|
+
methods = result.threads.last.methods.sort.reverse
|
116
|
+
assert_equal(3, methods.length)
|
117
|
+
|
118
|
+
# Check times
|
119
|
+
method = methods[0]
|
120
|
+
assert_equal('MeasureProcessTimeTest#test_class_methods_sleep_threaded', method.full_name)
|
121
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
122
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
123
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
124
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
125
|
+
|
126
|
+
method = methods[1]
|
127
|
+
assert_equal('<Class::RubyProf::C1>#sleep_wait', method.full_name)
|
128
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
129
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
130
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
131
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
132
|
+
|
133
|
+
method = methods[2]
|
134
|
+
assert_equal('Kernel#sleep', method.full_name)
|
135
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
136
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
137
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
138
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_class_methods_busy
|
142
|
+
result = RubyProf.profile do
|
143
|
+
RubyProf::C1.busy_wait
|
144
|
+
end
|
28
145
|
|
29
146
|
thread = result.threads.first
|
30
|
-
assert_in_delta(
|
147
|
+
assert_in_delta(0.08, thread.total_time, 0.05)
|
148
|
+
|
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)
|
31
152
|
|
32
153
|
methods = result.threads.first.methods.sort.reverse
|
154
|
+
assert_equal(3, methods.length)
|
33
155
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
156
|
+
# Check times
|
157
|
+
method = methods[0]
|
158
|
+
assert_equal('MeasureProcessTimeTest#test_class_methods_busy', method.full_name)
|
159
|
+
assert_in_delta(0.1, method.total_time, 0.05)
|
160
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
161
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
162
|
+
assert_in_delta(0.1, method.children_time, 0.05)
|
163
|
+
|
164
|
+
method = methods[1]
|
165
|
+
assert_equal('<Class::RubyProf::C1>#busy_wait', method.full_name)
|
166
|
+
assert_in_delta(0.1, method.total_time, 0.05)
|
167
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
168
|
+
assert_in_delta(0.06, method.self_time, 0.05)
|
169
|
+
assert_in_delta(0.07, method.children_time, 0.05)
|
170
|
+
|
171
|
+
method = methods[2]
|
172
|
+
assert_equal('<Module::Process>#clock_gettime', method.full_name)
|
173
|
+
assert_in_delta(0.05, method.total_time, 0.05)
|
174
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
175
|
+
assert_in_delta(0.05, method.self_time, 0.05)
|
176
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_class_methods_busy_threaded
|
180
|
+
result = RubyProf.profile do
|
181
|
+
background_thread = Thread.new do
|
182
|
+
RubyProf::C1.busy_wait
|
38
183
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
assert_in_delta(0.
|
46
|
-
|
47
|
-
|
48
|
-
assert_equal(
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
assert_equal(
|
57
|
-
|
58
|
-
|
59
|
-
|
184
|
+
background_thread.join
|
185
|
+
end
|
186
|
+
|
187
|
+
assert_equal(2, result.threads.count)
|
188
|
+
|
189
|
+
thread = result.threads.first
|
190
|
+
assert_in_delta(0.1, thread.total_time, 0.05)
|
191
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
197
|
+
assert_equal(4, methods.length)
|
198
|
+
|
199
|
+
# Check times
|
200
|
+
method = methods[0]
|
201
|
+
assert_equal('MeasureProcessTimeTest#test_class_methods_busy_threaded', method.full_name)
|
202
|
+
assert_in_delta(0.1, method.total_time, 0.05)
|
203
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
204
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
205
|
+
assert_in_delta(0.1, method.children_time, 0.05)
|
206
|
+
|
207
|
+
method = methods[1]
|
208
|
+
assert_equal('Thread#join', method.full_name)
|
209
|
+
assert_in_delta(0.1, method.total_time, 0.05)
|
210
|
+
assert_in_delta(0.1, method.wait_time, 0.05)
|
211
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
212
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
213
|
+
|
214
|
+
method = methods[2]
|
215
|
+
assert_equal('<Class::Thread>#new', method.full_name)
|
216
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
217
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
218
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
219
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
220
|
+
|
221
|
+
method = methods[3]
|
222
|
+
assert_equal('Thread#initialize', method.full_name)
|
223
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
224
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
225
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
226
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
227
|
+
|
228
|
+
thread = result.threads.last
|
229
|
+
assert_in_delta(0.1, thread.total_time, 0.05)
|
230
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
236
|
+
assert_equal(4, methods.length)
|
237
|
+
|
238
|
+
methods = result.threads.last.methods.sort.reverse
|
239
|
+
assert_equal(3, methods.length)
|
240
|
+
|
241
|
+
# Check times
|
242
|
+
method = methods[0]
|
243
|
+
assert_equal('MeasureProcessTimeTest#test_class_methods_busy_threaded', method.full_name)
|
244
|
+
assert_in_delta(0.1, method.total_time, 0.05)
|
245
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
246
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
247
|
+
assert_in_delta(0.1, method.children_time, 0.05)
|
248
|
+
|
249
|
+
method = methods[1]
|
250
|
+
assert_equal('<Class::RubyProf::C1>#busy_wait', method.full_name)
|
251
|
+
assert_in_delta(0.1, method.total_time, 0.05)
|
252
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
253
|
+
assert_in_delta(0.05, method.self_time, 0.05)
|
254
|
+
assert_in_delta(0.05, method.children_time, 0.05)
|
255
|
+
|
256
|
+
method = methods[2]
|
257
|
+
assert_equal('<Module::Process>#clock_gettime', method.full_name)
|
258
|
+
assert_in_delta(0.05, method.total_time, 0.05)
|
259
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
260
|
+
assert_in_delta(0.05, method.self_time, 0.05)
|
261
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
262
|
+
end
|
263
|
+
|
264
|
+
def test_instance_methods_sleep
|
265
|
+
result = RubyProf.profile do
|
266
|
+
RubyProf::C1.new.sleep_wait
|
267
|
+
end
|
268
|
+
|
269
|
+
thread = result.threads.first
|
270
|
+
assert_in_delta(0.0, thread.total_time, 0.05)
|
271
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
277
|
+
assert_equal(5, methods.length)
|
278
|
+
|
279
|
+
# Check times
|
280
|
+
method = methods[0]
|
281
|
+
assert_equal('MeasureProcessTimeTest#test_instance_methods_sleep', method.full_name)
|
282
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
283
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
284
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
285
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
286
|
+
|
287
|
+
method = methods[1]
|
288
|
+
assert_equal('RubyProf::C1#sleep_wait', method.full_name)
|
289
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
290
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
291
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
292
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
293
|
+
|
294
|
+
method = methods[2]
|
295
|
+
assert_equal('Kernel#sleep', method.full_name)
|
296
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
297
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
298
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
299
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
300
|
+
|
301
|
+
method = methods[3]
|
302
|
+
assert_equal('Class#new', method.full_name)
|
303
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
304
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
305
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
306
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
307
|
+
|
308
|
+
method = methods[4]
|
309
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
310
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
311
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
312
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
313
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
314
|
+
end
|
315
|
+
|
316
|
+
def test_instance_methods_sleep_block
|
317
|
+
result = RubyProf.profile do
|
318
|
+
1.times { RubyProf::C1.new.sleep_wait }
|
319
|
+
end
|
320
|
+
|
321
|
+
methods = result.threads.first.methods.sort.reverse
|
322
|
+
assert_equal(6, methods.length)
|
323
|
+
|
324
|
+
# Check times
|
325
|
+
method = methods[0]
|
326
|
+
assert_equal("MeasureProcessTimeTest#test_instance_methods_sleep_block", method.full_name)
|
327
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
328
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
329
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
330
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
331
|
+
|
332
|
+
method = methods[1]
|
333
|
+
assert_equal('Integer#times', method.full_name)
|
334
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
335
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
336
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
337
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
338
|
+
|
339
|
+
method = methods[2]
|
340
|
+
assert_equal('RubyProf::C1#sleep_wait', method.full_name)
|
341
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
342
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
343
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
344
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
345
|
+
|
346
|
+
method = methods[3]
|
347
|
+
assert_equal('Kernel#sleep', method.full_name)
|
348
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
349
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
350
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
351
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
352
|
+
|
353
|
+
method = methods[4]
|
354
|
+
assert_equal('Class#new', method.full_name)
|
355
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
356
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
357
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
358
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
359
|
+
|
360
|
+
method = methods[5]
|
361
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
362
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
363
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
364
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
365
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
366
|
+
end
|
367
|
+
|
368
|
+
def test_instance_methods_sleep_threaded
|
369
|
+
result = RubyProf.profile do
|
370
|
+
background_thread = Thread.new do
|
371
|
+
RubyProf::C1.new.sleep_wait
|
372
|
+
end
|
373
|
+
background_thread.join
|
374
|
+
end
|
375
|
+
|
376
|
+
assert_equal(2, result.threads.count)
|
377
|
+
|
378
|
+
thread = result.threads.first
|
379
|
+
assert_in_delta(0.0, thread.total_time, 0.05)
|
380
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
386
|
+
assert_equal(4, methods.length)
|
387
|
+
|
388
|
+
# Check times
|
389
|
+
method = methods[0]
|
390
|
+
assert_equal('MeasureProcessTimeTest#test_instance_methods_sleep_threaded', method.full_name)
|
391
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
392
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
393
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
394
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
395
|
+
|
396
|
+
method = methods[1]
|
397
|
+
assert_equal('Thread#join', method.full_name)
|
398
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
399
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
400
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
401
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
402
|
+
|
403
|
+
method = methods[2]
|
404
|
+
assert_equal('<Class::Thread>#new', method.full_name)
|
405
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
406
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
407
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
408
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
409
|
+
|
410
|
+
method = methods[3]
|
411
|
+
assert_equal('Thread#initialize', method.full_name)
|
412
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
413
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
414
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
415
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
416
|
+
|
417
|
+
thread = result.threads.last
|
418
|
+
assert_in_delta(0.0, thread.total_time, 0.05)
|
419
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
425
|
+
assert_equal(4, methods.length)
|
426
|
+
|
427
|
+
methods = result.threads.last.methods.sort.reverse
|
428
|
+
assert_equal(5, methods.length)
|
429
|
+
|
430
|
+
# Check times
|
431
|
+
method = methods[0]
|
432
|
+
assert_equal('MeasureProcessTimeTest#test_instance_methods_sleep_threaded', method.full_name)
|
433
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
434
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
435
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
436
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
437
|
+
|
438
|
+
method = methods[1]
|
439
|
+
assert_equal('RubyProf::C1#sleep_wait', method.full_name)
|
440
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
441
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
442
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
443
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
444
|
+
|
445
|
+
method = methods[2]
|
446
|
+
assert_equal('Kernel#sleep', method.full_name)
|
447
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
448
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
449
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
450
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
451
|
+
|
452
|
+
method = methods[3]
|
453
|
+
assert_equal('Class#new', method.full_name)
|
454
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
455
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
456
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
457
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
458
|
+
|
459
|
+
method = methods[4]
|
460
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
461
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
462
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
463
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
464
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
465
|
+
end
|
466
|
+
|
467
|
+
def test_instance_methods_busy
|
468
|
+
result = RubyProf.profile do
|
469
|
+
RubyProf::C1.new.busy_wait
|
470
|
+
end
|
471
|
+
|
472
|
+
thread = result.threads.first
|
473
|
+
assert_in_delta(0.2, thread.total_time, 0.05)
|
474
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
480
|
+
assert_equal(5, methods.length)
|
481
|
+
|
482
|
+
# Check times
|
483
|
+
method = methods[0]
|
484
|
+
assert_equal('MeasureProcessTimeTest#test_instance_methods_busy', method.full_name)
|
485
|
+
assert_in_delta(0.2, method.total_time, 0.05)
|
486
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
487
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
488
|
+
assert_in_delta(0.2, method.children_time, 0.05)
|
489
|
+
|
490
|
+
method = methods[1]
|
491
|
+
assert_equal('RubyProf::C1#busy_wait', method.full_name)
|
492
|
+
assert_in_delta(0.2, method.total_time, 0.05)
|
493
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
494
|
+
assert_in_delta(0.09, method.self_time, 0.05)
|
495
|
+
assert_in_delta(0.11, method.children_time, 0.05)
|
496
|
+
|
497
|
+
method = methods[2]
|
498
|
+
assert_equal('<Module::Process>#clock_gettime', method.full_name)
|
499
|
+
assert_in_delta(0.11, method.total_time, 0.05)
|
500
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
501
|
+
assert_in_delta(0.11, method.self_time, 0.05)
|
502
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
503
|
+
|
504
|
+
method = methods[3]
|
505
|
+
assert_equal('Class#new', method.full_name)
|
506
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
507
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
508
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
509
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
510
|
+
|
511
|
+
method = methods[4]
|
512
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
513
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
514
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
515
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
516
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
517
|
+
end
|
518
|
+
|
519
|
+
def test_instance_methods_busy_block
|
520
|
+
result = RubyProf.profile do
|
521
|
+
1.times { RubyProf::C1.new.busy_wait }
|
522
|
+
end
|
523
|
+
|
524
|
+
methods = result.threads.first.methods.sort.reverse
|
525
|
+
assert_equal(6, methods.length)
|
526
|
+
|
527
|
+
# Check times
|
528
|
+
method = methods[0]
|
529
|
+
assert_equal("MeasureProcessTimeTest#test_instance_methods_busy_block", method.full_name)
|
530
|
+
assert_in_delta(0.2, method.total_time, 0.05)
|
531
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
532
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
533
|
+
assert_in_delta(0.2, method.children_time, 0.05)
|
534
|
+
|
535
|
+
method = methods[1]
|
536
|
+
assert_equal('Integer#times', method.full_name)
|
537
|
+
assert_in_delta(0.2, method.total_time, 0.05)
|
538
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
539
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
540
|
+
assert_in_delta(0.2, method.children_time, 0.05)
|
541
|
+
|
542
|
+
method = methods[2]
|
543
|
+
assert_equal('RubyProf::C1#busy_wait', method.full_name)
|
544
|
+
assert_in_delta(0.2, method.total_time, 0.05)
|
545
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
546
|
+
assert_in_delta(0.09, method.self_time, 0.05)
|
547
|
+
assert_in_delta(0.11, method.children_time, 0.05)
|
548
|
+
|
549
|
+
method = methods[3]
|
550
|
+
assert_equal('<Module::Process>#clock_gettime', method.full_name)
|
551
|
+
assert_in_delta(0.11, method.total_time, 0.05)
|
552
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
553
|
+
assert_in_delta(0.11, method.self_time, 0.05)
|
554
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
555
|
+
|
556
|
+
method = methods[4]
|
557
|
+
assert_equal('Class#new', method.full_name)
|
558
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
559
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
560
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
561
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
562
|
+
|
563
|
+
method = methods[5]
|
564
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
565
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
566
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
567
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
568
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
569
|
+
end
|
570
|
+
|
571
|
+
def test_instance_methods_busy_threaded
|
572
|
+
result = RubyProf.profile do
|
573
|
+
background_thread = Thread.new do
|
574
|
+
RubyProf::C1.new.busy_wait
|
575
|
+
end
|
576
|
+
background_thread.join
|
577
|
+
end
|
578
|
+
|
579
|
+
assert_equal(2, result.threads.count)
|
580
|
+
|
581
|
+
thread = result.threads.first
|
582
|
+
assert_in_delta(0.2, thread.total_time, 0.05)
|
583
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
589
|
+
assert_equal(4, methods.length)
|
590
|
+
|
591
|
+
# Check times
|
592
|
+
method = methods[0]
|
593
|
+
assert_equal('MeasureProcessTimeTest#test_instance_methods_busy_threaded', method.full_name)
|
594
|
+
assert_in_delta(0.2, method.total_time, 0.05)
|
595
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
596
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
597
|
+
assert_in_delta(0.2, method.children_time, 0.05)
|
598
|
+
|
599
|
+
method = methods[1]
|
600
|
+
assert_equal('Thread#join', method.full_name)
|
601
|
+
assert_in_delta(0.2, method.total_time, 0.05)
|
602
|
+
assert_in_delta(0.2, method.wait_time, 0.05)
|
603
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
604
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
605
|
+
|
606
|
+
method = methods[2]
|
607
|
+
assert_equal('<Class::Thread>#new', method.full_name)
|
608
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
609
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
610
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
611
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
612
|
+
|
613
|
+
method = methods[3]
|
614
|
+
assert_equal('Thread#initialize', method.full_name)
|
615
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
616
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
617
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
618
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
619
|
+
|
620
|
+
thread = result.threads.last
|
621
|
+
assert_in_delta(0.2, thread.total_time, 0.05)
|
622
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
628
|
+
assert_equal(4, methods.length)
|
629
|
+
|
630
|
+
methods = result.threads.last.methods.sort.reverse
|
631
|
+
assert_equal(5, methods.length)
|
632
|
+
|
633
|
+
# Check times
|
634
|
+
method = methods[0]
|
635
|
+
assert_equal('MeasureProcessTimeTest#test_instance_methods_busy_threaded', method.full_name)
|
636
|
+
assert_in_delta(0.2, method.total_time, 0.05)
|
637
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
638
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
639
|
+
assert_in_delta(0.2, method.children_time, 0.05)
|
640
|
+
|
641
|
+
method = methods[1]
|
642
|
+
assert_equal('RubyProf::C1#busy_wait', method.full_name)
|
643
|
+
assert_in_delta(0.2, method.total_time, 0.05)
|
644
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
645
|
+
assert_in_delta(0.1, method.self_time, 0.05)
|
646
|
+
assert_in_delta(0.1, method.children_time, 0.05)
|
647
|
+
|
648
|
+
method = methods[2]
|
649
|
+
assert_equal('<Module::Process>#clock_gettime', method.full_name)
|
650
|
+
assert_in_delta(0.1, method.total_time, 0.05)
|
651
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
652
|
+
assert_in_delta(0.1, method.self_time, 0.05)
|
653
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
654
|
+
|
655
|
+
method = methods[3]
|
656
|
+
assert_equal('Class#new', method.full_name)
|
657
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
658
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
659
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
660
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
661
|
+
|
662
|
+
method = methods[4]
|
663
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
664
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
665
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
666
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
667
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
668
|
+
end
|
669
|
+
|
670
|
+
def test_module_methods_sleep
|
671
|
+
result = RubyProf.profile do
|
672
|
+
RubyProf::C2.sleep_wait
|
673
|
+
end
|
674
|
+
|
675
|
+
thread = result.threads.first
|
676
|
+
assert_in_delta(0.0, thread.total_time, 0.05)
|
677
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
683
|
+
assert_equal(3, methods.length)
|
684
|
+
|
685
|
+
# Check times
|
686
|
+
method = methods[0]
|
687
|
+
assert_equal('MeasureProcessTimeTest#test_module_methods_sleep', method.full_name)
|
688
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
689
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
690
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
691
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
692
|
+
|
693
|
+
method = methods[1]
|
694
|
+
assert_equal('RubyProf::M1#sleep_wait', method.full_name)
|
695
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
696
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
697
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
698
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
699
|
+
|
700
|
+
method = methods[2]
|
701
|
+
assert_equal('Kernel#sleep', method.full_name)
|
702
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
703
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
704
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
705
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
706
|
+
end
|
707
|
+
|
708
|
+
def test_module_methods_busy
|
709
|
+
result = RubyProf.profile do
|
710
|
+
RubyProf::C2.busy_wait
|
711
|
+
end
|
712
|
+
|
713
|
+
thread = result.threads.first
|
714
|
+
assert_in_delta(0.3, thread.total_time, 0.05)
|
715
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
721
|
+
assert_equal(3, methods.length)
|
722
|
+
|
723
|
+
# Check times
|
724
|
+
method = methods[0]
|
725
|
+
assert_equal('MeasureProcessTimeTest#test_module_methods_busy', method.full_name)
|
726
|
+
assert_in_delta(0.3, method.total_time, 0.05)
|
727
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
728
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
729
|
+
assert_in_delta(0.3, method.children_time, 0.05)
|
730
|
+
|
731
|
+
method = methods[1]
|
732
|
+
assert_equal('RubyProf::M1#busy_wait', method.full_name)
|
733
|
+
assert_in_delta(0.3, method.total_time, 0.05)
|
734
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
735
|
+
assert_in_delta(0.15, method.self_time, 0.05)
|
736
|
+
assert_in_delta(0.15, method.children_time, 0.05)
|
737
|
+
|
738
|
+
method = methods[2]
|
739
|
+
assert_equal('<Module::Process>#clock_gettime', method.full_name)
|
740
|
+
assert_in_delta(0.15, method.total_time, 0.05)
|
741
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
742
|
+
assert_in_delta(0.15, method.self_time, 0.05)
|
743
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
744
|
+
end
|
745
|
+
|
746
|
+
def test_module_instance_methods_sleep
|
747
|
+
result = RubyProf.profile do
|
748
|
+
RubyProf::C2.new.sleep_wait
|
749
|
+
end
|
750
|
+
|
751
|
+
thread = result.threads.first
|
752
|
+
assert_in_delta(0.0, thread.total_time, 0.05)
|
753
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
759
|
+
assert_equal(5, methods.length)
|
760
|
+
|
761
|
+
# Check times
|
762
|
+
method = methods[0]
|
763
|
+
assert_equal('MeasureProcessTimeTest#test_module_instance_methods_sleep', method.full_name)
|
764
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
765
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
766
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
767
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
768
|
+
|
769
|
+
method = methods[1]
|
770
|
+
assert_equal('RubyProf::M1#sleep_wait', method.full_name)
|
771
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
772
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
773
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
774
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
775
|
+
|
776
|
+
method = methods[2]
|
777
|
+
assert_equal('Kernel#sleep', method.full_name)
|
778
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
779
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
780
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
781
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
782
|
+
|
783
|
+
method = methods[3]
|
784
|
+
assert_equal('Class#new', method.full_name)
|
785
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
786
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
787
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
788
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
789
|
+
|
790
|
+
method = methods[4]
|
791
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
792
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
793
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
794
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
795
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
796
|
+
end
|
797
|
+
|
798
|
+
def test_module_instance_methods_busy
|
799
|
+
result = RubyProf.profile do
|
800
|
+
RubyProf::C2.new.busy_wait
|
801
|
+
end
|
802
|
+
|
803
|
+
thread = result.threads.first
|
804
|
+
assert_in_delta(0.3, thread.total_time, 0.05)
|
805
|
+
|
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
|
+
methods = result.threads.first.methods.sort.reverse
|
811
|
+
assert_equal(5, methods.length)
|
812
|
+
|
813
|
+
# Check times
|
814
|
+
method = methods[0]
|
815
|
+
assert_equal('MeasureProcessTimeTest#test_module_instance_methods_busy', method.full_name)
|
816
|
+
assert_in_delta(0.3, method.total_time, 0.05)
|
817
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
818
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
819
|
+
assert_in_delta(0.3, method.children_time, 0.05)
|
820
|
+
|
821
|
+
method = methods[1]
|
822
|
+
assert_equal('RubyProf::M1#busy_wait', method.full_name)
|
823
|
+
assert_in_delta(0.3, method.total_time, 0.05)
|
824
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
825
|
+
assert_in_delta(0.15, method.self_time, 0.05)
|
826
|
+
assert_in_delta(0.15, method.children_time, 0.05)
|
827
|
+
|
828
|
+
method = methods[2]
|
829
|
+
assert_equal('<Module::Process>#clock_gettime', method.full_name)
|
830
|
+
assert_in_delta(0.15, method.total_time, 0.05)
|
831
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
832
|
+
assert_in_delta(0.15, method.self_time, 0.05)
|
833
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
834
|
+
|
835
|
+
method = methods[3]
|
836
|
+
assert_equal('Class#new', method.full_name)
|
837
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
838
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
839
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
840
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
841
|
+
|
842
|
+
method = methods[4]
|
843
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
844
|
+
assert_in_delta(0.0, method.total_time, 0.05)
|
845
|
+
assert_in_delta(0.0, method.wait_time, 0.05)
|
846
|
+
assert_in_delta(0.0, method.self_time, 0.05)
|
847
|
+
assert_in_delta(0.0, method.children_time, 0.05)
|
60
848
|
end
|
61
849
|
end
|