ruby-prof 1.7.1 → 2.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.
- checksums.yaml +4 -4
- data/{CHANGES → CHANGELOG.md} +118 -176
- data/README.md +5 -5
- data/bin/ruby-prof +1 -4
- data/docs/advanced-usage.md +132 -0
- data/docs/alternatives.md +98 -0
- data/docs/architecture.md +122 -0
- data/docs/best-practices.md +27 -0
- data/docs/getting-started.md +130 -0
- data/docs/history.md +11 -0
- data/docs/index.md +45 -0
- data/docs/profiling-rails.md +64 -0
- data/docs/public/examples/example.rb +33 -0
- data/docs/public/examples/generate_reports.rb +92 -0
- data/docs/public/examples/reports/call_info.txt +27 -0
- data/docs/public/examples/reports/call_stack.html +835 -0
- data/docs/public/examples/reports/callgrind.out +150 -0
- data/docs/public/examples/reports/flame_graph.html +408 -0
- data/docs/public/examples/reports/flat.txt +45 -0
- data/docs/public/examples/reports/graph.dot +129 -0
- data/docs/public/examples/reports/graph.html +1319 -0
- data/docs/public/examples/reports/graph.txt +100 -0
- data/docs/public/examples/reports/graphviz_viewer.html +1 -0
- data/docs/public/images/call_stack.png +0 -0
- data/docs/public/images/class_diagram.png +0 -0
- data/docs/public/images/dot_printer.png +0 -0
- data/docs/public/images/flame_graph.png +0 -0
- data/docs/public/images/flat.png +0 -0
- data/docs/public/images/graph.png +0 -0
- data/docs/public/images/graph_html.png +0 -0
- data/docs/public/images/ruby-prof-logo.svg +1 -0
- data/docs/reports.md +150 -0
- data/docs/stylesheets/extra.css +80 -0
- data/ext/ruby_prof/extconf.rb +23 -22
- data/ext/ruby_prof/rp_allocation.c +0 -15
- data/ext/ruby_prof/rp_allocation.h +29 -33
- data/ext/ruby_prof/rp_call_tree.c +3 -0
- data/ext/ruby_prof/rp_call_tree.h +1 -4
- data/ext/ruby_prof/rp_call_trees.c +296 -296
- data/ext/ruby_prof/rp_call_trees.h +25 -28
- data/ext/ruby_prof/rp_measure_allocations.c +47 -47
- data/ext/ruby_prof/rp_measure_process_time.c +64 -66
- data/ext/ruby_prof/rp_measure_wall_time.c +52 -64
- data/ext/ruby_prof/rp_measurement.c +0 -5
- data/ext/ruby_prof/rp_measurement.h +49 -53
- data/ext/ruby_prof/rp_method.c +554 -551
- data/ext/ruby_prof/rp_method.h +1 -4
- data/ext/ruby_prof/rp_profile.c +1 -1
- data/ext/ruby_prof/rp_profile.h +1 -5
- data/ext/ruby_prof/rp_stack.c +212 -212
- data/ext/ruby_prof/rp_stack.h +50 -53
- data/ext/ruby_prof/rp_thread.h +1 -4
- data/ext/ruby_prof/ruby_prof.c +50 -50
- data/ext/ruby_prof/ruby_prof.h +4 -6
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +7 -8
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +746 -711
- data/lib/ruby-prof/assets/flame_graph_printer.html.erb +412 -0
- data/lib/ruby-prof/assets/graph_printer.html.erb +355 -355
- data/lib/ruby-prof/call_tree.rb +57 -57
- data/lib/ruby-prof/call_tree_visitor.rb +36 -36
- data/lib/ruby-prof/exclude_common_methods.rb +204 -204
- data/lib/ruby-prof/measurement.rb +17 -17
- data/lib/ruby-prof/printers/abstract_printer.rb +142 -138
- data/lib/ruby-prof/printers/call_info_printer.rb +53 -53
- data/lib/ruby-prof/printers/call_stack_printer.rb +168 -180
- data/lib/ruby-prof/printers/call_tree_printer.rb +132 -145
- data/lib/ruby-prof/printers/dot_printer.rb +177 -132
- data/lib/ruby-prof/printers/flame_graph_printer.rb +79 -0
- data/lib/ruby-prof/printers/flat_printer.rb +52 -52
- data/lib/ruby-prof/printers/graph_html_printer.rb +62 -63
- data/lib/ruby-prof/printers/graph_printer.rb +112 -113
- data/lib/ruby-prof/printers/multi_printer.rb +134 -127
- data/lib/ruby-prof/profile.rb +13 -0
- data/lib/ruby-prof/rack.rb +114 -105
- data/lib/ruby-prof/task.rb +147 -147
- data/lib/ruby-prof/thread.rb +20 -20
- data/lib/ruby-prof/version.rb +3 -3
- data/lib/ruby-prof.rb +50 -52
- data/lib/unprof.rb +10 -10
- data/ruby-prof.gemspec +66 -65
- data/test/abstract_printer_test.rb +25 -27
- data/test/alias_test.rb +203 -117
- data/test/call_tree_builder.rb +126 -126
- data/test/call_tree_visitor_test.rb +27 -27
- data/test/call_trees_test.rb +66 -66
- data/test/duplicate_names_test.rb +32 -32
- data/test/dynamic_method_test.rb +50 -62
- data/test/enumerable_test.rb +23 -21
- data/test/exceptions_test.rb +24 -24
- data/test/exclude_methods_test.rb +363 -257
- data/test/exclude_threads_test.rb +48 -48
- data/test/fiber_test.rb +195 -195
- data/test/gc_test.rb +104 -102
- data/test/inverse_call_tree_test.rb +174 -174
- data/test/line_number_test.rb +563 -289
- data/test/marshal_test.rb +144 -145
- data/test/measure_allocations.rb +26 -26
- data/test/measure_allocations_test.rb +1511 -1081
- data/test/measure_process_time_test.rb +3286 -2477
- data/test/measure_times.rb +56 -56
- data/test/measure_wall_time_test.rb +773 -568
- data/test/measurement_test.rb +82 -82
- data/test/merge_test.rb +146 -146
- data/test/method_info_test.rb +100 -95
- data/test/multi_printer_test.rb +52 -66
- data/test/no_method_class_test.rb +15 -15
- data/test/pause_resume_test.rb +171 -171
- data/test/prime.rb +54 -54
- data/test/prime_script.rb +5 -5
- data/test/printer_call_stack_test.rb +28 -27
- data/test/printer_call_tree_test.rb +30 -30
- data/test/printer_flame_graph_test.rb +82 -0
- data/test/printer_flat_test.rb +99 -99
- data/test/printer_graph_html_test.rb +62 -59
- data/test/printer_graph_test.rb +42 -40
- data/test/printers_test.rb +162 -135
- data/test/printing_recursive_graph_test.rb +81 -81
- data/test/profile_test.rb +101 -101
- data/test/rack_test.rb +103 -93
- data/test/recursive_test.rb +796 -622
- data/test/scheduler.rb +4 -0
- data/test/singleton_test.rb +39 -38
- data/test/stack_printer_test.rb +61 -61
- data/test/start_stop_test.rb +106 -106
- data/test/test_helper.rb +24 -20
- data/test/thread_test.rb +229 -231
- data/test/unique_call_path_test.rb +123 -136
- data/test/yarv_test.rb +56 -60
- metadata +68 -16
- data/ext/ruby_prof/rp_measure_memory.c +0 -46
- data/lib/ruby-prof/compatibility.rb +0 -113
- data/test/compatibility_test.rb +0 -49
- data/test/crash2.rb +0 -144
- data/test/measure_memory_test.rb +0 -1456
data/test/thread_test.rb
CHANGED
|
@@ -1,231 +1,229 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# encoding: UTF-8
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../test_helper', __FILE__)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
assert(thread)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
assert_in_delta(
|
|
39
|
-
assert_in_delta(
|
|
40
|
-
assert_in_delta(
|
|
41
|
-
assert_in_delta(
|
|
42
|
-
assert_in_delta(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
call_tree
|
|
48
|
-
|
|
49
|
-
assert_in_delta(
|
|
50
|
-
assert_in_delta(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
call_tree
|
|
56
|
-
|
|
57
|
-
assert_in_delta(
|
|
58
|
-
assert_in_delta(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
call_tree
|
|
64
|
-
|
|
65
|
-
assert_in_delta(
|
|
66
|
-
assert_in_delta(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
call_tree
|
|
72
|
-
|
|
73
|
-
assert_in_delta(
|
|
74
|
-
assert_in_delta(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
#
|
|
79
|
-
# call_tree
|
|
80
|
-
#
|
|
81
|
-
# assert_in_delta(
|
|
82
|
-
# assert_in_delta(
|
|
83
|
-
|
|
84
|
-
#
|
|
85
|
-
|
|
86
|
-
# bb
|
|
87
|
-
# call_tree
|
|
88
|
-
#
|
|
89
|
-
# assert_in_delta(
|
|
90
|
-
# assert_in_delta(
|
|
91
|
-
|
|
92
|
-
#
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
call_tree
|
|
96
|
-
|
|
97
|
-
assert_in_delta(0.
|
|
98
|
-
assert_in_delta(0.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
sleep
|
|
144
|
-
#
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
method
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
assert_in_delta(
|
|
162
|
-
assert_in_delta(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
method
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
assert_in_delta(
|
|
171
|
-
assert_in_delta(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
methods =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
#
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
assert_in_delta(
|
|
191
|
-
assert_in_delta(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
method
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
assert_in_delta(1, method.
|
|
202
|
-
assert_in_delta(0, method.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
method
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
assert_in_delta(0, method.
|
|
213
|
-
assert_in_delta(0, method.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
method
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
assert_in_delta(0, method.
|
|
224
|
-
assert_in_delta(0, method.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
end
|
|
231
|
-
end
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
|
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
|
5
|
+
require_relative './call_tree_builder'
|
|
6
|
+
|
|
7
|
+
# -- Tests ----
|
|
8
|
+
class ThreadTest < TestCase
|
|
9
|
+
def test_initialize
|
|
10
|
+
method_info = RubyProf::MethodInfo.new(Array, :size)
|
|
11
|
+
call_tree = RubyProf::CallTree.new(method_info)
|
|
12
|
+
thread = RubyProf::Thread.new(call_tree, Thread.current, Fiber.current)
|
|
13
|
+
|
|
14
|
+
assert_equal(call_tree, thread.call_tree)
|
|
15
|
+
assert(thread)
|
|
16
|
+
assert(thread.id)
|
|
17
|
+
assert(thread.fiber_id)
|
|
18
|
+
|
|
19
|
+
assert_equal(1, thread.methods.size)
|
|
20
|
+
assert_same(method_info, thread.methods[0])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_merge
|
|
24
|
+
call_tree_1 = create_call_tree_1
|
|
25
|
+
thread_1 = RubyProf::Thread.new(call_tree_1, Thread.current, Fiber.current)
|
|
26
|
+
assert_equal(6, thread_1.methods.size)
|
|
27
|
+
|
|
28
|
+
call_tree_2 = create_call_tree_2
|
|
29
|
+
thread_2 = RubyProf::Thread.new(call_tree_2, Thread.current, Fiber.current)
|
|
30
|
+
assert_equal(6, thread_2.methods.size)
|
|
31
|
+
|
|
32
|
+
thread_1.merge!(thread_2)
|
|
33
|
+
assert_equal(7, thread_1.methods.size)
|
|
34
|
+
|
|
35
|
+
# Method times
|
|
36
|
+
assert_in_delta(11.6, thread_1.methods[0].total_time, 0.00001) # root
|
|
37
|
+
assert_in_delta(4.1, thread_1.methods[1].total_time, 0.00001) # a
|
|
38
|
+
assert_in_delta(1.5, thread_1.methods[2].total_time, 0.00001) # aa
|
|
39
|
+
assert_in_delta(2.6, thread_1.methods[3].total_time, 0.00001) # ab
|
|
40
|
+
assert_in_delta(7.5, thread_1.methods[4].total_time, 0.00001) # b
|
|
41
|
+
assert_in_delta(6.6, thread_1.methods[5].total_time, 0.00001) # bb
|
|
42
|
+
assert_in_delta(0.9, thread_1.methods[6].total_time, 0.00001) # ba
|
|
43
|
+
|
|
44
|
+
# Root
|
|
45
|
+
call_tree = call_tree_1
|
|
46
|
+
assert_equal(:root, call_tree.target.method_name)
|
|
47
|
+
assert_in_delta(11.6, call_tree.total_time, 0.00001)
|
|
48
|
+
assert_in_delta(0, call_tree.self_time, 0.00001)
|
|
49
|
+
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
|
50
|
+
assert_in_delta(11.6, call_tree.children_time, 0.00001)
|
|
51
|
+
|
|
52
|
+
# a
|
|
53
|
+
call_tree = call_tree_1.children[0]
|
|
54
|
+
assert_equal(:a, call_tree.target.method_name)
|
|
55
|
+
assert_in_delta(4.1, call_tree.total_time, 0.00001)
|
|
56
|
+
assert_in_delta(0, call_tree.self_time, 0.00001)
|
|
57
|
+
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
|
58
|
+
assert_in_delta(4.1, call_tree.children_time, 0.00001)
|
|
59
|
+
|
|
60
|
+
# aa
|
|
61
|
+
call_tree = call_tree_1.children[0].children[0]
|
|
62
|
+
assert_equal(:aa, call_tree.target.method_name)
|
|
63
|
+
assert_in_delta(1.5, call_tree.total_time, 0.00001)
|
|
64
|
+
assert_in_delta(1.5, call_tree.self_time, 0.00001)
|
|
65
|
+
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
|
66
|
+
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
|
67
|
+
|
|
68
|
+
# ab
|
|
69
|
+
call_tree = call_tree_1.children[0].children[1]
|
|
70
|
+
assert_equal(:ab, call_tree.target.method_name)
|
|
71
|
+
assert_in_delta(2.6, call_tree.total_time, 0.00001)
|
|
72
|
+
assert_in_delta(2.6, call_tree.self_time, 0.00001)
|
|
73
|
+
assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
|
74
|
+
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
|
75
|
+
|
|
76
|
+
# # b
|
|
77
|
+
# call_tree = call_tree_1.children[1]
|
|
78
|
+
# assert_equal(:b, call_tree.target.method_name)
|
|
79
|
+
# assert_in_delta(7.5, call_tree.total_time, 0.00001)
|
|
80
|
+
# assert_in_delta(0, call_tree.self_time, 0.00001)
|
|
81
|
+
# assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
|
82
|
+
# assert_in_delta(7.5, call_tree.children_time, 0.00001)
|
|
83
|
+
|
|
84
|
+
# bb
|
|
85
|
+
# call_tree = call_tree_1.children[1].children[0]
|
|
86
|
+
# assert_equal(:bb, call_tree.target.method_name)
|
|
87
|
+
# assert_in_delta(6.6, call_tree.total_time, 0.00001)
|
|
88
|
+
# assert_in_delta(6.6, call_tree.self_time, 0.00001)
|
|
89
|
+
# assert_in_delta(0.0, call_tree.wait_time, 0.00001)
|
|
90
|
+
# assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
|
91
|
+
|
|
92
|
+
# ba
|
|
93
|
+
call_tree = call_tree_1.children[1].children[1]
|
|
94
|
+
assert_equal(:ba, call_tree.target.method_name)
|
|
95
|
+
assert_in_delta(0.9, call_tree.total_time, 0.00001)
|
|
96
|
+
assert_in_delta(0.7, call_tree.self_time, 0.00001)
|
|
97
|
+
assert_in_delta(0.2, call_tree.wait_time, 0.00001)
|
|
98
|
+
assert_in_delta(0.0, call_tree.children_time, 0.00001)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_thread_count
|
|
102
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) do
|
|
103
|
+
thread = Thread.new do
|
|
104
|
+
sleep(1)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
thread.join
|
|
108
|
+
end
|
|
109
|
+
assert_equal(2, result.threads.length)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def test_thread_identity
|
|
113
|
+
profile = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
|
|
114
|
+
profile.start
|
|
115
|
+
|
|
116
|
+
sleep_thread = Thread.new do
|
|
117
|
+
sleep(1)
|
|
118
|
+
end
|
|
119
|
+
sleep_thread.join
|
|
120
|
+
result = profile.stop
|
|
121
|
+
|
|
122
|
+
thread_ids = result.threads.map {|thread| thread.id}.sort
|
|
123
|
+
threads = [Thread.current, sleep_thread]
|
|
124
|
+
assert_equal(2, result.threads.length)
|
|
125
|
+
|
|
126
|
+
assert(thread_ids.include?(threads[0].object_id))
|
|
127
|
+
assert(thread_ids.include?(threads[1].object_id))
|
|
128
|
+
|
|
129
|
+
thread_ids.each do |id|
|
|
130
|
+
thread = threads.find { |t| t.object_id == id }
|
|
131
|
+
refute_nil(thread)
|
|
132
|
+
assert_instance_of(Thread, thread)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_thread_timings
|
|
137
|
+
profile = RubyProf::Profile.new(measure_mode: RubyProf::WALL_TIME)
|
|
138
|
+
profile.start
|
|
139
|
+
|
|
140
|
+
thread = Thread.new do
|
|
141
|
+
sleep 0
|
|
142
|
+
# force it to hit thread.join, below, first
|
|
143
|
+
# thus forcing sleep(1), below, to be counted as (wall) self_time
|
|
144
|
+
# since we currently count time "in some other thread" as self.wait_time
|
|
145
|
+
sleep(1)
|
|
146
|
+
end
|
|
147
|
+
thread.join
|
|
148
|
+
result = profile.stop
|
|
149
|
+
|
|
150
|
+
# Check background thread
|
|
151
|
+
assert_equal(2, result.threads.length)
|
|
152
|
+
|
|
153
|
+
rp_thread = result.threads.detect {|t| t.id == thread.object_id}
|
|
154
|
+
methods = rp_thread.methods.sort.reverse
|
|
155
|
+
|
|
156
|
+
method = methods[0]
|
|
157
|
+
assert_equal('ThreadTest#test_thread_timings', method.full_name)
|
|
158
|
+
assert_equal(1, method.called)
|
|
159
|
+
assert_in_delta(1, method.total_time, 0.1 * delta_multiplier)
|
|
160
|
+
assert_in_delta(0, method.self_time, 0.05 * delta_multiplier)
|
|
161
|
+
assert_in_delta(0, method.wait_time, 0.05 * delta_multiplier)
|
|
162
|
+
assert_in_delta(1, method.children_time, 0.1 * delta_multiplier)
|
|
163
|
+
assert_equal(0, method.call_trees.callers.length)
|
|
164
|
+
|
|
165
|
+
method = methods[1]
|
|
166
|
+
assert_equal('Kernel#sleep', method.full_name)
|
|
167
|
+
assert_equal(2, method.called)
|
|
168
|
+
assert_in_delta(1, method.total_time, 0.05 * delta_multiplier)
|
|
169
|
+
assert_in_delta(1.0, method.self_time, 0.05 * delta_multiplier)
|
|
170
|
+
assert_in_delta(0, method.wait_time, 0.05 * delta_multiplier)
|
|
171
|
+
assert_in_delta(0, method.children_time, 0.05 * delta_multiplier)
|
|
172
|
+
|
|
173
|
+
assert_equal(1, method.call_trees.callers.length)
|
|
174
|
+
assert_equal(0, method.call_trees.callees.length)
|
|
175
|
+
|
|
176
|
+
# Check foreground thread
|
|
177
|
+
rp_thread = result.threads.detect {|athread| athread.id == Thread.current.object_id}
|
|
178
|
+
methods = rp_thread.methods.sort.reverse
|
|
179
|
+
assert_equal(4, methods.length)
|
|
180
|
+
methods = methods.sort.reverse
|
|
181
|
+
|
|
182
|
+
method = methods[0]
|
|
183
|
+
assert_equal('ThreadTest#test_thread_timings', method.full_name)
|
|
184
|
+
# the sub calls to Object#new, when popped,
|
|
185
|
+
# cause the parent frame to be created for method #test_thread_timings, which means a +1 when it's popped in the end
|
|
186
|
+
# xxxx a test that shows it the other way, too (never creates parent frame--if that's even possible)
|
|
187
|
+
assert_equal(1, method.called)
|
|
188
|
+
assert_in_delta(1, method.total_time, 0.05 * delta_multiplier)
|
|
189
|
+
assert_in_delta(0, method.self_time, 0.05 * delta_multiplier)
|
|
190
|
+
assert_in_delta(0, method.wait_time, 0.05 * delta_multiplier)
|
|
191
|
+
assert_in_delta(1, method.children_time, 0.05 * delta_multiplier)
|
|
192
|
+
|
|
193
|
+
assert_equal(0, method.call_trees.callers.length)
|
|
194
|
+
assert_equal(2, method.call_trees.callees.length)
|
|
195
|
+
|
|
196
|
+
method = methods[1]
|
|
197
|
+
assert_equal('Thread#join', method.full_name)
|
|
198
|
+
assert_equal(1, method.called)
|
|
199
|
+
assert_in_delta(1, method.total_time, 0.05 * delta_multiplier)
|
|
200
|
+
assert_in_delta(0, method.self_time, 0.05 * delta_multiplier)
|
|
201
|
+
assert_in_delta(1.0, method.wait_time, 0.05 * delta_multiplier)
|
|
202
|
+
assert_in_delta(0, method.children_time, 0.05 * delta_multiplier)
|
|
203
|
+
|
|
204
|
+
assert_equal(1, method.call_trees.callers.length)
|
|
205
|
+
assert_equal(0, method.call_trees.callees.length)
|
|
206
|
+
|
|
207
|
+
method = methods[2]
|
|
208
|
+
assert_equal('<Class::Thread>#new', method.full_name)
|
|
209
|
+
assert_equal(1, method.called)
|
|
210
|
+
assert_in_delta(0, method.total_time, 0.05 * delta_multiplier)
|
|
211
|
+
assert_in_delta(0, method.self_time, 0.05 * delta_multiplier)
|
|
212
|
+
assert_in_delta(0, method.wait_time, 0.05 * delta_multiplier)
|
|
213
|
+
assert_in_delta(0, method.children_time, 0.05 * delta_multiplier)
|
|
214
|
+
|
|
215
|
+
assert_equal(1, method.call_trees.callers.length)
|
|
216
|
+
assert_equal(1, method.call_trees.callees.length)
|
|
217
|
+
|
|
218
|
+
method = methods[3]
|
|
219
|
+
assert_equal('Thread#initialize', method.full_name)
|
|
220
|
+
assert_equal(1, method.called)
|
|
221
|
+
assert_in_delta(0, method.total_time, 0.05 * delta_multiplier)
|
|
222
|
+
assert_in_delta(0, method.self_time, 0.05 * delta_multiplier)
|
|
223
|
+
assert_in_delta(0, method.wait_time, 0.05 * delta_multiplier)
|
|
224
|
+
assert_in_delta(0, method.children_time, 0.05 * delta_multiplier)
|
|
225
|
+
|
|
226
|
+
assert_equal(1, method.call_trees.callers.length)
|
|
227
|
+
assert_equal(0, method.call_trees.callees.length)
|
|
228
|
+
end
|
|
229
|
+
end
|