ruby-prof 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +25 -9
- data/{README.rdoc → README.md} +2 -2
- data/Rakefile +3 -3
- data/ext/ruby_prof/rp_call_tree.c +0 -2
- data/ext/ruby_prof/rp_call_tree.h +1 -1
- data/ext/ruby_prof/rp_measure_allocations.c +10 -13
- data/ext/ruby_prof/rp_measure_memory.c +8 -4
- data/ext/ruby_prof/rp_measure_process_time.c +7 -6
- data/ext/ruby_prof/rp_measurement.c +1 -1
- data/ext/ruby_prof/rp_measurement.h +1 -1
- data/ext/ruby_prof/rp_profile.c +18 -3
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +8 -6
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +2 -1
- data/lib/ruby-prof/printers/call_tree_printer.rb +3 -7
- data/lib/ruby-prof/printers/graph_html_printer.rb +1 -1
- data/lib/ruby-prof/version.rb +1 -1
- data/ruby-prof.gemspec +2 -3
- data/test/alias_test.rb +97 -101
- data/test/duplicate_names_test.rb +4 -4
- data/test/dynamic_method_test.rb +23 -9
- data/test/marshal_test.rb +15 -2
- data/test/measure_allocations.rb +1 -5
- data/test/measure_allocations_test.rb +27 -69
- data/test/measure_memory_test.rb +688 -0
- data/test/measure_process_time_test.rb +1564 -735
- data/test/measure_wall_time_test.rb +6 -15
- data/test/printer_call_tree_test.rb +2 -2
- data/test/recursive_test.rb +372 -148
- data/test/test_helper.rb +4 -8
- data/test/unique_call_path_test.rb +24 -8
- data/test/yarv_test.rb +8 -4
- metadata +10 -26
- data/test/measure_allocations_trace_test.rb +0 -375
- data/test/measure_memory_trace_test.rb +0 -1460
- data/test/temp.rb +0 -20
@@ -3,18 +3,18 @@
|
|
3
3
|
|
4
4
|
require File.expand_path('../test_helper', __FILE__)
|
5
5
|
|
6
|
-
class
|
6
|
+
class DuplicateNamesTest < TestCase
|
7
7
|
def test_names
|
8
8
|
result = RubyProf::profile do
|
9
9
|
str = %{module Foo; class Bar; def foo; end end end}
|
10
10
|
|
11
11
|
eval str
|
12
12
|
Foo::Bar.new.foo
|
13
|
-
|
13
|
+
DuplicateNamesTest.class_eval {remove_const :Foo}
|
14
14
|
|
15
15
|
eval str
|
16
16
|
Foo::Bar.new.foo
|
17
|
-
|
17
|
+
DuplicateNamesTest.class_eval {remove_const :Foo}
|
18
18
|
|
19
19
|
eval str
|
20
20
|
Foo::Bar.new.foo
|
@@ -24,7 +24,7 @@ class DuplicateNames < TestCase
|
|
24
24
|
methods = result.threads.first.methods.sort.reverse
|
25
25
|
|
26
26
|
methods = methods.select do |method|
|
27
|
-
method.full_name == '
|
27
|
+
method.full_name == 'DuplicateNamesTest::Foo::Bar#foo'
|
28
28
|
end
|
29
29
|
|
30
30
|
assert_equal(3, methods.length)
|
data/test/dynamic_method_test.rb
CHANGED
@@ -39,15 +39,29 @@ class DynamicMethodTest < TestCase
|
|
39
39
|
end
|
40
40
|
|
41
41
|
methods = result.threads.first.methods.sort.reverse
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
|
43
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1')
|
44
|
+
expected_method_names = %w(
|
45
|
+
DynamicMethodTest#test_dynamic_method
|
46
|
+
Kernel#sleep
|
47
|
+
DynamicMethodTest::FruitMedley#peach
|
48
|
+
DynamicMethodTest::FruitMedley#banana
|
49
|
+
DynamicMethodTest::FruitMedley#orange
|
50
|
+
DynamicMethodTest::FruitMedley#apple
|
51
|
+
Symbol#to_s
|
52
|
+
)
|
53
|
+
else
|
54
|
+
expected_method_names = %w(
|
55
|
+
DynamicMethodTest#test_dynamic_method
|
56
|
+
Kernel#sleep
|
57
|
+
DynamicMethodTest::FruitMedley#peach
|
58
|
+
DynamicMethodTest::FruitMedley#banana
|
59
|
+
DynamicMethodTest::FruitMedley#orange
|
60
|
+
DynamicMethodTest::FruitMedley#apple
|
61
|
+
Integer#==
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
51
65
|
assert_equal expected_method_names.join("\n"), methods.map(&:full_name).join("\n")
|
52
66
|
end
|
53
67
|
end
|
data/test/marshal_test.rb
CHANGED
@@ -5,6 +5,8 @@ require File.expand_path("../test_helper", __FILE__)
|
|
5
5
|
class MarshalTest < TestCase
|
6
6
|
def verify_profile(profile_1, profile_2)
|
7
7
|
verify_threads(profile_1.threads, profile_2.threads)
|
8
|
+
assert_equal(profile_1.measure_mode, profile_2.measure_mode)
|
9
|
+
assert_equal(profile_1.track_allocations?, profile_2.track_allocations?)
|
8
10
|
end
|
9
11
|
|
10
12
|
def verify_threads(threads_1, threads_2)
|
@@ -108,8 +110,19 @@ class MarshalTest < TestCase
|
|
108
110
|
assert_equal(measurement_1.called, measurement_2.called)
|
109
111
|
end
|
110
112
|
|
111
|
-
def
|
112
|
-
profile_1 = RubyProf.profile do
|
113
|
+
def test_marshal_1
|
114
|
+
profile_1 = RubyProf.profile(:measure_mode => RubyProf::WALL_TIME) do
|
115
|
+
1.times { RubyProf::C1.new.sleep_wait }
|
116
|
+
end
|
117
|
+
|
118
|
+
data = Marshal.dump(profile_1)
|
119
|
+
profile_2 = Marshal.load(data)
|
120
|
+
|
121
|
+
verify_profile(profile_1, profile_2)
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_marshal_2
|
125
|
+
profile_1 = RubyProf.profile(:measure_mode => RubyProf::PROCESS_TIME, :track_allocations => true) do
|
113
126
|
1.times { RubyProf::C1.new.sleep_wait }
|
114
127
|
end
|
115
128
|
|
data/test/measure_allocations.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
require File.expand_path('../test_helper', __FILE__)
|
5
5
|
require_relative './measure_allocations'
|
6
6
|
|
7
|
-
class
|
7
|
+
class MeasureAllocationsTraceTest < TestCase
|
8
8
|
def setup
|
9
9
|
RubyProf::measure_mode = RubyProf::ALLOCATIONS
|
10
10
|
end
|
@@ -15,7 +15,7 @@ class MeasureAllocationsTest < TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_allocations
|
18
|
-
result = RubyProf.profile do
|
18
|
+
result = RubyProf.profile(:track_allocations => true) do
|
19
19
|
allocator = Allocator.new
|
20
20
|
allocator.run
|
21
21
|
end
|
@@ -24,11 +24,11 @@ class MeasureAllocationsTest < TestCase
|
|
24
24
|
assert_in_delta(20, thread.total_time, 1)
|
25
25
|
|
26
26
|
methods = result.threads.first.methods.sort.reverse
|
27
|
-
assert_equal(
|
27
|
+
assert_equal(12, methods.length)
|
28
28
|
|
29
29
|
# Method 0
|
30
30
|
method = methods[0]
|
31
|
-
assert_equal('
|
31
|
+
assert_equal('MeasureAllocationsTraceTest#test_allocations', method.full_name)
|
32
32
|
assert_in_delta(20, method.total_time, 1)
|
33
33
|
assert_equal(0, method.wait_time)
|
34
34
|
assert_equal(0, method.self_time)
|
@@ -61,31 +61,7 @@ class MeasureAllocationsTest < TestCase
|
|
61
61
|
|
62
62
|
assert_equal(1, method.call_trees.callers.length)
|
63
63
|
call_tree = method.call_trees.callers[0]
|
64
|
-
assert_equal('
|
65
|
-
assert_equal(19, call_tree.total_time)
|
66
|
-
assert_equal(0, call_tree.wait_time)
|
67
|
-
assert_equal(0, call_tree.self_time)
|
68
|
-
assert_equal(19, call_tree.children_time)
|
69
|
-
|
70
|
-
assert_equal(1, method.call_trees.callees.length)
|
71
|
-
call_tree = method.call_trees.callees[0]
|
72
|
-
assert_equal('Allocator#internal_run', call_tree.target.full_name)
|
73
|
-
assert_equal(19, call_tree.total_time)
|
74
|
-
assert_equal(0, call_tree.wait_time)
|
75
|
-
assert_equal(0, call_tree.self_time)
|
76
|
-
assert_equal(19, call_tree.children_time)
|
77
|
-
|
78
|
-
# Method 2
|
79
|
-
method = methods[2]
|
80
|
-
assert_equal('Allocator#internal_run', method.full_name)
|
81
|
-
assert_equal(19, method.total_time)
|
82
|
-
assert_equal(0, method.wait_time)
|
83
|
-
assert_equal(0, method.self_time)
|
84
|
-
assert_equal(19, method.children_time)
|
85
|
-
|
86
|
-
assert_equal(1, method.call_trees.callers.length)
|
87
|
-
call_tree = method.call_trees.callers[0]
|
88
|
-
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
64
|
+
assert_equal('MeasureAllocationsTraceTest#test_allocations', call_tree.parent.target.full_name)
|
89
65
|
assert_equal(19, call_tree.total_time)
|
90
66
|
assert_equal(0, call_tree.wait_time)
|
91
67
|
assert_equal(0, call_tree.self_time)
|
@@ -113,8 +89,8 @@ class MeasureAllocationsTest < TestCase
|
|
113
89
|
assert_equal(1, call_tree.self_time)
|
114
90
|
assert_equal(3, call_tree.children_time)
|
115
91
|
|
116
|
-
# Method
|
117
|
-
method = methods[
|
92
|
+
# Method 2
|
93
|
+
method = methods[2]
|
118
94
|
assert_equal('Class#new', method.full_name)
|
119
95
|
assert_equal(18, method.total_time)
|
120
96
|
assert_equal(0, method.wait_time)
|
@@ -123,7 +99,7 @@ class MeasureAllocationsTest < TestCase
|
|
123
99
|
|
124
100
|
assert_equal(4, method.call_trees.callers.length)
|
125
101
|
call_tree = method.call_trees.callers[0]
|
126
|
-
assert_equal('
|
102
|
+
assert_equal('MeasureAllocationsTraceTest#test_allocations', call_tree.parent.target.full_name)
|
127
103
|
assert_equal(1, call_tree.total_time)
|
128
104
|
assert_equal(0, call_tree.wait_time)
|
129
105
|
assert_equal(1, call_tree.self_time)
|
@@ -179,8 +155,8 @@ class MeasureAllocationsTest < TestCase
|
|
179
155
|
assert_equal(1, call_tree.self_time)
|
180
156
|
assert_equal(0, call_tree.children_time)
|
181
157
|
|
182
|
-
# Method
|
183
|
-
method = methods[
|
158
|
+
# Method 3
|
159
|
+
method = methods[3]
|
184
160
|
assert_equal('Allocator#make_arrays', method.full_name)
|
185
161
|
assert_equal(10, method.total_time)
|
186
162
|
assert_equal(0, method.wait_time)
|
@@ -189,7 +165,7 @@ class MeasureAllocationsTest < TestCase
|
|
189
165
|
|
190
166
|
assert_equal(1, method.call_trees.callers.length)
|
191
167
|
call_tree = method.call_trees.callers[0]
|
192
|
-
assert_equal('Allocator#
|
168
|
+
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
193
169
|
assert_equal(10, call_tree.total_time)
|
194
170
|
assert_equal(0, call_tree.wait_time)
|
195
171
|
assert_equal(0, call_tree.self_time)
|
@@ -203,8 +179,8 @@ class MeasureAllocationsTest < TestCase
|
|
203
179
|
assert_equal(0, call_tree.self_time)
|
204
180
|
assert_equal(10, call_tree.children_time)
|
205
181
|
|
206
|
-
# Method
|
207
|
-
method = methods[
|
182
|
+
# Method 4
|
183
|
+
method = methods[4]
|
208
184
|
assert_equal('Integer#times', method.full_name)
|
209
185
|
assert_equal(10, method.total_time)
|
210
186
|
assert_equal(0, method.wait_time)
|
@@ -227,8 +203,8 @@ class MeasureAllocationsTest < TestCase
|
|
227
203
|
assert_equal(10, call_tree.self_time)
|
228
204
|
assert_equal(0, call_tree.children_time)
|
229
205
|
|
230
|
-
# Method
|
231
|
-
method = methods[
|
206
|
+
# Method 5
|
207
|
+
method = methods[5]
|
232
208
|
assert_equal('Allocator#make_hashes', method.full_name)
|
233
209
|
assert_equal(5, method.total_time)
|
234
210
|
assert_equal(0, method.wait_time)
|
@@ -237,7 +213,7 @@ class MeasureAllocationsTest < TestCase
|
|
237
213
|
|
238
214
|
assert_equal(1, method.call_trees.callers.length)
|
239
215
|
call_tree = method.call_trees.callers[0]
|
240
|
-
assert_equal('Allocator#
|
216
|
+
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
241
217
|
assert_equal(5, call_tree.total_time)
|
242
218
|
assert_equal(0, call_tree.wait_time)
|
243
219
|
assert_equal(0, call_tree.self_time)
|
@@ -251,8 +227,8 @@ class MeasureAllocationsTest < TestCase
|
|
251
227
|
assert_equal(5, call_tree.self_time)
|
252
228
|
assert_equal(0, call_tree.children_time)
|
253
229
|
|
254
|
-
# Method
|
255
|
-
method = methods[
|
230
|
+
# Method 6
|
231
|
+
method = methods[6]
|
256
232
|
assert_equal('Allocator#make_strings', method.full_name)
|
257
233
|
assert_equal(4, method.total_time)
|
258
234
|
assert_equal(0, method.wait_time)
|
@@ -261,7 +237,7 @@ class MeasureAllocationsTest < TestCase
|
|
261
237
|
|
262
238
|
assert_equal(1, method.call_trees.callers.length)
|
263
239
|
call_tree = method.call_trees.callers[0]
|
264
|
-
assert_equal('Allocator#
|
240
|
+
assert_equal('Allocator#run', call_tree.parent.target.full_name)
|
265
241
|
assert_equal(4, call_tree.total_time)
|
266
242
|
assert_equal(0, call_tree.wait_time)
|
267
243
|
assert_equal(1, call_tree.self_time)
|
@@ -282,8 +258,8 @@ class MeasureAllocationsTest < TestCase
|
|
282
258
|
assert_equal(1, call_tree.self_time)
|
283
259
|
assert_equal(1, call_tree.children_time)
|
284
260
|
|
285
|
-
# Method
|
286
|
-
method = methods[
|
261
|
+
# Method 7
|
262
|
+
method = methods[7]
|
287
263
|
assert_equal('String#*', method.full_name)
|
288
264
|
assert_equal(1, method.total_time)
|
289
265
|
assert_equal(0, method.wait_time)
|
@@ -300,8 +276,8 @@ class MeasureAllocationsTest < TestCase
|
|
300
276
|
|
301
277
|
assert_equal(0, method.call_trees.callees.length)
|
302
278
|
|
303
|
-
# Method
|
304
|
-
method = methods[
|
279
|
+
# Method 8
|
280
|
+
method = methods[8]
|
305
281
|
assert_equal('String#initialize', method.full_name)
|
306
282
|
assert_equal(1, method.total_time)
|
307
283
|
assert_equal(0, method.wait_time)
|
@@ -318,8 +294,8 @@ class MeasureAllocationsTest < TestCase
|
|
318
294
|
|
319
295
|
assert_equal(0, method.call_trees.callees.length)
|
320
296
|
|
321
|
-
# Method
|
322
|
-
method = methods[
|
297
|
+
# Method 9
|
298
|
+
method = methods[9]
|
323
299
|
assert_equal('BasicObject#initialize', method.full_name)
|
324
300
|
assert_equal(0, method.total_time)
|
325
301
|
assert_equal(0, method.wait_time)
|
@@ -336,8 +312,8 @@ class MeasureAllocationsTest < TestCase
|
|
336
312
|
|
337
313
|
assert_equal(0, method.call_trees.callees.length)
|
338
314
|
|
339
|
-
# Method
|
340
|
-
method = methods[
|
315
|
+
# Method 10
|
316
|
+
method = methods[10]
|
341
317
|
assert_equal('Hash#initialize', method.full_name)
|
342
318
|
assert_equal(0, method.total_time)
|
343
319
|
assert_equal(0, method.wait_time)
|
@@ -353,23 +329,5 @@ class MeasureAllocationsTest < TestCase
|
|
353
329
|
assert_equal(0, call_tree.children_time)
|
354
330
|
|
355
331
|
assert_equal(0, method.call_trees.callees.length)
|
356
|
-
|
357
|
-
# Method 12
|
358
|
-
method = methods[12]
|
359
|
-
assert_equal('Array#initialize', method.full_name)
|
360
|
-
assert_equal(0, method.total_time)
|
361
|
-
assert_equal(0, method.wait_time)
|
362
|
-
assert_equal(0, method.self_time)
|
363
|
-
assert_equal(0, method.children_time)
|
364
|
-
|
365
|
-
assert_equal(1, method.call_trees.callers.length)
|
366
|
-
call_tree = method.call_trees.callers[0]
|
367
|
-
assert_equal('Class#new', call_tree.parent.target.full_name)
|
368
|
-
assert_equal(0, call_tree.total_time)
|
369
|
-
assert_equal(0, call_tree.wait_time)
|
370
|
-
assert_equal(0, call_tree.self_time)
|
371
|
-
assert_equal(0, call_tree.children_time)
|
372
|
-
|
373
|
-
assert_equal(0, method.call_trees.callees.length)
|
374
332
|
end
|
375
333
|
end
|