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.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +608 -0
  3. data/LICENSE +25 -0
  4. data/README.md +5 -0
  5. data/Rakefile +98 -0
  6. data/bin/ruby-prof +328 -0
  7. data/bin/ruby-prof-check-trace +45 -0
  8. data/ext/ruby_prof/extconf.rb +22 -0
  9. data/ext/ruby_prof/rp_aggregate_call_tree.c +59 -0
  10. data/ext/ruby_prof/rp_aggregate_call_tree.h +13 -0
  11. data/ext/ruby_prof/rp_allocation.c +287 -0
  12. data/ext/ruby_prof/rp_allocation.h +31 -0
  13. data/ext/ruby_prof/rp_call_tree.c +367 -0
  14. data/ext/ruby_prof/rp_call_tree.h +43 -0
  15. data/ext/ruby_prof/rp_call_trees.c +288 -0
  16. data/ext/ruby_prof/rp_call_trees.h +28 -0
  17. data/ext/ruby_prof/rp_measure_allocations.c +47 -0
  18. data/ext/ruby_prof/rp_measure_memory.c +46 -0
  19. data/ext/ruby_prof/rp_measure_process_time.c +66 -0
  20. data/ext/ruby_prof/rp_measure_wall_time.c +64 -0
  21. data/ext/ruby_prof/rp_measurement.c +237 -0
  22. data/ext/ruby_prof/rp_measurement.h +50 -0
  23. data/ext/ruby_prof/rp_method.c +491 -0
  24. data/ext/ruby_prof/rp_method.h +62 -0
  25. data/ext/ruby_prof/rp_profile.c +915 -0
  26. data/ext/ruby_prof/rp_profile.h +35 -0
  27. data/ext/ruby_prof/rp_stack.c +212 -0
  28. data/ext/ruby_prof/rp_stack.h +53 -0
  29. data/ext/ruby_prof/rp_thread.c +362 -0
  30. data/ext/ruby_prof/rp_thread.h +39 -0
  31. data/ext/ruby_prof/ruby_prof.c +52 -0
  32. data/ext/ruby_prof/ruby_prof.h +26 -0
  33. data/ext/ruby_prof/vc/ruby_prof.sln +39 -0
  34. data/ext/ruby_prof/vc/ruby_prof.vcxproj +160 -0
  35. data/lib/3.1/ruby_prof.so +0 -0
  36. data/lib/ruby-prof/assets/call_stack_printer.html.erb +711 -0
  37. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  38. data/lib/ruby-prof/assets/graph_printer.html.erb +355 -0
  39. data/lib/ruby-prof/call_tree.rb +57 -0
  40. data/lib/ruby-prof/call_tree_visitor.rb +36 -0
  41. data/lib/ruby-prof/compatibility.rb +99 -0
  42. data/lib/ruby-prof/exclude_common_methods.rb +198 -0
  43. data/lib/ruby-prof/measurement.rb +17 -0
  44. data/lib/ruby-prof/method_info.rb +78 -0
  45. data/lib/ruby-prof/printers/abstract_printer.rb +137 -0
  46. data/lib/ruby-prof/printers/call_info_printer.rb +53 -0
  47. data/lib/ruby-prof/printers/call_stack_printer.rb +180 -0
  48. data/lib/ruby-prof/printers/call_tree_printer.rb +147 -0
  49. data/lib/ruby-prof/printers/dot_printer.rb +132 -0
  50. data/lib/ruby-prof/printers/flat_printer.rb +53 -0
  51. data/lib/ruby-prof/printers/graph_html_printer.rb +63 -0
  52. data/lib/ruby-prof/printers/graph_printer.rb +113 -0
  53. data/lib/ruby-prof/printers/multi_printer.rb +127 -0
  54. data/lib/ruby-prof/profile.rb +37 -0
  55. data/lib/ruby-prof/rack.rb +95 -0
  56. data/lib/ruby-prof/task.rb +147 -0
  57. data/lib/ruby-prof/thread.rb +20 -0
  58. data/lib/ruby-prof/version.rb +3 -0
  59. data/lib/ruby-prof.rb +52 -0
  60. data/lib/unprof.rb +10 -0
  61. data/ruby-prof.gemspec +64 -0
  62. data/test/abstract_printer_test.rb +26 -0
  63. data/test/alias_test.rb +122 -0
  64. data/test/basic_test.rb +43 -0
  65. data/test/call_tree_visitor_test.rb +32 -0
  66. data/test/call_trees_test.rb +66 -0
  67. data/test/duplicate_names_test.rb +32 -0
  68. data/test/dynamic_method_test.rb +67 -0
  69. data/test/enumerable_test.rb +21 -0
  70. data/test/exceptions_test.rb +24 -0
  71. data/test/exclude_methods_test.rb +151 -0
  72. data/test/exclude_threads_test.rb +53 -0
  73. data/test/fiber_test.rb +129 -0
  74. data/test/gc_test.rb +100 -0
  75. data/test/inverse_call_tree_test.rb +175 -0
  76. data/test/line_number_test.rb +158 -0
  77. data/test/marshal_test.rb +145 -0
  78. data/test/measure_allocations.rb +26 -0
  79. data/test/measure_allocations_test.rb +333 -0
  80. data/test/measure_memory_test.rb +688 -0
  81. data/test/measure_process_time_test.rb +1614 -0
  82. data/test/measure_times.rb +56 -0
  83. data/test/measure_wall_time_test.rb +426 -0
  84. data/test/multi_printer_test.rb +71 -0
  85. data/test/no_method_class_test.rb +15 -0
  86. data/test/pause_resume_test.rb +175 -0
  87. data/test/prime.rb +54 -0
  88. data/test/prime_script.rb +6 -0
  89. data/test/printer_call_stack_test.rb +27 -0
  90. data/test/printer_call_tree_test.rb +30 -0
  91. data/test/printer_flat_test.rb +99 -0
  92. data/test/printer_graph_html_test.rb +59 -0
  93. data/test/printer_graph_test.rb +40 -0
  94. data/test/printers_test.rb +141 -0
  95. data/test/printing_recursive_graph_test.rb +81 -0
  96. data/test/profile_test.rb +16 -0
  97. data/test/rack_test.rb +93 -0
  98. data/test/recursive_test.rb +430 -0
  99. data/test/singleton_test.rb +38 -0
  100. data/test/stack_printer_test.rb +64 -0
  101. data/test/start_stop_test.rb +109 -0
  102. data/test/test_helper.rb +13 -0
  103. data/test/thread_test.rb +144 -0
  104. data/test/unique_call_path_test.rb +136 -0
  105. data/test/yarv_test.rb +60 -0
  106. metadata +187 -0
