ruby-prof 1.3.0-x64-mingw32 → 1.4.3-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +42 -0
  3. data/README.rdoc +1 -1
  4. data/Rakefile +2 -14
  5. data/ext/ruby_prof/extconf.rb +13 -27
  6. data/ext/ruby_prof/rp_allocation.c +1 -1
  7. data/ext/ruby_prof/rp_call_trees.c +2 -2
  8. data/ext/ruby_prof/rp_measure_allocations.c +1 -1
  9. data/ext/ruby_prof/rp_measure_process_time.c +1 -1
  10. data/ext/ruby_prof/rp_measure_wall_time.c +1 -1
  11. data/ext/ruby_prof/rp_measurement.c +1 -1
  12. data/ext/ruby_prof/rp_method.c +2 -2
  13. data/ext/ruby_prof/rp_method.h +19 -19
  14. data/ext/ruby_prof/rp_profile.c +12 -37
  15. data/ext/ruby_prof/rp_profile.h +0 -1
  16. data/ext/ruby_prof/rp_stack.c +12 -4
  17. data/ext/ruby_prof/rp_thread.c +2 -2
  18. data/ext/ruby_prof/vc/ruby_prof.sln +8 -0
  19. data/ext/ruby_prof/vc/ruby_prof.vcxproj +15 -4
  20. data/lib/2.7/ruby_prof.so +0 -0
  21. data/lib/3.0/ruby_prof.so +0 -0
  22. data/lib/ruby-prof.rb +4 -3
  23. data/lib/ruby-prof/compatibility.rb +0 -10
  24. data/lib/ruby-prof/printers/abstract_printer.rb +13 -3
  25. data/lib/ruby-prof/printers/call_stack_printer.rb +1 -0
  26. data/lib/ruby-prof/printers/flat_printer.rb +3 -2
  27. data/lib/ruby-prof/printers/graph_printer.rb +1 -1
  28. data/lib/ruby-prof/profile.rb +8 -4
  29. data/lib/ruby-prof/rack.rb +51 -130
  30. data/lib/ruby-prof/version.rb +1 -1
  31. data/ruby-prof.gemspec +1 -1
  32. data/test/fiber_test.rb +55 -187
  33. data/test/gc_test.rb +12 -2
  34. data/test/marshal_test.rb +22 -5
  35. data/test/measure_memory_trace_test.rb +361 -2
  36. data/test/printer_call_stack_test.rb +0 -1
  37. data/test/printer_call_tree_test.rb +0 -1
  38. data/test/printer_flat_test.rb +61 -30
  39. data/test/printer_graph_html_test.rb +0 -1
  40. data/test/printer_graph_test.rb +3 -4
  41. data/test/printers_test.rb +3 -3
  42. data/test/printing_recursive_graph_test.rb +1 -1
  43. data/test/profile_test.rb +16 -0
  44. data/test/rack_test.rb +0 -64
  45. data/test/start_stop_test.rb +4 -4
  46. data/test/temp.rb +20 -0
  47. data/test/test_helper.rb +10 -5
  48. metadata +9 -5
@@ -1,3 +1,3 @@
1
1
  module RubyProf
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.3"
3
3
  end
data/ruby-prof.gemspec CHANGED
@@ -56,7 +56,7 @@ EOF
56
56
  'test/*.rb']
57
57
 
58
58
  spec.test_files = Dir["test/test_*.rb"]
59
- spec.required_ruby_version = '>= 2.4.0'
59
+ spec.required_ruby_version = '>= 2.5.0'
60
60
  spec.date = Time.now.strftime('%Y-%m-%d')
61
61
  spec.homepage = 'https://github.com/ruby-prof/ruby-prof'
62
62
  spec.add_development_dependency('minitest')
data/test/fiber_test.rb CHANGED
@@ -8,254 +8,122 @@ require 'set'
8
8
 
9
9
  # -- Tests ----
10
10
  class FiberTest < TestCase
11
+
11
12
  def enumerator_with_fibers
12
- @fiber_ids << Fiber.current.object_id
13
13
  enum = Enumerator.new do |yielder|
14
14
  [1,2].each do |x|
15
- @fiber_ids << Fiber.current.object_id
16
- sleep 0.1
17
15
  yielder.yield x
18
16
  end
19
17
  end
20
- while true
21
- begin
22
- enum.next
23
- rescue StopIteration
24
- break
25
- end
26
- end
27
- sleep 0.1
18
+
19
+ enum.next
20
+ enum.next
21
+ end
22
+
23
+ def fiber_yield_resume
24
+ fiber = Fiber.new do
25
+ Fiber.yield 1
26
+ Fiber.yield 2
27
+ end
28
+
29
+ fiber.resume
30
+ fiber.resume
28
31
  end
29
32
 
30
33
  def setup
31
34
  # Need to use wall time for this test due to the sleep calls
32
35
  RubyProf::measure_mode = RubyProf::WALL_TIME
33
- @fiber_ids = Set.new
34
- @root_fiber = Fiber.current.object_id
35
- @thread_id = Thread.current.object_id
36
36
  end
37
37
 
38
38
  def test_fibers
39
39
  result = RubyProf.profile { enumerator_with_fibers }
40
40
 
41
- profiled_fiber_ids = result.threads.map(&:fiber_id)
42
- assert_equal(2, result.threads.length)
43
- assert_equal([@thread_id], result.threads.map(&:id).uniq)
44
- assert_equal(@fiber_ids, Set.new(profiled_fiber_ids))
41
+ assert_equal(2, result.threads.size)
45
42
 
