ruby-prof 1.4.4-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +608 -0
- data/LICENSE +25 -0
- data/README.md +5 -0
- data/Rakefile +98 -0
- data/bin/ruby-prof +328 -0
- data/bin/ruby-prof-check-trace +45 -0
- data/ext/ruby_prof/extconf.rb +22 -0
- data/ext/ruby_prof/rp_aggregate_call_tree.c +59 -0
- data/ext/ruby_prof/rp_aggregate_call_tree.h +13 -0
- data/ext/ruby_prof/rp_allocation.c +287 -0
- data/ext/ruby_prof/rp_allocation.h +31 -0
- data/ext/ruby_prof/rp_call_tree.c +367 -0
- data/ext/ruby_prof/rp_call_tree.h +43 -0
- data/ext/ruby_prof/rp_call_trees.c +288 -0
- data/ext/ruby_prof/rp_call_trees.h +28 -0
- data/ext/ruby_prof/rp_measure_allocations.c +47 -0
- data/ext/ruby_prof/rp_measure_memory.c +46 -0
- data/ext/ruby_prof/rp_measure_process_time.c +66 -0
- data/ext/ruby_prof/rp_measure_wall_time.c +64 -0
- data/ext/ruby_prof/rp_measurement.c +237 -0
- data/ext/ruby_prof/rp_measurement.h +50 -0
- data/ext/ruby_prof/rp_method.c +491 -0
- data/ext/ruby_prof/rp_method.h +62 -0
- data/ext/ruby_prof/rp_profile.c +915 -0
- data/ext/ruby_prof/rp_profile.h +35 -0
- data/ext/ruby_prof/rp_stack.c +212 -0
- data/ext/ruby_prof/rp_stack.h +53 -0
- data/ext/ruby_prof/rp_thread.c +362 -0
- data/ext/ruby_prof/rp_thread.h +39 -0
- data/ext/ruby_prof/ruby_prof.c +52 -0
- data/ext/ruby_prof/ruby_prof.h +26 -0
- data/ext/ruby_prof/vc/ruby_prof.sln +39 -0
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +160 -0
- data/lib/3.1/ruby_prof.so +0 -0
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +711 -0
- data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
- data/lib/ruby-prof/assets/graph_printer.html.erb +355 -0
- data/lib/ruby-prof/call_tree.rb +57 -0
- data/lib/ruby-prof/call_tree_visitor.rb +36 -0
- data/lib/ruby-prof/compatibility.rb +99 -0
- data/lib/ruby-prof/exclude_common_methods.rb +198 -0
- data/lib/ruby-prof/measurement.rb +17 -0
- data/lib/ruby-prof/method_info.rb +78 -0
- data/lib/ruby-prof/printers/abstract_printer.rb +137 -0
- data/lib/ruby-prof/printers/call_info_printer.rb +53 -0
- data/lib/ruby-prof/printers/call_stack_printer.rb +180 -0
- data/lib/ruby-prof/printers/call_tree_printer.rb +147 -0
- data/lib/ruby-prof/printers/dot_printer.rb +132 -0
- data/lib/ruby-prof/printers/flat_printer.rb +53 -0
- data/lib/ruby-prof/printers/graph_html_printer.rb +63 -0
- data/lib/ruby-prof/printers/graph_printer.rb +113 -0
- data/lib/ruby-prof/printers/multi_printer.rb +127 -0
- data/lib/ruby-prof/profile.rb +37 -0
- data/lib/ruby-prof/rack.rb +95 -0
- data/lib/ruby-prof/task.rb +147 -0
- data/lib/ruby-prof/thread.rb +20 -0
- data/lib/ruby-prof/version.rb +3 -0
- data/lib/ruby-prof.rb +52 -0
- data/lib/unprof.rb +10 -0
- data/ruby-prof.gemspec +64 -0
- data/test/abstract_printer_test.rb +26 -0
- data/test/alias_test.rb +122 -0
- data/test/basic_test.rb +43 -0
- data/test/call_tree_visitor_test.rb +32 -0
- data/test/call_trees_test.rb +66 -0
- data/test/duplicate_names_test.rb +32 -0
- data/test/dynamic_method_test.rb +67 -0
- data/test/enumerable_test.rb +21 -0
- data/test/exceptions_test.rb +24 -0
- data/test/exclude_methods_test.rb +151 -0
- data/test/exclude_threads_test.rb +53 -0
- data/test/fiber_test.rb +129 -0
- data/test/gc_test.rb +100 -0
- data/test/inverse_call_tree_test.rb +175 -0
- data/test/line_number_test.rb +158 -0
- data/test/marshal_test.rb +145 -0
- data/test/measure_allocations.rb +26 -0
- data/test/measure_allocations_test.rb +333 -0
- data/test/measure_memory_test.rb +688 -0
- data/test/measure_process_time_test.rb +1614 -0
- data/test/measure_times.rb +56 -0
- data/test/measure_wall_time_test.rb +426 -0
- data/test/multi_printer_test.rb +71 -0
- data/test/no_method_class_test.rb +15 -0
- data/test/pause_resume_test.rb +175 -0
- data/test/prime.rb +54 -0
- data/test/prime_script.rb +6 -0
- data/test/printer_call_stack_test.rb +27 -0
- data/test/printer_call_tree_test.rb +30 -0
- data/test/printer_flat_test.rb +99 -0
- data/test/printer_graph_html_test.rb +59 -0
- data/test/printer_graph_test.rb +40 -0
- data/test/printers_test.rb +141 -0
- data/test/printing_recursive_graph_test.rb +81 -0
- data/test/profile_test.rb +16 -0
- data/test/rack_test.rb +93 -0
- data/test/recursive_test.rb +430 -0
- data/test/singleton_test.rb +38 -0
- data/test/stack_printer_test.rb +64 -0
- data/test/start_stop_test.rb +109 -0
- data/test/test_helper.rb +13 -0
- data/test/thread_test.rb +144 -0
- data/test/unique_call_path_test.rb +136 -0
- data/test/yarv_test.rb +60 -0
- metadata +187 -0
@@ -0,0 +1,688 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
5
|
+
require_relative './measure_allocations'
|
6
|
+
|
7
|
+
class MeasureMemoryTest < TestCase
|
8
|
+
def setup
|
9
|
+
RubyProf::measure_mode = RubyProf::MEMORY
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_memory_mode
|
13
|
+
RubyProf::measure_mode = RubyProf::MEMORY
|
14
|
+
assert_equal(RubyProf::MEMORY, RubyProf::measure_mode)
|
15
|
+
end
|
16
|
+
|
17
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0')
|
18
|
+
def test_memory
|
19
|
+
result = RubyProf.profile do
|
20
|
+
allocator = Allocator.new
|
21
|
+
allocator.run
|
22
|
+
end
|
23
|
+
|
24
|
+
thread = result.threads.first
|
25
|
+
|
26
|
+
assert_in_delta(800, thread.total_time, 1)
|
27
|
+
methods = result.threads.first.methods.sort.reverse
|
28
|
+
assert_equal(12, methods.length)
|
29
|
+
|
30
|
+
# Method 0
|
31
|
+
method = methods[0]
|
32
|
+
assert_equal('MeasureMemoryTest#test_memory', method.full_name)
|
33
|
+
assert_in_delta(800, method.total_time, 1)
|
34
|
+
|
35
|
+
assert_equal(0.0, method.wait_time)
|
36
|
+
assert_equal(0.0, method.self_time)
|
37
|
+
assert_in_delta(800, method.children_time, 1)
|
38
|
+
assert_equal(0, method.call_trees.callers.length)
|
39
|
+
|
40
|
+
assert_equal(2, method.call_trees.callees.length)
|
41
|
+
call_tree = method.call_trees.callees[0]
|
42
|
+
assert_equal('Class#new', call_tree.target.full_name)
|
43
|
+
assert_equal(40.0, call_tree.total_time)
|
44
|
+
assert_equal(0.0, call_tree.wait_time)
|
45
|
+
assert_equal(40.0, call_tree.self_time)
|
46
|
+
assert_equal(0.0, call_tree.children_time)
|
47
|
+
|
48
|
+
call_tree = method.call_trees.callees[1]
|
49
|
+
assert_equal('Allocator#run', call_tree.target.full_name)
|
50
|
+
assert_equal(760.0, call_tree.total_time)
|
51
|
+
assert_equal(0.0, call_tree.wait_time)
|
52
|
+
assert_equal(0.0, call_tree.self_time)
|
53
|
+
assert_equal(760.0, call_tree.children_time)
|
54
|
+
|
55
|
+
# Method 1
|
56
|
+
method = methods[1]
|
57
|
+
assert_equal('Allocator#run',method.full_name)
|
58
|
+
assert_equal(760.0, method.total_time)
|
59
|
+
assert_equal(0.0, method.wait_time)
|
60
|
+
assert_equal(0.0, method.self_time)
|
61
|
+
assert_equal(760.0, method.children_time)
|
62
|
+
|
63
|
+
assert_equal(1, method.call_trees.callers.length)
|
64
|
+
call_tree = method.call_trees.callers[0]
|
65
|
+
assert_equal('MeasureMemoryTest#test_memory', call_tree.parent.target.full_name)
|
66
|
+
assert_equal(760.0, call_tree.total_time)
|
67
|
+
assert_equal(0.0, call_tree.wait_time)
|
68
|
+
assert_equal(0.0, call_tree.self_time)
|
69
|
+
assert_equal(760.0, call_tree.children_time)
|
70
|
+
|
71
|
+
assert_equal(3, method.call_trees.callees.length)
|
72
|
+
call_tree = method.call_trees.callees[0]
|
73
|
+
assert_equal('Allocator#make_arrays', call_tree.target.full_name)
|
74
|
+
assert_equal(400.0, call_tree.total_time)
|
75
|
+
assert_equal(0.0, call_tree.wait_time)
|
76
|
+
assert_equal(0.0, call_tree.self_time)
|
77
|
+
assert_equal(400.0, call_tree.children_time)
|
78
|
+
|
79
|
+
call_tree = method.call_trees.callees[1]
|
80
|
+
assert_equal('Allocator#make_hashes', call_tree.target.full_name)
|
81
|
+
assert_equal(200.0, call_tree.total_time)
|
82
|
+
assert_equal(0.0, call_tree.wait_time)
|
83
|
+
assert_equal(0.0, call_tree.self_time)
|
84
|
+
assert_equal(200.0, call_tree.children_time)
|
85
|
+
|
86
|
+
call_tree = method.call_trees.callees[2]
|
87
|
+
assert_equal('Allocator#make_strings', call_tree.target.full_name)
|
88
|
+
assert_equal(160.0, call_tree.total_time)
|
89
|
+
assert_equal(0.0, call_tree.wait_time)
|
90
|
+
assert_equal(40, call_tree.self_time)
|
91
|
+
assert_equal(120.0, call_tree.children_time)
|
92
|
+
|
93
|
+
# Method 2
|
94
|
+
method = methods[2]
|
95
|
+
assert_equal('Class#new', method.full_name)
|
96
|
+
assert_equal(720.0, method.total_time)
|
97
|
+
assert_equal(0.0, method.wait_time)
|
98
|
+
assert_equal(680.0, method.self_time)
|
99
|
+
assert_equal(40.0, method.children_time)
|
100
|
+
|
101
|
+
assert_equal(4, method.call_trees.callers.length)
|
102
|
+
call_tree = method.call_trees.callers[0]
|
103
|
+
assert_equal('MeasureMemoryTest#test_memory', call_tree.parent.target.full_name)
|
104
|
+
assert_equal(40.0, call_tree.total_time)
|
105
|
+
assert_equal(0.0, call_tree.wait_time)
|
106
|
+
assert_equal(40.0, call_tree.self_time)
|
107
|
+
assert_equal(0.0, call_tree.children_time)
|
108
|
+
|
109
|
+
call_tree = method.call_trees.callers[1]
|
110
|
+
assert_equal('Integer#times', call_tree.parent.target.full_name)
|
111
|
+
assert_equal(400.0, call_tree.total_time)
|
112
|
+
assert_equal(0.0, call_tree.wait_time)
|
113
|
+
assert_equal(400.0, call_tree.self_time)
|
114
|
+
assert_equal(0.0, call_tree.children_time)
|
115
|
+
|
116
|
+
call_tree = method.call_trees.callers[2]
|
117
|
+
assert_equal('Allocator#make_hashes', call_tree.parent.target.full_name)
|
118
|
+
assert_equal(200.0, call_tree.total_time)
|
119
|
+
assert_equal(0.0, call_tree.wait_time)
|
120
|
+
assert_equal(200.0, call_tree.self_time)
|
121
|
+
assert_equal(0.0, call_tree.children_time)
|
122
|
+
|
123
|
+
call_tree = method.call_trees.callers[3]
|
124
|
+
assert_equal('Allocator#make_strings', call_tree.parent.target.full_name)
|
125
|
+
assert_equal(80.0, call_tree.total_time)
|
126
|
+
assert_equal(0.0, call_tree.wait_time)
|
127
|
+
assert_equal(40.0, call_tree.self_time)
|
128
|
+
assert_equal(40.0, call_tree.children_time)
|
129
|
+
|
130
|
+
assert_equal(4, method.call_trees.callees.length)
|
131
|
+
call_tree = method.call_trees.callees[0]
|
132
|
+
assert_equal('BasicObject#initialize', call_tree.target.full_name)
|
133
|
+
assert_equal(0.0, call_tree.total_time)
|
134
|
+
assert_equal(0.0, call_tree.wait_time)
|
135
|
+
assert_equal(0.0, call_tree.self_time)
|
136
|
+
assert_equal(0.0, call_tree.children_time)
|
137
|
+
|
138
|
+
call_tree = method.call_trees.callees[1]
|
139
|
+
assert_equal('Array#initialize', call_tree.target.full_name)
|
140
|
+
assert_equal(0.0, call_tree.total_time)
|
141
|
+
assert_equal(0.0, call_tree.wait_time)
|
142
|
+
assert_equal(0.0, call_tree.self_time)
|
143
|
+
assert_equal(0.0, call_tree.children_time)
|
144
|
+
|
145
|
+
call_tree = method.call_trees.callees[2]
|
146
|
+
assert_equal('Hash#initialize', call_tree.target.full_name)
|
147
|
+
assert_equal(0.0, call_tree.total_time)
|
148
|
+
assert_equal(0.0, call_tree.wait_time)
|
149
|
+
assert_equal(0.0, call_tree.self_time)
|
150
|
+
assert_equal(0.0, call_tree.children_time)
|
151
|
+
|
152
|
+
call_tree = method.call_trees.callees[3]
|
153
|
+
assert_equal('String#initialize', call_tree.target.full_name)
|
154
|
+
assert_equal(40.0, call_tree.total_time)
|
155
|
+
assert_equal(0.0, call_tree.wait_time)
|
156
|
+
assert_equal(40.0, call_tree.self_time)
|
157
|
+
assert_equal(0.0, call_tree.children_time)
|
158
|
+
|
159
|
+
# Method 3
|
160
|
+
method = methods[3]
|
161
|
+
assert_equal('Allocator#make_arrays', method.full_name)
|
162
|
+
assert_equal(400.0, method.total_time)
|
163
|
+
assert_equal(0.0, method.wait_time)
|
164
|
+
assert_equal(0.0, method.self_time)
|
165
|
+
assert_equal(400.0, method.children_time)
|
166
|
+
|
167
|
+
assert_equal(1, method.call_trees.callers.length)
|
168
|
+
call_tree = method.call_trees.callers[0]
|
169
|
+
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
170
|
+
assert_equal(400.0, call_tree.total_time)
|
171
|
+
assert_equal(0.0, call_tree.wait_time)
|
172
|
+
assert_equal(0.0, call_tree.self_time)
|
173
|
+
assert_equal(400.0, call_tree.children_time)
|
174
|
+
|
175
|
+
assert_equal(1, method.call_trees.callees.length)
|
176
|
+
call_tree = method.call_trees.callees[0]
|
177
|
+
assert_equal('Integer#times', call_tree.target.full_name)
|
178
|
+
assert_equal(400.0, call_tree.total_time)
|
179
|
+
assert_equal(0.0, call_tree.wait_time)
|
180
|
+
assert_equal(0.0, call_tree.self_time)
|
181
|
+
assert_equal(400.0, call_tree.children_time)
|
182
|
+
|
183
|
+
# Method 4
|
184
|
+
method = methods[4]
|
185
|
+
assert_equal('Integer#times', method.full_name)
|
186
|
+
assert_equal(400.0, method.total_time)
|
187
|
+
assert_equal(0.0, method.wait_time)
|
188
|
+
assert_equal(0.0, method.self_time)
|
189
|
+
assert_equal(400.0, method.children_time)
|
190
|
+
|
191
|
+
assert_equal(1, method.call_trees.callers.length)
|
192
|
+
call_tree = method.call_trees.callers[0]
|
193
|
+
assert_equal('Allocator#make_arrays', call_tree.parent.target.full_name)
|
194
|
+
assert_equal(400.0, call_tree.total_time)
|
195
|
+
assert_equal(0.0, call_tree.wait_time)
|
196
|
+
assert_equal(0.0, call_tree.self_time)
|
197
|
+
assert_equal(400.0, call_tree.children_time)
|
198
|
+
|
199
|
+
assert_equal(1, method.call_trees.callees.length)
|
200
|
+
call_tree = method.call_trees.callees[0]
|
201
|
+
assert_equal('Class#new', call_tree.target.full_name)
|
202
|
+
assert_equal(400.0, call_tree.total_time)
|
203
|
+
assert_equal(0.0, call_tree.wait_time)
|
204
|
+
assert_equal(400.0, call_tree.self_time)
|
205
|
+
assert_equal(0.0, call_tree.children_time)
|
206
|
+
|
207
|
+
# Method 5
|
208
|
+
method = methods[5]
|
209
|
+
assert_equal('Allocator#make_hashes', method.full_name)
|
210
|
+
assert_equal(200.0, method.total_time)
|
211
|
+
assert_equal(0.0, method.wait_time)
|
212
|
+
assert_equal(0.0, method.self_time)
|
213
|
+
assert_equal(200.0, method.children_time)
|
214
|
+
|
215
|
+
assert_equal(1, method.call_trees.callers.length)
|
216
|
+
call_tree = method.call_trees.callers[0]
|
217
|
+
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
218
|
+
assert_equal(200.0, call_tree.total_time)
|
219
|
+
assert_equal(0.0, call_tree.wait_time)
|
220
|
+
assert_equal(0.0, call_tree.self_time)
|
221
|
+
assert_equal(200.0, call_tree.children_time)
|
222
|
+
|
223
|
+
assert_equal(1, method.call_trees.callees.length)
|
224
|
+
call_tree = method.call_trees.callees[0]
|
225
|
+
assert_equal('Class#new', call_tree.target.full_name)
|
226
|
+
assert_equal(200.0, call_tree.total_time)
|
227
|
+
assert_equal(0.0, call_tree.wait_time)
|
228
|
+
assert_equal(200.0, call_tree.self_time)
|
229
|
+
assert_equal(0.0, call_tree.children_time)
|
230
|
+
|
231
|
+
# Method 6
|
232
|
+
method = methods[6]
|
233
|
+
assert_equal('Allocator#make_strings', method.full_name)
|
234
|
+
assert_equal(160.0, method.total_time)
|
235
|
+
assert_equal(0.0, method.wait_time)
|
236
|
+
assert_equal(40.0, method.self_time)
|
237
|
+
assert_equal(120.0, method.children_time)
|
238
|
+
|
239
|
+
assert_equal(1, method.call_trees.callers.length)
|
240
|
+
call_tree = method.call_trees.callers[0]
|
241
|
+
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
242
|
+
assert_equal(160.0, call_tree.total_time)
|
243
|
+
assert_equal(0.0, call_tree.wait_time)
|
244
|
+
assert_equal(40.0, call_tree.self_time)
|
245
|
+
assert_equal(120.0, call_tree.children_time)
|
246
|
+
|
247
|
+
assert_equal(2, method.call_trees.callees.length)
|
248
|
+
call_tree = method.call_trees.callees[0]
|
249
|
+
assert_equal('String#*', call_tree.target.full_name)
|
250
|
+
assert_equal(40.0, call_tree.total_time)
|
251
|
+
assert_equal(0.0, call_tree.wait_time)
|
252
|
+
assert_equal(40.0, call_tree.self_time)
|
253
|
+
assert_equal(0.0, call_tree.children_time)
|
254
|
+
|
255
|
+
call_tree = method.call_trees.callees[1]
|
256
|
+
assert_equal('Class#new', call_tree.target.full_name)
|
257
|
+
assert_equal(80.0, call_tree.total_time)
|
258
|
+
assert_equal(0.0, call_tree.wait_time)
|
259
|
+
assert_equal(40.0, call_tree.self_time)
|
260
|
+
assert_equal(40.0, call_tree.children_time)
|
261
|
+
|
262
|
+
# Method 7
|
263
|
+
method = methods[7]
|
264
|
+
assert_equal('String#*', method.full_name)
|
265
|
+
assert_equal(40.0, method.total_time)
|
266
|
+
assert_equal(0.0, method.wait_time)
|
267
|
+
assert_equal(40.0, method.self_time)
|
268
|
+
assert_equal(0.0, method.children_time)
|
269
|
+
|
270
|
+
assert_equal(1, method.call_trees.callers.length)
|
271
|
+
call_tree = method.call_trees.callers[0]
|
272
|
+
assert_equal('Allocator#make_strings', call_tree.parent.target.full_name)
|
273
|
+
assert_equal(40.0, call_tree.total_time)
|
274
|
+
assert_equal(0.0, call_tree.wait_time)
|
275
|
+
assert_equal(40.0, call_tree.self_time)
|
276
|
+
assert_equal(0.0, call_tree.children_time)
|
277
|
+
|
278
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
279
|
+
|
280
|
+
# Method 8
|
281
|
+
method = methods[8]
|
282
|
+
assert_equal('String#initialize', method.full_name)
|
283
|
+
assert_equal(40.0, method.total_time)
|
284
|
+
assert_equal(0.0, method.wait_time)
|
285
|
+
assert_equal(40.0, method.self_time)
|
286
|
+
assert_equal(0.0, method.children_time)
|
287
|
+
|
288
|
+
assert_equal(1, method.call_trees.callers.length)
|
289
|
+
call_tree = method.call_trees.callers[0]
|
290
|
+
assert_equal('Class#new', call_tree.parent.target.full_name)
|
291
|
+
assert_equal(40.0, call_tree.total_time)
|
292
|
+
assert_equal(0.0, call_tree.wait_time)
|
293
|
+
assert_equal(40.0, call_tree.self_time)
|
294
|
+
assert_equal(0.0, call_tree.children_time)
|
295
|
+
|
296
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
297
|
+
|
298
|
+
# Method 9
|
299
|
+
method = methods[9]
|
300
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
301
|
+
assert_equal(0.0, method.total_time)
|
302
|
+
assert_equal(0.0, method.wait_time)
|
303
|
+
assert_equal(0.0, method.self_time)
|
304
|
+
assert_equal(0.0, method.children_time)
|
305
|
+
|
306
|
+
assert_equal(1, method.call_trees.callers.length)
|
307
|
+
call_tree = method.call_trees.callers[0]
|
308
|
+
assert_equal('Class#new', call_tree.parent.target.full_name)
|
309
|
+
assert_equal(0.0, call_tree.total_time)
|
310
|
+
assert_equal(0.0, call_tree.wait_time)
|
311
|
+
assert_equal(0.0, call_tree.self_time)
|
312
|
+
assert_equal(0.0, call_tree.children_time)
|
313
|
+
|
314
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
315
|
+
|
316
|
+
# Method 10
|
317
|
+
method = methods[10]
|
318
|
+
assert_equal('Hash#initialize', method.full_name)
|
319
|
+
assert_equal(0.0, method.total_time)
|
320
|
+
assert_equal(0.0, method.wait_time)
|
321
|
+
assert_equal(0.0, method.self_time)
|
322
|
+
assert_equal(0.0, method.children_time)
|
323
|
+
|
324
|
+
assert_equal(1, method.call_trees.callers.length)
|
325
|
+
call_tree = method.call_trees.callers[0]
|
326
|
+
assert_equal('Class#new', call_tree.parent.target.full_name)
|
327
|
+
assert_equal(0.0, call_tree.total_time)
|
328
|
+
assert_equal(0.0, call_tree.wait_time)
|
329
|
+
assert_equal(0.0, call_tree.self_time)
|
330
|
+
assert_equal(0.0, call_tree.children_time)
|
331
|
+
|
332
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
333
|
+
|
334
|
+
# Method 11
|
335
|
+
method = methods[11]
|
336
|
+
assert_equal('Array#initialize', method.full_name)
|
337
|
+
assert_equal(0.0, method.total_time)
|
338
|
+
assert_equal(0.0, method.wait_time)
|
339
|
+
assert_equal(0.0, method.self_time)
|
340
|
+
assert_equal(0.0, method.children_time)
|
341
|
+
|
342
|
+
assert_equal(1, method.call_trees.callers.length)
|
343
|
+
call_tree = method.call_trees.callers[0]
|
344
|
+
assert_equal('Class#new', call_tree.parent.target.full_name)
|
345
|
+
assert_equal(0.0, call_tree.total_time)
|
346
|
+
assert_equal(0.0, call_tree.wait_time)
|
347
|
+
assert_equal(0.0, call_tree.self_time)
|
348
|
+
assert_equal(0.0, call_tree.children_time)
|
349
|
+
|
350
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
351
|
+
end
|
352
|
+
else
|
353
|
+
def test_memory
|
354
|
+
result = RubyProf.profile do
|
355
|
+
allocator = Allocator.new
|
356
|
+
allocator.run
|
357
|
+
end
|
358
|
+
|
359
|
+
thread = result.threads.first
|
360
|
+
|
361
|
+
assert_in_delta(800, thread.total_time, 1)
|
362
|
+
methods = result.threads.first.methods.sort.reverse
|
363
|
+
assert_equal(12, methods.length)
|
364
|
+
|
365
|
+
# Method 0
|
366
|
+
method = methods[0]
|
367
|
+
assert_equal('MeasureMemoryTest#test_memory', method.full_name)
|
368
|
+
assert_in_delta(800, method.total_time, 1)
|
369
|
+
|
370
|
+
assert_equal(0.0, method.wait_time)
|
371
|
+
assert_equal(0.0, method.self_time)
|
372
|
+
assert_in_delta(800, method.children_time, 1)
|
373
|
+
assert_equal(0, method.call_trees.callers.length)
|
374
|
+
|
375
|
+
assert_equal(2, method.call_trees.callees.length)
|
376
|
+
call_tree = method.call_trees.callees[0]
|
377
|
+
assert_equal('Class#new', call_tree.target.full_name)
|
378
|
+
assert_equal(40.0, call_tree.total_time)
|
379
|
+
assert_equal(0.0, call_tree.wait_time)
|
380
|
+
assert_equal(40.0, call_tree.self_time)
|
381
|
+
assert_equal(0.0, call_tree.children_time)
|
382
|
+
|
383
|
+
call_tree = method.call_trees.callees[1]
|
384
|
+
assert_equal('Allocator#run', call_tree.target.full_name)
|
385
|
+
assert_equal(760.0, call_tree.total_time)
|
386
|
+
assert_equal(0.0, call_tree.wait_time)
|
387
|
+
assert_equal(0.0, call_tree.self_time)
|
388
|
+
assert_equal(760.0, call_tree.children_time)
|
389
|
+
|
390
|
+
# Method 1
|
391
|
+
method = methods[1]
|
392
|
+
assert_equal('Allocator#run',method.full_name)
|
393
|
+
assert_equal(760.0, method.total_time)
|
394
|
+
assert_equal(0.0, method.wait_time)
|
395
|
+
assert_equal(0.0, method.self_time)
|
396
|
+
assert_equal(760.0, method.children_time)
|
397
|
+
|
398
|
+
assert_equal(1, method.call_trees.callers.length)
|
399
|
+
call_tree = method.call_trees.callers[0]
|
400
|
+
assert_equal('MeasureMemoryTest#test_memory', call_tree.parent.target.full_name)
|
401
|
+
assert_equal(760.0, call_tree.total_time)
|
402
|
+
assert_equal(0.0, call_tree.wait_time)
|
403
|
+
assert_equal(0.0, call_tree.self_time)
|
404
|
+
assert_equal(760.0, call_tree.children_time)
|
405
|
+
|
406
|
+
assert_equal(3, method.call_trees.callees.length)
|
407
|
+
call_tree = method.call_trees.callees[0]
|
408
|
+
assert_equal('Allocator#make_arrays', call_tree.target.full_name)
|
409
|
+
assert_equal(400.0, call_tree.total_time)
|
410
|
+
assert_equal(0.0, call_tree.wait_time)
|
411
|
+
assert_equal(0.0, call_tree.self_time)
|
412
|
+
assert_equal(400.0, call_tree.children_time)
|
413
|
+
|
414
|
+
call_tree = method.call_trees.callees[1]
|
415
|
+
assert_equal('Allocator#make_hashes', call_tree.target.full_name)
|
416
|
+
assert_equal(200.0, call_tree.total_time)
|
417
|
+
assert_equal(0.0, call_tree.wait_time)
|
418
|
+
assert_equal(0.0, call_tree.self_time)
|
419
|
+
assert_equal(200.0, call_tree.children_time)
|
420
|
+
|
421
|
+
call_tree = method.call_trees.callees[2]
|
422
|
+
assert_equal('Allocator#make_strings', call_tree.target.full_name)
|
423
|
+
assert_equal(160.0, call_tree.total_time)
|
424
|
+
assert_equal(0.0, call_tree.wait_time)
|
425
|
+
assert_equal(40.0, call_tree.self_time)
|
426
|
+
assert_equal(120.0, call_tree.children_time)
|
427
|
+
|
428
|
+
# Method 2
|
429
|
+
method = methods[2]
|
430
|
+
assert_equal('Class#new', method.full_name)
|
431
|
+
assert_equal(720.0, method.total_time)
|
432
|
+
assert_equal(0.0, method.wait_time)
|
433
|
+
assert_equal(680.0, method.self_time)
|
434
|
+
assert_equal(40.0, method.children_time)
|
435
|
+
|
436
|
+
assert_equal(4, method.call_trees.callers.length)
|
437
|
+
call_tree = method.call_trees.callers[0]
|
438
|
+
assert_equal('MeasureMemoryTest#test_memory', call_tree.parent.target.full_name)
|
439
|
+
assert_equal(40.0, call_tree.total_time)
|
440
|
+
assert_equal(0.0, call_tree.wait_time)
|
441
|
+
assert_equal(40.0, call_tree.self_time)
|
442
|
+
assert_equal(0.0, call_tree.children_time)
|
443
|
+
|
444
|
+
call_tree = method.call_trees.callers[1]
|
445
|
+
assert_equal('Integer#times', call_tree.parent.target.full_name)
|
446
|
+
assert_equal(400.0, call_tree.total_time)
|
447
|
+
assert_equal(0.0, call_tree.wait_time)
|
448
|
+
assert_equal(400.0, call_tree.self_time)
|
449
|
+
assert_equal(0.0, call_tree.children_time)
|
450
|
+
|
451
|
+
call_tree = method.call_trees.callers[2]
|
452
|
+
assert_equal('Allocator#make_hashes', call_tree.parent.target.full_name)
|
453
|
+
assert_equal(200.0, call_tree.total_time)
|
454
|
+
assert_equal(0.0, call_tree.wait_time)
|
455
|
+
assert_equal(200.0, call_tree.self_time)
|
456
|
+
assert_equal(0.0, call_tree.children_time)
|
457
|
+
|
458
|
+
call_tree = method.call_trees.callers[3]
|
459
|
+
assert_equal('Allocator#make_strings', call_tree.parent.target.full_name)
|
460
|
+
assert_equal(80.0, call_tree.total_time)
|
461
|
+
assert_equal(0.0, call_tree.wait_time)
|
462
|
+
assert_equal(40.0, call_tree.self_time)
|
463
|
+
assert_equal(40.0, call_tree.children_time)
|
464
|
+
|
465
|
+
assert_equal(4, method.call_trees.callees.length)
|
466
|
+
call_tree = method.call_trees.callees[0]
|
467
|
+
assert_equal('BasicObject#initialize', call_tree.target.full_name)
|
468
|
+
assert_equal(0.0, call_tree.total_time)
|
469
|
+
assert_equal(0.0, call_tree.wait_time)
|
470
|
+
assert_equal(0.0, call_tree.self_time)
|
471
|
+
assert_equal(0.0, call_tree.children_time)
|
472
|
+
|
473
|
+
call_tree = method.call_trees.callees[1]
|
474
|
+
assert_equal('Array#initialize', call_tree.target.full_name)
|
475
|
+
assert_equal(0.0, call_tree.total_time)
|
476
|
+
assert_equal(0.0, call_tree.wait_time)
|
477
|
+
assert_equal(0.0, call_tree.self_time)
|
478
|
+
assert_equal(0.0, call_tree.children_time)
|
479
|
+
|
480
|
+
call_tree = method.call_trees.callees[2]
|
481
|
+
assert_equal('Hash#initialize', call_tree.target.full_name)
|
482
|
+
assert_equal(0.0, call_tree.total_time)
|
483
|
+
assert_equal(0.0, call_tree.wait_time)
|
484
|
+
assert_equal(0.0, call_tree.self_time)
|
485
|
+
assert_equal(0.0, call_tree.children_time)
|
486
|
+
|
487
|
+
call_tree = method.call_trees.callees[3]
|
488
|
+
assert_equal('String#initialize', call_tree.target.full_name)
|
489
|
+
assert_equal(40.0, call_tree.total_time)
|
490
|
+
assert_equal(0.0, call_tree.wait_time)
|
491
|
+
assert_equal(40.0, call_tree.self_time)
|
492
|
+
assert_equal(0.0, call_tree.children_time)
|
493
|
+
|
494
|
+
# Method 3
|
495
|
+
method = methods[3]
|
496
|
+
assert_equal('Allocator#make_arrays', method.full_name)
|
497
|
+
assert_equal(400.0, method.total_time)
|
498
|
+
assert_equal(0.0, method.wait_time)
|
499
|
+
assert_equal(0.0, method.self_time)
|
500
|
+
assert_equal(400.0, method.children_time)
|
501
|
+
|
502
|
+
assert_equal(1, method.call_trees.callers.length)
|
503
|
+
call_tree = method.call_trees.callers[0]
|
504
|
+
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
505
|
+
assert_equal(400.0, call_tree.total_time)
|
506
|
+
assert_equal(0.0, call_tree.wait_time)
|
507
|
+
assert_equal(0.0, call_tree.self_time)
|
508
|
+
assert_equal(400.0, call_tree.children_time)
|
509
|
+
|
510
|
+
assert_equal(1, method.call_trees.callees.length)
|
511
|
+
call_tree = method.call_trees.callees[0]
|
512
|
+
assert_equal('Integer#times', call_tree.target.full_name)
|
513
|
+
assert_equal(400.0, call_tree.total_time)
|
514
|
+
assert_equal(0.0, call_tree.wait_time)
|
515
|
+
assert_equal(0.0, call_tree.self_time)
|
516
|
+
assert_equal(400.0, call_tree.children_time)
|
517
|
+
|
518
|
+
# Method 4
|
519
|
+
method = methods[4]
|
520
|
+
assert_equal('Integer#times', method.full_name)
|
521
|
+
assert_equal(400.0, method.total_time)
|
522
|
+
assert_equal(0.0, method.wait_time)
|
523
|
+
assert_equal(0.0, method.self_time)
|
524
|
+
assert_equal(400.0, method.children_time)
|
525
|
+
|
526
|
+
assert_equal(1, method.call_trees.callers.length)
|
527
|
+
call_tree = method.call_trees.callers[0]
|
528
|
+
assert_equal('Allocator#make_arrays', call_tree.parent.target.full_name)
|
529
|
+
assert_equal(400.0, call_tree.total_time)
|
530
|
+
assert_equal(0.0, call_tree.wait_time)
|
531
|
+
assert_equal(0.0, call_tree.self_time)
|
532
|
+
assert_equal(400.0, call_tree.children_time)
|
533
|
+
|
534
|
+
assert_equal(1, method.call_trees.callees.length)
|
535
|
+
call_tree = method.call_trees.callees[0]
|
536
|
+
assert_equal('Class#new', call_tree.target.full_name)
|
537
|
+
assert_equal(400.0, call_tree.total_time)
|
538
|
+
assert_equal(0.0, call_tree.wait_time)
|
539
|
+
assert_equal(400.0, call_tree.self_time)
|
540
|
+
assert_equal(0.0, call_tree.children_time)
|
541
|
+
|
542
|
+
# Method 5
|
543
|
+
method = methods[5]
|
544
|
+
assert_equal('Allocator#make_hashes', method.full_name)
|
545
|
+
assert_equal(200.0, method.total_time)
|
546
|
+
assert_equal(0.0, method.wait_time)
|
547
|
+
assert_equal(0.0, method.self_time)
|
548
|
+
assert_equal(200.0, method.children_time)
|
549
|
+
|
550
|
+
assert_equal(1, method.call_trees.callers.length)
|
551
|
+
call_tree = method.call_trees.callers[0]
|
552
|
+
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
553
|
+
assert_equal(200.0, call_tree.total_time)
|
554
|
+
assert_equal(0.0, call_tree.wait_time)
|
555
|
+
assert_equal(0.0, call_tree.self_time)
|
556
|
+
assert_equal(200.0, call_tree.children_time)
|
557
|
+
|
558
|
+
assert_equal(1, method.call_trees.callees.length)
|
559
|
+
call_tree = method.call_trees.callees[0]
|
560
|
+
assert_equal('Class#new', call_tree.target.full_name)
|
561
|
+
assert_equal(200.0, call_tree.total_time)
|
562
|
+
assert_equal(0.0, call_tree.wait_time)
|
563
|
+
assert_equal(200.0, call_tree.self_time)
|
564
|
+
assert_equal(0.0, call_tree.children_time)
|
565
|
+
|
566
|
+
# Method 6
|
567
|
+
method = methods[6]
|
568
|
+
assert_equal('Allocator#make_strings', method.full_name)
|
569
|
+
assert_equal(160.0, method.total_time)
|
570
|
+
assert_equal(0.0, method.wait_time)
|
571
|
+
assert_equal(40.0, method.self_time)
|
572
|
+
assert_equal(120.0, method.children_time)
|
573
|
+
|
574
|
+
assert_equal(1, method.call_trees.callers.length)
|
575
|
+
call_tree = method.call_trees.callers[0]
|
576
|
+
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
577
|
+
assert_equal(160.0, call_tree.total_time)
|
578
|
+
assert_equal(0.0, call_tree.wait_time)
|
579
|
+
assert_equal(40.0, call_tree.self_time)
|
580
|
+
assert_equal(120.0, call_tree.children_time)
|
581
|
+
|
582
|
+
assert_equal(2, method.call_trees.callees.length)
|
583
|
+
call_tree = method.call_trees.callees[0]
|
584
|
+
assert_equal('String#*', call_tree.target.full_name)
|
585
|
+
assert_equal(40.0, call_tree.total_time)
|
586
|
+
assert_equal(0.0, call_tree.wait_time)
|
587
|
+
assert_equal(40.0, call_tree.self_time)
|
588
|
+
assert_equal(0.0, call_tree.children_time)
|
589
|
+
|
590
|
+
call_tree = method.call_trees.callees[1]
|
591
|
+
assert_equal('Class#new', call_tree.target.full_name)
|
592
|
+
assert_equal(80.0, call_tree.total_time)
|
593
|
+
assert_equal(0.0, call_tree.wait_time)
|
594
|
+
assert_equal(40.0, call_tree.self_time)
|
595
|
+
assert_equal(40.0, call_tree.children_time)
|
596
|
+
|
597
|
+
# Method 7
|
598
|
+
method = methods[7]
|
599
|
+
assert_equal('String#*', method.full_name)
|
600
|
+
assert_equal(40.0, method.total_time)
|
601
|
+
assert_equal(0.0, method.wait_time)
|
602
|
+
assert_equal(40.0, method.self_time)
|
603
|
+
assert_equal(0.0, method.children_time)
|
604
|
+
|
605
|
+
assert_equal(1, method.call_trees.callers.length)
|
606
|
+
call_tree = method.call_trees.callers[0]
|
607
|
+
assert_equal('Allocator#make_strings', call_tree.parent.target.full_name)
|
608
|
+
assert_equal(40.0, call_tree.total_time)
|
609
|
+
assert_equal(0.0, call_tree.wait_time)
|
610
|
+
assert_equal(40.0, call_tree.self_time)
|
611
|
+
assert_equal(0.0, call_tree.children_time)
|
612
|
+
|
613
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
614
|
+
|
615
|
+
# Method 8
|
616
|
+
method = methods[8]
|
617
|
+
assert_equal('String#initialize', method.full_name)
|
618
|
+
assert_equal(40.0, method.total_time)
|
619
|
+
assert_equal(0.0, method.wait_time)
|
620
|
+
assert_equal(40.0, method.self_time)
|
621
|
+
assert_equal(0.0, method.children_time)
|
622
|
+
|
623
|
+
assert_equal(1, method.call_trees.callers.length)
|
624
|
+
call_tree = method.call_trees.callers[0]
|
625
|
+
assert_equal('Class#new', call_tree.parent.target.full_name)
|
626
|
+
assert_equal(40.0, call_tree.total_time)
|
627
|
+
assert_equal(0.0, call_tree.wait_time)
|
628
|
+
assert_equal(40.0, call_tree.self_time)
|
629
|
+
assert_equal(0.0, call_tree.children_time)
|
630
|
+
|
631
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
632
|
+
|
633
|
+
# Method 9
|
634
|
+
method = methods[9]
|
635
|
+
assert_equal('BasicObject#initialize', method.full_name)
|
636
|
+
assert_equal(0.0, method.total_time)
|
637
|
+
assert_equal(0.0, method.wait_time)
|
638
|
+
assert_equal(0.0, method.self_time)
|
639
|
+
assert_equal(0.0, method.children_time)
|
640
|
+
|
641
|
+
assert_equal(1, method.call_trees.callers.length)
|
642
|
+
call_tree = method.call_trees.callers[0]
|
643
|
+
assert_equal('Class#new', call_tree.parent.target.full_name)
|
644
|
+
assert_equal(0.0, call_tree.total_time)
|
645
|
+
assert_equal(0.0, call_tree.wait_time)
|
646
|
+
assert_equal(0.0, call_tree.self_time)
|
647
|
+
assert_equal(0.0, call_tree.children_time)
|
648
|
+
|
649
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
650
|
+
|
651
|
+
# Method 10
|
652
|
+
method = methods[10]
|
653
|
+
assert_equal('Hash#initialize', method.full_name)
|
654
|
+
assert_equal(0.0, method.total_time)
|
655
|
+
assert_equal(0.0, method.wait_time)
|
656
|
+
assert_equal(0.0, method.self_time)
|
657
|
+
assert_equal(0.0, method.children_time)
|
658
|
+
|
659
|
+
assert_equal(1, method.call_trees.callers.length)
|
660
|
+
call_tree = method.call_trees.callers[0]
|
661
|
+
assert_equal('Class#new', call_tree.parent.target.full_name)
|
662
|
+
assert_equal(0.0, call_tree.total_time)
|
663
|
+
assert_equal(0.0, call_tree.wait_time)
|
664
|
+
assert_equal(0.0, call_tree.self_time)
|
665
|
+
assert_equal(0.0, call_tree.children_time)
|
666
|
+
|
667
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
668
|
+
|
669
|
+
# Method 11
|
670
|
+
method = methods[11]
|
671
|
+
assert_equal('Array#initialize', method.full_name)
|
672
|
+
assert_equal(0.0, method.total_time)
|
673
|
+
assert_equal(0.0, method.wait_time)
|
674
|
+
assert_equal(0.0, method.self_time)
|
675
|
+
assert_equal(0.0, method.children_time)
|
676
|
+
|
677
|
+
assert_equal(1, method.call_trees.callers.length)
|
678
|
+
call_tree = method.call_trees.callers[0]
|
679
|
+
assert_equal('Class#new', call_tree.parent.target.full_name)
|
680
|
+
assert_equal(0.0, call_tree.total_time)
|
681
|
+
assert_equal(0.0, call_tree.wait_time)
|
682
|
+
assert_equal(0.0, call_tree.self_time)
|
683
|
+
assert_equal(0.0, call_tree.children_time)
|
684
|
+
|
685
|
+
assert_equal(0.0, method.call_trees.callees.length)
|
686
|
+
end
|
687
|
+
end
|
688
|
+
end
|