@@ -0,0 +1,333 @@
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 MeasureAllocationsTraceTest < TestCase
8
+ def setup
9
+ RubyProf::measure_mode = RubyProf::ALLOCATIONS
10
+ end
11
+
12
+ def test_allocations_mode
13
+ RubyProf::measure_mode = RubyProf::ALLOCATIONS
14
+ assert_equal(RubyProf::ALLOCATIONS, RubyProf::measure_mode)
15
+ end
16
+
17
+ def test_allocations
18
+ result = RubyProf.profile(:track_allocations => true) do
19
+ allocator = Allocator.new
20
+ allocator.run
21
+ end
22
+
23
+ thread = result.threads.first
24
+ assert_in_delta(20, thread.total_time, 1)
25
+
26
+ methods = result.threads.first.methods.sort.reverse
27
+ assert_equal(12, methods.length)
28
+
29
+ # Method 0
30
+ method = methods[0]
31
+ assert_equal('MeasureAllocationsTraceTest#test_allocations', method.full_name)
32
+ assert_in_delta(20, method.total_time, 1)
33
+ assert_equal(0, method.wait_time)
34
+ assert_equal(0, method.self_time)
35
+ assert_in_delta(20, method.children_time, 1)
36
+
37
+ assert_equal(0, method.call_trees.callers.length)
38
+
39
+ assert_equal(2, method.call_trees.callees.length)
40
+ call_tree = method.call_trees.callees[0]
41
+ assert_equal('Class#new', call_tree.target.full_name)
42
+ assert_equal(1, call_tree.total_time)
43
+ assert_equal(0, call_tree.wait_time)
44
+ assert_equal(1, call_tree.self_time)
45
+ assert_equal(0, call_tree.children_time)
46
+
47
+ call_tree = method.call_trees.callees[1]
48
+ assert_equal('Allocator#run', call_tree.target.full_name)
49
+ assert_equal(19, call_tree.total_time)
50
+ assert_equal(0, call_tree.wait_time)
51
+ assert_equal(0, call_tree.self_time)
52
+ assert_equal(19, call_tree.children_time)
53
+
54
+ # Method 1
55
+ method = methods[1]
56
+ assert_equal('Allocator#run',method.full_name)
57
+ assert_equal(19, method.total_time)
58
+ assert_equal(0, method.wait_time)
59
+ assert_equal(0, method.self_time)
60
+ assert_equal(19, method.children_time)
61
+
62
+ assert_equal(1, method.call_trees.callers.length)
63
+ call_tree = method.call_trees.callers[0]
64
+ assert_equal('MeasureAllocationsTraceTest#test_allocations', call_tree.parent.target.full_name)
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(3, method.call_trees.callees.length)
71
+ call_tree = method.call_trees.callees[0]
72
+ assert_equal('Allocator#make_arrays', call_tree.target.full_name)
73
+ assert_equal(10, call_tree.total_time)
74
+ assert_equal(0, call_tree.wait_time)
75
+ assert_equal(0, call_tree.self_time)
76
+ assert_equal(10, call_tree.children_time)
77
+
78
+ call_tree = method.call_trees.callees[1]
79
+ assert_equal('Allocator#make_hashes', call_tree.target.full_name)
80
+ assert_equal(5, call_tree.total_time)
81
+ assert_equal(0, call_tree.wait_time)
82
+ assert_equal(0, call_tree.self_time)
83
+ assert_equal(5, call_tree.children_time)
84
+
85
+ call_tree = method.call_trees.callees[2]
86
+ assert_equal('Allocator#make_strings', call_tree.target.full_name)
87
+ assert_equal(4, call_tree.total_time)
88
+ assert_equal(0, call_tree.wait_time)
89
+ assert_equal(1, call_tree.self_time)
90
+ assert_equal(3, call_tree.children_time)
91
+
92
+ # Method 2
93
+ method = methods[2]
94
+ assert_equal('Class#new', method.full_name)
95
+ assert_equal(18, method.total_time)
96
+ assert_equal(0, method.wait_time)
97
+ assert_equal(17, method.self_time)
98
+ assert_equal(1, method.children_time)
99
+
100
+ assert_equal(4, method.call_trees.callers.length)
101
+ call_tree = method.call_trees.callers[0]
102
+ assert_equal('MeasureAllocationsTraceTest#test_allocations', call_tree.parent.target.full_name)
103
+ assert_equal(1, call_tree.total_time)
104
+ assert_equal(0, call_tree.wait_time)
105
+ assert_equal(1, call_tree.self_time)
106
+ assert_equal(0, call_tree.children_time)
107
+
108
+ call_tree = method.call_trees.callers[1]
109
+ assert_equal('Integer#times', call_tree.parent.target.full_name)
110
+ assert_equal(10, call_tree.total_time)
111
+ assert_equal(0, call_tree.wait_time)
112
+ assert_equal(10, call_tree.self_time)
113
+ assert_equal(0, call_tree.children_time)
114
+
115
+ call_tree = method.call_trees.callers[2]
116
+ assert_equal('Allocator#make_hashes', call_tree.parent.target.full_name)
117
+ assert_equal(5, call_tree.total_time)
118
+ assert_equal(0, call_tree.wait_time)
119
+ assert_equal(5, call_tree.self_time)
120
+ assert_equal(0, call_tree.children_time)
121
+
122
+ call_tree = method.call_trees.callers[3]
123
+ assert_equal('Allocator#make_strings', call_tree.parent.target.full_name)
124
+ assert_equal(2, call_tree.total_time)
125
+ assert_equal(0, call_tree.wait_time)
126
+ assert_equal(1, call_tree.self_time)
127
+ assert_equal(1, call_tree.children_time)
128
+
129
+ assert_equal(4, method.call_trees.callees.length)
130
+ call_tree = method.call_trees.callees[0]
131
+ assert_equal('BasicObject#initialize', call_tree.target.full_name)
132
+ assert_equal(0, call_tree.total_time)
133
+ assert_equal(0, call_tree.wait_time)
134
+ assert_equal(0, call_tree.self_time)
135
+ assert_equal(0, call_tree.children_time)
136
+
137
+ call_tree = method.call_trees.callees[1]
138
+ assert_equal('Array#initialize', call_tree.target.full_name)
139
+ assert_equal(0, call_tree.total_time)
140
+ assert_equal(0, call_tree.wait_time)
141
+ assert_equal(0, call_tree.self_time)
142
+ assert_equal(0, call_tree.children_time)
143
+
144
+ call_tree = method.call_trees.callees[2]
145
+ assert_equal('Hash#initialize', call_tree.target.full_name)
146
+ assert_equal(0, call_tree.total_time)
147
+ assert_equal(0, call_tree.wait_time)
148
+ assert_equal(0, call_tree.self_time)
149
+ assert_equal(0, call_tree.children_time)
150
+
151
+ call_tree = method.call_trees.callees[3]
152
+ assert_equal('String#initialize', call_tree.target.full_name)
153
+ assert_equal(1, call_tree.total_time)
154
+ assert_equal(0, call_tree.wait_time)
155
+ assert_equal(1, call_tree.self_time)
156
+ assert_equal(0, call_tree.children_time)
157
+
158
+ # Method 3
159
+ method = methods[3]
160
+ assert_equal('Allocator#make_arrays', method.full_name)
161
+ assert_equal(10, method.total_time)
162
+ assert_equal(0, method.wait_time)
163
+ assert_equal(0, method.self_time)
164
+ assert_equal(10, method.children_time)
165
+
166
+ assert_equal(1, method.call_trees.callers.length)
167
+ call_tree = method.call_trees.callers[0]
168
+ assert_equal('Allocator#run', call_tree.parent.target.full_name)
169
+ assert_equal(10, call_tree.total_time)
170
+ assert_equal(0, call_tree.wait_time)
171
+ assert_equal(0, call_tree.self_time)
172
+ assert_equal(10, call_tree.children_time)
173
+
174
+ assert_equal(1, method.call_trees.callees.length)
175
+ call_tree = method.call_trees.callees[0]
176
+ assert_equal('Integer#times', call_tree.target.full_name)
177
+ assert_equal(10, call_tree.total_time)
178
+ assert_equal(0, call_tree.wait_time)
179
+ assert_equal(0, call_tree.self_time)
180
+ assert_equal(10, call_tree.children_time)
181
+
182
+ # Method 4
183
+ method = methods[4]
184
+ assert_equal('Integer#times', method.full_name)
185
+ assert_equal(10, method.total_time)
186
+ assert_equal(0, method.wait_time)
187
+ assert_equal(0, method.self_time)
188
+ assert_equal(10, method.children_time)
189
+
190
+ assert_equal(1, method.call_trees.callers.length)
191
+ call_tree = method.call_trees.callers[0]
192
+ assert_equal('Allocator#make_arrays', call_tree.parent.target.full_name)
193
+ assert_equal(10, call_tree.total_time)
194
+ assert_equal(0, call_tree.wait_time)
195
+ assert_equal(0, call_tree.self_time)
196
+ assert_equal(10, call_tree.children_time)
197
+
198
+ assert_equal(1, method.call_trees.callees.length)
199
+ call_tree = method.call_trees.callees[0]
200
+ assert_equal('Class#new', call_tree.target.full_name)
201
+ assert_equal(10, call_tree.total_time)
202
+ assert_equal(0, call_tree.wait_time)
203
+ assert_equal(10, call_tree.self_time)
204
+ assert_equal(0, call_tree.children_time)
205
+
206
+ # Method 5
207
+ method = methods[5]
208
+ assert_equal('Allocator#make_hashes', method.full_name)
209
+ assert_equal(5, method.total_time)
210
+ assert_equal(0, method.wait_time)
211
+ assert_equal(0, method.self_time)
212
+ assert_equal(5, method.children_time)
213
+
214
+ assert_equal(1, method.call_trees.callers.length)
215
+ call_tree = method.call_trees.callers[0]
216
+ assert_equal('Allocator#run', call_tree.parent.target.full_name)
217
+ assert_equal(5, call_tree.total_time)
218
+ assert_equal(0, call_tree.wait_time)
219
+ assert_equal(0, call_tree.self_time)
220
+ assert_equal(5, call_tree.children_time)
221
+
222
+ assert_equal(1, method.call_trees.callees.length)
223
+ call_tree = method.call_trees.callees[0]
224
+ assert_equal('Class#new', call_tree.target.full_name)
225
+ assert_equal(5, call_tree.total_time)
226
+ assert_equal(0, call_tree.wait_time)
227
+ assert_equal(5, call_tree.self_time)
228
+ assert_equal(0, call_tree.children_time)
229
+
230
+ # Method 6
231
+ method = methods[6]
232
+ assert_equal('Allocator#make_strings', method.full_name)
233
+ assert_equal(4, method.total_time)
234
+ assert_equal(0, method.wait_time)
235
+ assert_equal(1, method.self_time)
236
+ assert_equal(3, method.children_time)
237
+
238
+ assert_equal(1, method.call_trees.callers.length)
239
+ call_tree = method.call_trees.callers[0]
240
+ assert_equal('Allocator#run', call_tree.parent.target.full_name)
241
+ assert_equal(4, call_tree.total_time)
242
+ assert_equal(0, call_tree.wait_time)
243
+ assert_equal(1, call_tree.self_time)
244
+ assert_equal(3, call_tree.children_time)
245
+
246
+ assert_equal(2, method.call_trees.callees.length)
247
+ call_tree = method.call_trees.callees[0]
248
+ assert_equal('String#*', call_tree.target.full_name)
249
+ assert_equal(1, call_tree.total_time)
250
+ assert_equal(0, call_tree.wait_time)
251
+ assert_equal(1, call_tree.self_time)
252
+ assert_equal(0, call_tree.children_time)
253
+
254
+ call_tree = method.call_trees.callees[1]
255
+ assert_equal('Class#new', call_tree.target.full_name)
256
+ assert_equal(2, call_tree.total_time)
257
+ assert_equal(0, call_tree.wait_time)
258
+ assert_equal(1, call_tree.self_time)
259
+ assert_equal(1, call_tree.children_time)
260
+
261
+ # Method 7
262
+ method = methods[7]
263
+ assert_equal('String#*', method.full_name)
264
+ assert_equal(1, method.total_time)
265
+ assert_equal(0, method.wait_time)
266
+ assert_equal(1, method.self_time)
267
+ assert_equal(0, method.children_time)
268
+
269
+ assert_equal(1, method.call_trees.callers.length)
270
+ call_tree = method.call_trees.callers[0]
271
+ assert_equal('Allocator#make_strings', call_tree.parent.target.full_name)
272
+ assert_equal(1, call_tree.total_time)
273
+ assert_equal(0, call_tree.wait_time)
274
+ assert_equal(1, call_tree.self_time)
275
+ assert_equal(0, call_tree.children_time)
276
+
277
+ assert_equal(0, method.call_trees.callees.length)
278
+
279
+ # Method 8
280
+ method = methods[8]
281
+ assert_equal('String#initialize', method.full_name)
282
+ assert_equal(1, method.total_time)
283
+ assert_equal(0, method.wait_time)
284
+ assert_equal(1, method.self_time)
285
+ assert_equal(0, method.children_time)
286
+
287
+ assert_equal(1, method.call_trees.callers.length)
288
+ call_tree = method.call_trees.callers[0]
289
+ assert_equal('Class#new', call_tree.parent.target.full_name)
290
+ assert_equal(1, call_tree.total_time)
291
+ assert_equal(0, call_tree.wait_time)
292
+ assert_equal(1, call_tree.self_time)
293
+ assert_equal(0, call_tree.children_time)
294
+
295
+ assert_equal(0, method.call_trees.callees.length)
296
+
297
+ # Method 9
298
+ method = methods[9]
299
+ assert_equal('BasicObject#initialize', method.full_name)
300
+ assert_equal(0, method.total_time)
301
+ assert_equal(0, method.wait_time)
302
+ assert_equal(0, method.self_time)
303
+ assert_equal(0, method.children_time)
304
+
305
+ assert_equal(1, method.call_trees.callers.length)
306
+ call_tree = method.call_trees.callers[0]
307
+ assert_equal('Class#new', call_tree.parent.target.full_name)
308
+ assert_equal(0, call_tree.total_time)
309
+ assert_equal(0, call_tree.wait_time)
310
+ assert_equal(0, call_tree.self_time)
311
+ assert_equal(0, call_tree.children_time)
312
+
313
+ assert_equal(0, method.call_trees.callees.length)
314
+
315
+ # Method 10
316
+ method = methods[10]
317
+ assert_equal('Hash#initialize', method.full_name)
318
+ assert_equal(0, method.total_time)
319
+ assert_equal(0, method.wait_time)
320
+ assert_equal(0, method.self_time)
321
+ assert_equal(0, method.children_time)
322
+
323
+ assert_equal(1, method.call_trees.callers.length)
324
+ call_tree = method.call_trees.callers[0]
325
+ assert_equal('Class#new', call_tree.parent.target.full_name)
326
+ assert_equal(0, call_tree.total_time)
327
+ assert_equal(0, call_tree.wait_time)
328
+ assert_equal(0, call_tree.self_time)
329
+ assert_equal(0, call_tree.children_time)
330
+
331
+ assert_equal(0, method.call_trees.callees.length)
332
+ end
333
+ end