46
- assert profiled_fiber_ids.include?(@root_fiber)
47
- assert(root_fiber_profile = result.threads.detect{|t| t.fiber_id == @root_fiber})
48
- assert(enum_fiber_profile = result.threads.detect{|t| t.fiber_id != @root_fiber})
49
- assert_in_delta(0.33, root_fiber_profile.total_time, 0.05)
50
- assert_in_delta(0.33, enum_fiber_profile.total_time, 0.05)
51
-
52
- methods = result.threads[0].methods.sort.reverse
53
- assert_equal(12, methods.count)
43
+ thread1 = result.threads[0]
44
+ methods = thread1.methods.sort.reverse
45
+ assert_equal(5, methods.count)
54
46
 
55
47
  method = methods[0]
56
48
  assert_equal('FiberTest#test_fibers', method.full_name)
57
49
  assert_equal(1, method.called)
58
- assert_in_delta(0.33, method.total_time, 0.05)
59
- assert_in_delta(0, method.self_time, 0.05)
60
- assert_in_delta(0, method.wait_time, 0.05)
61
- assert_in_delta(0.33, method.children_time, 0.05)
62
50
 
63
51
  method = methods[1]
64
52
  assert_equal('FiberTest#enumerator_with_fibers', method.full_name)
65
53
  assert_equal(1, method.called)
66
- assert_in_delta(0.33, method.total_time, 0.05)
67
- assert_in_delta(0, method.self_time, 0.05)
68
- assert_in_delta(0, method.wait_time, 0.05)
69
- assert_in_delta(0.33, method.children_time, 0.05)
70
54
 
71
55
  method = methods[2]
72
56
  assert_equal('Enumerator#next', method.full_name)
73
- assert_equal(3, method.called)
74
- assert_in_delta(0.22, method.total_time, 0.05)
75
- assert_in_delta(0, method.self_time, 0.05)
76
- assert_in_delta(0.22, method.wait_time, 0.05)
77
- assert_in_delta(0, method.children_time, 0.05)
57
+ assert_equal(2, method.called)
78
58
 
79
59
  method = methods[3]
80
- assert_equal('Kernel#sleep', method.full_name)
81
- assert_equal(1, method.called)
82
- assert_in_delta(0.11, method.total_time, 0.05)
83
- assert_in_delta(0.11, method.self_time, 0.05)
84
- assert_in_delta(0, method.wait_time, 0.05)
85
- assert_in_delta(0, method.children_time, 0.05)
86
-
87
- # Since these methods have such short times their order is a bit indeterminate
88
- method = methods.detect {|a_method| a_method.full_name == 'Class#new'}
89
60
  assert_equal('Class#new', method.full_name)
90
61
  assert_equal(1, method.called)
91
- assert_in_delta(0, method.total_time, 0.05)
92
- assert_in_delta(0, method.self_time, 0.05)
93
- assert_in_delta(0, method.wait_time, 0.05)
94
- assert_in_delta(0, method.children_time, 0.05)
95
-
96
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
97
- method = methods.detect {|a_method| a_method.full_name == 'Set#<<'}
98
- assert_equal('Set#<<', method.full_name)
99
- assert_equal(1, method.called)
100
- assert_in_delta(0, method.total_time, 0.05)
101
- assert_in_delta(0, method.self_time, 0.05)
102
- assert_in_delta(0, method.wait_time, 0.05)
103
- assert_in_delta(0, method.children_time, 0.05)
104
- end
105
62
 
106
- method = methods.detect {|a_method| a_method.full_name == 'Module#==='}
107
- assert_equal('Module#===', method.full_name)
63
+ method = methods[4]
64
+ assert_equal('Enumerator#initialize', method.full_name)
108
65
  assert_equal(1, method.called)
109
- assert_in_delta(0, method.total_time, 0.05)
110
- assert_in_delta(0, method.self_time, 0.05)
111
- assert_in_delta(0, method.wait_time, 0.05)
112
- assert_in_delta(0, method.children_time, 0.05)
113
66
 
114
- method = methods.detect {|a_method| a_method.full_name == 'Kernel#object_id'}
115
- assert_equal('Kernel#object_id', method.full_name)
116
- assert_equal(1, method.called)
117
- assert_in_delta(0, method.total_time, 0.05)
118
- assert_in_delta(0, method.self_time, 0.05)
119
- assert_in_delta(0, method.wait_time, 0.05)
120
- assert_in_delta(0, method.children_time, 0.05)
67
+ thread2 = result.threads[1]
68
+ methods = thread2.methods.sort.reverse
69
+ assert_equal(4, methods.count)
121
70
 
122
- method = methods.detect {|a_method| a_method.full_name == '<Class::Fiber>#current'}
123
- assert_equal('<Class::Fiber>#current', method.full_name)
71
+ method = methods[0]
72
+ assert_equal('Enumerator#each', method.full_name)
124
73
  assert_equal(1, method.called)
125
- assert_in_delta(0, method.total_time, 0.05)
126
- assert_in_delta(0, method.self_time, 0.05)
127
- assert_in_delta(0, method.wait_time, 0.05)
128
- assert_in_delta(0, method.children_time, 0.05)
129
74
 
130
- method = methods.detect {|a_method| a_method.full_name == 'Exception#exception'}
131
- assert_equal('Exception#exception', method.full_name)
75
+ method = methods[1]
76
+ assert_equal('Enumerator::Generator#each', method.full_name)
132
77
  assert_equal(1, method.called)
133
- assert_in_delta(0, method.total_time, 0.05)
134
- assert_in_delta(0, method.self_time, 0.05)
135
- assert_in_delta(0, method.wait_time, 0.05)
136
- assert_in_delta(0, method.children_time, 0.05)
137
78
 
138
- method = methods.detect {|a_method| a_method.full_name == 'Exception#backtrace'}
139
- assert_equal('Exception#backtrace', method.full_name)
79
+ method = methods[2]
80
+ assert_equal('Array#each', method.full_name)
140
81
  assert_equal(1, method.called)
141
- assert_in_delta(0, method.total_time, 0.05)
142
- assert_in_delta(0, method.self_time, 0.05)
143
- assert_in_delta(0, method.wait_time, 0.05)
144
- assert_in_delta(0, method.children_time, 0.05)
145
82
 
146
- method = methods.detect {|a_method| a_method.full_name == 'Enumerator#initialize'}
147
- assert_equal('Enumerator#initialize', method.full_name)
148
- assert_equal(1, method.called)
149
- assert_in_delta(0, method.total_time, 0.05)
150
- assert_in_delta(0, method.self_time, 0.05)
151
- assert_in_delta(0, method.wait_time, 0.05)
152
- assert_in_delta(0, method.children_time, 0.05)
83
+ method = methods[3]
84
+ assert_equal('Enumerator::Yielder#yield', method.full_name)
85
+ assert_equal(2, method.called)
86
+ end
153
87
 
154
- methods = result.threads[1].methods.sort.reverse
88
+ def test_fiber_resume
89
+ result = RubyProf.profile { fiber_yield_resume }
155
90
 
156
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
157
- assert_equal(10, methods.count)
158
- else
159
- assert_equal(11, methods.count)
160
- end
91
+ assert_equal(2, result.threads.size)
92
+
93
+ thread1 = result.threads[0]
94
+ methods = thread1.methods.sort.reverse
95
+ assert_equal(5, methods.count)
161
96
 
162
97
  method = methods[0]
163
- assert_equal('RubyProf::Profile#_inserted_parent_', method.full_name)
98
+ assert_equal('FiberTest#test_fiber_resume', method.full_name)
164
99
  assert_equal(1, method.called)
165
- assert_in_delta(0.33, method.total_time, 0.05)
166
- assert_in_delta(0, method.self_time, 0.05)
167
- assert_in_delta(0.11, method.wait_time, 0.05)
168
- assert_in_delta(0.22, method.children_time, 0.05)
169
100
 
170
101
  method = methods[1]
171
- assert_equal('Enumerator#each', method.full_name)
102
+ assert_equal('FiberTest#fiber_yield_resume', method.full_name)
172
103
  assert_equal(1, method.called)
173
- assert_in_delta(0.22, method.total_time, 0.05)
174
- assert_in_delta(0, method.self_time, 0.05)
175
- assert_in_delta(0, method.wait_time, 0.05)
176
- assert_in_delta(0.22, method.children_time, 0.05)
177
104
 
178
105
  method = methods[2]
179
- assert_equal('Enumerator::Generator#each', method.full_name)
180
- assert_equal(1, method.called)
181
- assert_in_delta(0.22, method.total_time, 0.05)
182
- assert_in_delta(0, method.self_time, 0.05)
183
- assert_in_delta(0, method.wait_time, 0.05)
184
- assert_in_delta(0.22, method.children_time, 0.05)
106
+ assert_equal('Fiber#resume', method.full_name)
107
+ assert_equal(2, method.called)
185
108
 
186
109
  method = methods[3]
187
- assert_equal('Array#each', method.full_name)
110
+ assert_equal('Class#new', method.full_name)
188
111
  assert_equal(1, method.called)
189
- assert_in_delta(0.22, method.total_time, 0.05)
190
- assert_in_delta(0, method.self_time, 0.05)
191
- assert_in_delta(0, method.wait_time, 0.05)
192
- assert_in_delta(0.22, method.children_time, 0.05)
193
112
 
194
113
  method = methods[4]
195
- assert_equal('Kernel#sleep', method.full_name)
196
- assert_equal(2, method.called)
197
- assert_in_delta(0.22, method.total_time, 0.05)
198
- assert_in_delta(0.22, method.self_time, 0.05)
199
- assert_in_delta(0, method.wait_time, 0.05)
200
- assert_in_delta(0, method.children_time, 0.05)
201
-
202
- # Since these methods have such short times their order is a bit indeterminate
203
- method = methods.detect {|a_method| a_method.full_name == 'Exception#initialize'}
204
- assert_equal('Exception#initialize', method.full_name)
114
+ assert_equal('Fiber#initialize', method.full_name)
205
115
  assert_equal(1, method.called)
206
- assert_in_delta(0, method.total_time, 0.05)
207
- assert_in_delta(0, method.self_time, 0.05)
208
- assert_in_delta(0, method.wait_time, 0.05)
209
- assert_in_delta(0, method.children_time, 0.05)
210
-
211
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
212
- method = methods.detect {|a_method| a_method.full_name == 'Set#<<'}
213
- assert_equal('Set#<<', method.full_name)
214
- assert_equal(2, method.called)
215
- assert_in_delta(0, method.total_time, 0.05)
216
- assert_in_delta(0, method.self_time, 0.05)
217
- assert_in_delta(0, method.wait_time, 0.05)
218
- assert_in_delta(0, method.children_time, 0.05)
219
- end
220
116
 
221
- method = methods.detect {|a_method| a_method.full_name == 'Kernel#object_id'}
222
- assert_equal('Kernel#object_id', method.full_name)
223
- assert_equal(2, method.called)
224
- assert_in_delta(0, method.total_time, 0.05)
225
- assert_in_delta(0, method.self_time, 0.05)
226
- assert_in_delta(0, method.wait_time, 0.05)
227
- assert_in_delta(0, method.children_time, 0.05)
117
+ thread1 = result.threads[1]
118
+ methods = thread1.methods.sort.reverse
119
+ assert_equal(2, methods.count)
228
120
 
229
- method = methods.detect {|a_method| a_method.full_name == 'Enumerator::Yielder#yield'}
230
- assert_equal('Enumerator::Yielder#yield', method.full_name)
231
- assert_equal(2, method.called)
232
- assert_in_delta(0, method.total_time, 0.05)
233
- assert_in_delta(0, method.self_time, 0.05)
234
- assert_in_delta(0, method.wait_time, 0.05)
235
- assert_in_delta(0, method.children_time, 0.05)
121
+ method = methods[0]
122
+ assert_equal('FiberTest#fiber_yield_resume', method.full_name)
123
+ assert_equal(1, method.called)
236
124
 
237
- method = methods.detect {|a_method| a_method.full_name == '<Class::Fiber>#current'}
238
- assert_equal('<Class::Fiber>#current', method.full_name)
125
+ method = methods[1]
126
+ assert_equal('<Class::Fiber>#yield', method.full_name)
239
127
  assert_equal(2, method.called)
240
- assert_in_delta(0, method.total_time, 0.05)
241
- assert_in_delta(0, method.self_time, 0.05)
242
- assert_in_delta(0, method.wait_time, 0.05)
243
- assert_in_delta(0, method.children_time, 0.05)
244
- end
245
-
246
- def test_merged_fibers
247
- result = RubyProf.profile(merge_fibers: true) { enumerator_with_fibers }
248
-
249
- assert_equal(1, result.threads.length)
250
-
251
- thread = result.threads.first
252
- assert_equal(thread.id, thread.fiber_id)
253
- assert_in_delta(0.3, thread.total_time, 0.05)
254
-
255
- assert(method_next = thread.methods.detect{|m| m.full_name == "Enumerator#next"})
256
- assert(method_each = thread.methods.detect{|m| m.full_name == "Enumerator#each"})
257
-
258
- assert_in_delta(0.2, method_next.total_time, 0.05)
259
- assert_in_delta(0.2, method_each.total_time, 0.05)
260
128
  end
261
129
  end
data/test/gc_test.rb CHANGED
@@ -29,6 +29,8 @@ class GcTest < TestCase
29
29
  array
30
30
  end
31
31
 
32
+ GC.start
33
+
32
34
  threads.each do |thread|
33
35
  refute_nil(thread.id)
34
36
  end
@@ -42,6 +44,8 @@ class GcTest < TestCase
42
44
  array
43
45
  end
44
46
 
47
+ GC.start
48
+
45
49
  methods.each do |method|
46
50
  refute_nil(method.method_name)
47
51
  end
@@ -55,6 +59,8 @@ class GcTest < TestCase
55
59
  array
56
60
  end
57
61
 
62
+ GC.start
63
+
58
64
  method_call_infos.each do |call_trees|
59
65
  refute_empty(call_trees.call_trees)
60
66
  end
@@ -63,11 +69,13 @@ class GcTest < TestCase
63
69
  def test_hold_onto_measurements
64
70
  measurements = 5.times.reduce(Array.new) do |array, i|
65
71
  profile = run_profile
66
- measurements = profile.threads.map(&:methods).flatten.map(&:measurement)
67
- array.concat(measurements)
72
+ measurements_2 = profile.threads.map(&:methods).flatten.map(&:measurement)
73
+ array.concat(measurements_2)
68
74
  array
69
75
  end
70
76
 
77
+ GC.start
78
+
71
79
  measurements.each do |measurement|
72
80
  error = assert_raises(RuntimeError) do
73
81
  measurement.total_time
@@ -83,6 +91,8 @@ class GcTest < TestCase
83
91
  array
84
92
  end
85
93
 
94
+ GC.start
95
+
86
96
  call_trees.each do |call_tree|
87
97
  refute_nil(call_tree.source_file)
88
98
  end
data/test/marshal_test.rb CHANGED
@@ -2,8 +2,6 @@
2
2
  # encoding: UTF-8
3
3
 
4
4
  require File.expand_path("../test_helper", __FILE__)
5
- require 'stringio'
6
-
7
5
  class MarshalTest < TestCase
8
6
  def verify_profile(profile_1, profile_2)
9
7
  verify_threads(profile_1.threads, profile_2.threads)
@@ -37,7 +35,13 @@ class MarshalTest < TestCase
37
35
 
38
36
  assert_equal(method_1.recursive?, method_2.recursive?)
39
37
 
40
- assert_equal(method_1.source_file, method_2.source_file)
38
+ if method_1.source_file
39
+ assert_equal(method_1.source_file, method_2.source_file)
40
+ else
41
+ assert_nil(method_1.source_file)
42
+ assert_nil(method_2.source_file)
43
+ end
44
+
41
45
  assert_equal(method_1.line, method_2.line)
42
46
 
43
47
  verify_measurement(method_1.measurement, method_2.measurement)
@@ -75,10 +79,23 @@ class MarshalTest < TestCase
75
79
 
76
80
  def verify_call_info(call_info_1, call_info_2)
77
81
  assert_equal(call_info_1.target, call_info_2.target)
78
- assert_equal(call_info_1.parent&.target, call_info_2.parent&.target)
82
+
83
+ if call_info_1.parent&.target
84
+ assert_equal(call_info_1.parent&.target, call_info_2.parent&.target)
85
+ else
86
+ assert_nil(call_info_1.parent&.target)
87
+ assert_nil(call_info_2.parent&.target)
88
+ end
79
89
 
80
90
  assert_equal(call_info_1.depth, call_info_2.depth)
81
- assert_equal(call_info_1.source_file, call_info_2.source_file)
91
+
92
+ if call_info_1.source_file
93
+ assert_equal(call_info_1.source_file, call_info_2.source_file) #
94
+ else
95
+ assert_nil(call_info_1.source_file)
96
+ assert_nil(call_info_2.source_file)
97
+ end
98
+
82
99
  assert_equal(call_info_1.line, call_info_2.line)
83
100
 
84
101
  verify_measurement(call_info_1.measurement, call_info_2.measurement)
@@ -36,7 +36,7 @@ class MeasureMemoryTraceTest < TestCase
36
36
  assert_in_delta(800, method.children_time, 1)
37
37
 
38
38
  assert_equal(0, method.call_trees.callers.length)
39
-
39
+
40
40
  assert_equal(2, method.call_trees.callees.length)
41
41
  call_tree = method.call_trees.callees[0]
42
42
  assert_equal('Class#new', call_tree.target.full_name)
@@ -738,7 +738,7 @@ class MeasureMemoryTraceTest < TestCase
738
738
 
739
739
  assert_equal(0.0, method.call_trees.callees.length)
740
740
  end
741
- else
741
+ elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0')
742
742
  def test_memory
743
743
  result = RubyProf.profile do
744
744
  allocator = Allocator.new
@@ -1095,6 +1095,365 @@ class MeasureMemoryTraceTest < TestCase
1095
1095
  assert_equal(0.0, call_tree.self_time)
1096
1096
  assert_equal(0.0, call_tree.children_time)
1097
1097
 
1098
+ assert_equal(0.0, method.call_trees.callees.length)
1099
+ end
1100
+ else
1101
+ def test_memory
1102
+ result = RubyProf.profile do
1103
+ allocator = Allocator.new
1104
+ allocator.run
1105
+ end
1106
+
1107
+ thread = result.threads.first
1108
+
1109
+ assert_in_delta(1680, thread.total_time, 1)
1110
+ methods = result.threads.first.methods.sort.reverse
1111
+ assert_equal(13, methods.length)
1112
+
1113
+ # Method 0
1114
+ method = methods[0]
1115
+ assert_equal('MeasureMemoryTraceTest#test_memory', method.full_name)
1116
+ assert_in_delta(1680, method.total_time, 1)
1117
+
1118
+ assert_equal(0.0, method.wait_time)
1119
+ assert_equal(80.0, method.self_time)
1120
+ assert_in_delta(1600, method.children_time, 1)
1121
+ assert_equal(0, method.call_trees.callers.length)
1122
+
1123
+ assert_equal(2, method.call_trees.callees.length)
1124
+ call_tree = method.call_trees.callees[0]
1125
+ assert_equal('Class#new', call_tree.target.full_name)
1126
+ assert_equal(40.0, call_tree.total_time)
1127
+ assert_equal(0.0, call_tree.wait_time)
1128
+ assert_equal(40.0, call_tree.self_time)
1129
+ assert_equal(0.0, call_tree.children_time)
1130
+
1131
+ call_tree = method.call_trees.callees[1]
1132
+ assert_equal('Allocator#run', call_tree.target.full_name)
1133
+ assert_equal(1560.0, call_tree.total_time)
1134
+ assert_equal(0.0, call_tree.wait_time)
1135
+ assert_equal(40.0, call_tree.self_time)
1136
+ assert_equal(1520.0, call_tree.children_time)
1137
+
1138
+ # Method 1
1139
+ method = methods[1]
1140
+ assert_equal('Allocator#run',method.full_name)
1141
+ assert_equal(1560.0, method.total_time)
1142
+ assert_equal(0.0, method.wait_time)
1143
+ assert_equal(40.0, method.self_time)
1144
+ assert_equal(1520.0, method.children_time)
1145
+
1146
+ assert_equal(1, method.call_trees.callers.length)
1147
+ call_tree = method.call_trees.callers[0]
1148
+ assert_equal('MeasureMemoryTraceTest#test_memory', call_tree.parent.target.full_name)
1149
+ assert_equal(1560.0, call_tree.total_time)
1150
+ assert_equal(0.0, call_tree.wait_time)
1151
+ assert_equal(40.0, call_tree.self_time)
1152
+ assert_equal(1520.0, call_tree.children_time)
1153
+
1154
+ assert_equal(1, method.call_trees.callees.length)
1155
+ call_tree = method.call_trees.callees[0]
1156
+ assert_equal('Allocator#internal_run', call_tree.target.full_name)
1157
+ assert_equal(1520.0, call_tree.total_time)
1158
+ assert_equal(0.0, call_tree.wait_time)
1159
+ assert_equal(120.0, call_tree.self_time)
1160
+ assert_equal(1400.0, call_tree.children_time)
1161
+
1162
+ # Method 2
1163
+ method = methods[2]
1164
+ assert_equal('Allocator#internal_run', method.full_name)
1165
+ assert_equal(1520.0, method.total_time)
1166
+ assert_equal(0.0, method.wait_time)
1167
+ assert_equal(120.0, method.self_time)
1168
+ assert_equal(1400.0, method.children_time)
1169
+
1170
+ assert_equal(1, method.call_trees.callers.length)
1171
+ call_tree = method.call_trees.callers[0]
1172
+ assert_equal('Allocator#run', call_tree.parent.target.full_name)
1173
+ assert_equal(1520.0, call_tree.total_time)
1174
+ assert_equal(0.0, call_tree.wait_time)
1175
+ assert_equal(120.0, call_tree.self_time)
1176
+ assert_equal(1400.0, call_tree.children_time)
1177
+
1178
+ assert_equal(3, method.call_trees.callees.length)
1179
+ call_tree = method.call_trees.callees[0]
1180
+ assert_equal('Allocator#make_arrays', call_tree.target.full_name)
1181
+ assert_equal(400.0, call_tree.total_time)
1182
+ assert_equal(0.0, call_tree.wait_time)
1183
+ assert_equal(0.0, call_tree.self_time)
1184
+ assert_equal(400.0, call_tree.children_time)
1185
+
1186
+ call_tree = method.call_trees.callees[1]
1187
+ assert_equal('Allocator#make_hashes', call_tree.target.full_name)
1188
+ assert_equal(840.0, call_tree.total_time)
1189
+ assert_equal(0.0, call_tree.wait_time)
1190
+ assert_equal(0.0, call_tree.self_time)
1191
+ assert_equal(840.0, call_tree.children_time)
1192
+
1193
+ call_tree = method.call_trees.callees[2]
1194
+ assert_equal('Allocator#make_strings', call_tree.target.full_name)
1195
+ assert_equal(160.0, call_tree.total_time)
1196
+ assert_equal(0.0, call_tree.wait_time)
1197
+ assert_equal(40, call_tree.self_time)
1198
+ assert_equal(120.0, call_tree.children_time)
1199
+
1200
+ # Method 3
1201
+ method = methods[3]
1202
+ assert_equal('Class#new', method.full_name)
1203
+ assert_equal(1360.0, method.total_time)
1204
+ assert_equal(0.0, method.wait_time)
1205
+ assert_equal(1320.0, method.self_time)
1206
+ assert_equal(40.0, method.children_time)
1207
+
1208
+ assert_equal(4, method.call_trees.callers.length)
1209
+ call_tree = method.call_trees.callers[0]
1210
+ assert_equal('MeasureMemoryTraceTest#test_memory', call_tree.parent.target.full_name)
1211
+ assert_equal(40.0, call_tree.total_time)
1212
+ assert_equal(0.0, call_tree.wait_time)
1213
+ assert_equal(40.0, call_tree.self_time)
1214
+ assert_equal(0.0, call_tree.children_time)
1215
+
1216
+ call_tree = method.call_trees.callers[1]
1217
+ assert_equal('Integer#times', call_tree.parent.target.full_name)
1218
+ assert_equal(400.0, call_tree.total_time)
1219
+ assert_equal(0.0, call_tree.wait_time)
1220
+ assert_equal(400.0, call_tree.self_time)
1221
+ assert_equal(0.0, call_tree.children_time)
1222
+
1223
+ call_tree = method.call_trees.callers[2]
1224
+ assert_equal('Allocator#make_hashes', call_tree.parent.target.full_name)
1225
+ assert_equal(840.0, call_tree.total_time)
1226
+ assert_equal(0.0, call_tree.wait_time)
1227
+ assert_equal(840.0, call_tree.self_time)
1228
+ assert_equal(0.0, call_tree.children_time)
1229
+
1230
+ call_tree = method.call_trees.callers[3]
1231
+ assert_equal('Allocator#make_strings', call_tree.parent.target.full_name)
1232
+ assert_equal(80.0, call_tree.total_time)
1233
+ assert_equal(0.0, call_tree.wait_time)
1234
+ assert_equal(40.0, call_tree.self_time)
1235
+ assert_equal(40.0, call_tree.children_time)
1236
+
1237
+ assert_equal(4, method.call_trees.callees.length)
1238
+ call_tree = method.call_trees.callees[0]
1239
+ assert_equal('BasicObject#initialize', call_tree.target.full_name)
1240
+ assert_equal(0.0, call_tree.total_time)
1241
+ assert_equal(0.0, call_tree.wait_time)
1242
+ assert_equal(0.0, call_tree.self_time)
1243
+ assert_equal(0.0, call_tree.children_time)
1244
+
1245
+ call_tree = method.call_trees.callees[1]
1246
+ assert_equal('Array#initialize', call_tree.target.full_name)
1247
+ assert_equal(0.0, call_tree.total_time)
1248
+ assert_equal(0.0, call_tree.wait_time)
1249
+ assert_equal(0.0, call_tree.self_time)
1250
+ assert_equal(0.0, call_tree.children_time)
1251
+
1252
+ call_tree = method.call_trees.callees[2]
1253
+ assert_equal('Hash#initialize', call_tree.target.full_name)
1254
+ assert_equal(0.0, call_tree.total_time)
1255
+ assert_equal(0.0, call_tree.wait_time)
1256
+ assert_equal(0.0, call_tree.self_time)
1257
+ assert_equal(0.0, call_tree.children_time)
1258
+
1259
+ call_tree = method.call_trees.callees[3]
1260
+ assert_equal('String#initialize', call_tree.target.full_name)
1261
+ assert_equal(40.0, call_tree.total_time)
1262
+ assert_equal(0.0, call_tree.wait_time)
1263
+ assert_equal(40.0, call_tree.self_time)
1264
+ assert_equal(0.0, call_tree.children_time)
1265
+
1266
+ # Method 4
1267
+ method = methods[4]
1268
+ assert_equal('Allocator#make_hashes', method.full_name)
1269
+ assert_equal(840.0, method.total_time)
1270
+ assert_equal(0.0, method.wait_time)
1271
+ assert_equal(0.0, method.self_time)
1272
+ assert_equal(840.0, method.children_time)
1273
+
1274
+ assert_equal(1, method.call_trees.callers.length)
1275
+ call_tree = method.call_trees.callers[0]
1276
+ assert_equal('Allocator#internal_run', call_tree.parent.target.full_name)
1277
+ assert_equal(840.0, call_tree.total_time)
1278
+ assert_equal(0.0, call_tree.wait_time)
1279
+ assert_equal(0.0, call_tree.self_time)
1280
+ assert_equal(840.0, call_tree.children_time)
1281
+
1282
+ assert_equal(1, method.call_trees.callees.length)
1283
+ call_tree = method.call_trees.callees[0]
1284
+ assert_equal('Class#new', call_tree.target.full_name)
1285
+ assert_equal(840.0, call_tree.total_time)
1286
+ assert_equal(0.0, call_tree.wait_time)
1287
+ assert_equal(840.0, call_tree.self_time)
1288
+ assert_equal(0.0, call_tree.children_time)
1289
+
1290
+ # Method 5
1291
+ method = methods[5]
1292
+ assert_equal('Allocator#make_arrays', method.full_name)
1293
+ assert_equal(400.0, method.total_time)
1294
+ assert_equal(0.0, method.wait_time)
1295
+ assert_equal(0.0, method.self_time)
1296
+ assert_equal(400.0, method.children_time)
1297
+
1298
+ assert_equal(1, method.call_trees.callers.length)
1299
+ call_tree = method.call_trees.callers[0]
1300
+ assert_equal('Allocator#internal_run', call_tree.parent.target.full_name)
1301
+ assert_equal(400.0, call_tree.total_time)
1302
+ assert_equal(0.0, call_tree.wait_time)
1303
+ assert_equal(0.0, call_tree.self_time)
1304
+ assert_equal(400.0, call_tree.children_time)
1305
+
1306
+ assert_equal(1, method.call_trees.callees.length)
1307
+ call_tree = method.call_trees.callees[0]
1308
+ assert_equal('Integer#times', call_tree.target.full_name)
1309
+ assert_equal(400.0, call_tree.total_time)
1310
+ assert_equal(0.0, call_tree.wait_time)
1311
+ assert_equal(0.0, call_tree.self_time)
1312
+ assert_equal(400.0, call_tree.children_time)
1313
+
1314
+ # Method 6
1315
+ method = methods[6]
1316
+ assert_equal('Integer#times', method.full_name)
1317
+ assert_equal(400.0, method.total_time)
1318
+ assert_equal(0.0, method.wait_time)
1319
+ assert_equal(0.0, method.self_time)
1320
+ assert_equal(400.0, method.children_time)
1321
+
1322
+ assert_equal(1, method.call_trees.callers.length)
1323
+ call_tree = method.call_trees.callers[0]
1324
+ assert_equal('Allocator#make_arrays', call_tree.parent.target.full_name)
1325
+ assert_equal(400.0, call_tree.total_time)
1326
+ assert_equal(0.0, call_tree.wait_time)
1327
+ assert_equal(0.0, call_tree.self_time)
1328
+ assert_equal(400.0, call_tree.children_time)
1329
+
1330
+ assert_equal(1, method.call_trees.callees.length)
1331
+ call_tree = method.call_trees.callees[0]
1332
+ assert_equal('Class#new', call_tree.target.full_name)
1333
+ assert_equal(400.0, call_tree.total_time)
1334
+ assert_equal(0.0, call_tree.wait_time)
1335
+ assert_equal(400.0, call_tree.self_time)
1336
+ assert_equal(0.0, call_tree.children_time)
1337
+
1338
+ # Method 7
1339
+ method = methods[7]
1340
+ assert_equal('Allocator#make_strings', method.full_name)
1341
+ assert_equal(160.0, method.total_time)
1342
+ assert_equal(0.0, method.wait_time)
1343
+ assert_equal(40.0, method.self_time)
1344
+ assert_equal(120.0, method.children_time)
1345
+
1346
+ assert_equal(1, method.call_trees.callers.length)
1347
+ call_tree = method.call_trees.callers[0]
1348
+ assert_equal('Allocator#internal_run', call_tree.parent.target.full_name)
1349
+ assert_equal(160.0, call_tree.total_time)
1350
+ assert_equal(0.0, call_tree.wait_time)
1351
+ assert_equal(40.0, call_tree.self_time)
1352
+ assert_equal(120.0, call_tree.children_time)
1353
+
1354
+ assert_equal(2, method.call_trees.callees.length)
1355
+ call_tree = method.call_trees.callees[0]
1356
+ assert_equal('String#*', call_tree.target.full_name)
1357
+ assert_equal(40.0, call_tree.total_time)
1358
+ assert_equal(0.0, call_tree.wait_time)
1359
+ assert_equal(40.0, call_tree.self_time)
1360
+ assert_equal(0.0, call_tree.children_time)
1361
+
1362
+ call_tree = method.call_trees.callees[1]
1363
+ assert_equal('Class#new', call_tree.target.full_name)
1364
+ assert_equal(80.0, call_tree.total_time)
1365
+ assert_equal(0.0, call_tree.wait_time)
1366
+ assert_equal(40.0, call_tree.self_time)
1367
+ assert_equal(40.0, call_tree.children_time)
1368
+
1369
+ # Method 8
1370
+ method = methods[8]
1371
+ assert_equal('String#*', method.full_name)
1372
+ assert_equal(40.0, method.total_time)
1373
+ assert_equal(0.0, method.wait_time)
1374
+ assert_equal(40.0, method.self_time)
1375
+ assert_equal(0.0, method.children_time)
1376
+
1377
+ assert_equal(1, method.call_trees.callers.length)
1378
+ call_tree = method.call_trees.callers[0]
1379
+ assert_equal('Allocator#make_strings', call_tree.parent.target.full_name)
1380
+ assert_equal(40.0, call_tree.total_time)
1381
+ assert_equal(0.0, call_tree.wait_time)
1382
+ assert_equal(40.0, call_tree.self_time)
1383
+ assert_equal(0.0, call_tree.children_time)
1384
+
1385
+ assert_equal(0.0, method.call_trees.callees.length)
1386
+
1387
+ # Method 9
1388
+ method = methods[9]
1389
+ assert_equal('String#initialize', method.full_name)
1390
+ assert_equal(40.0, method.total_time)
1391
+ assert_equal(0.0, method.wait_time)
1392
+ assert_equal(40.0, method.self_time)
1393
+ assert_equal(0.0, method.children_time)
1394
+
1395
+ assert_equal(1, method.call_trees.callers.length)
1396
+ call_tree = method.call_trees.callers[0]
1397
+ assert_equal('Class#new', call_tree.parent.target.full_name)
1398
+ assert_equal(40.0, call_tree.total_time)
1399
+ assert_equal(0.0, call_tree.wait_time)
1400
+ assert_equal(40.0, call_tree.self_time)
1401
+ assert_equal(0.0, call_tree.children_time)
1402
+
1403
+ assert_equal(0.0, method.call_trees.callees.length)
1404
+
1405
+ # Method 10
1406
+ method = methods[10]
1407
+ assert_equal('BasicObject#initialize', method.full_name)
1408
+ assert_equal(0.0, method.total_time)
1409
+ assert_equal(0.0, method.wait_time)
1410
+ assert_equal(0.0, method.self_time)
1411
+ assert_equal(0.0, method.children_time)
1412
+
1413
+ assert_equal(1, method.call_trees.callers.length)
1414
+ call_tree = method.call_trees.callers[0]
1415
+ assert_equal('Class#new', call_tree.parent.target.full_name)
1416
+ assert_equal(0.0, call_tree.total_time)
1417
+ assert_equal(0.0, call_tree.wait_time)
1418
+ assert_equal(0.0, call_tree.self_time)
1419
+ assert_equal(0.0, call_tree.children_time)
1420
+
1421
+ assert_equal(0.0, method.call_trees.callees.length)
1422
+
1423
+ # Method 11
1424
+ method = methods[11]
1425
+ assert_equal('Hash#initialize', method.full_name)
1426
+ assert_equal(0.0, method.total_time)
1427
+ assert_equal(0.0, method.wait_time)
1428
+ assert_equal(0.0, method.self_time)
1429
+ assert_equal(0.0, method.children_time)
1430
+
1431
+ assert_equal(1, method.call_trees.callers.length)
1432
+ call_tree = method.call_trees.callers[0]
1433
+ assert_equal('Class#new', call_tree.parent.target.full_name)
1434
+ assert_equal(0.0, call_tree.total_time)
1435
+ assert_equal(0.0, call_tree.wait_time)
1436
+ assert_equal(0.0, call_tree.self_time)
1437
+ assert_equal(0.0, call_tree.children_time)
1438
+
1439
+ assert_equal(0.0, method.call_trees.callees.length)
1440
+
1441
+ # Method 12
1442
+ method = methods[12]
1443
+ assert_equal('Array#initialize', method.full_name)
1444
+ assert_equal(0.0, method.total_time)
1445
+ assert_equal(0.0, method.wait_time)
1446
+ assert_equal(0.0, method.self_time)
1447
+ assert_equal(0.0, method.children_time)
1448
+
1449
+ assert_equal(1, method.call_trees.callers.length)
1450
+ call_tree = method.call_trees.callers[0]
1451
+ assert_equal('Class#new', call_tree.parent.target.full_name)
1452
+ assert_equal(0.0, call_tree.total_time)
1453
+ assert_equal(0.0, call_tree.wait_time)
1454
+ assert_equal(0.0, call_tree.self_time)
1455
+ assert_equal(0.0, call_tree.children_time)
1456
+
1098
1457
  assert_equal(0.0, method.call_trees.callees.length)
1099
1458
  end
1100
1459
  end