ruby-prof 0.13.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +579 -371
  3. data/LICENSE +24 -23
  4. data/README.rdoc +5 -433
  5. data/Rakefile +98 -110
  6. data/bin/ruby-prof +328 -329
  7. data/bin/ruby-prof-check-trace +45 -0
  8. data/ext/ruby_prof/extconf.rb +16 -59
  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 +369 -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 +50 -65
  18. data/ext/ruby_prof/rp_measure_memory.c +42 -73
  19. data/ext/ruby_prof/rp_measure_process_time.c +65 -71
  20. data/ext/ruby_prof/rp_measure_wall_time.c +64 -42
  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 -420
  24. data/ext/ruby_prof/rp_method.h +62 -57
  25. data/ext/ruby_prof/rp_profile.c +908 -0
  26. data/ext/ruby_prof/rp_profile.h +35 -0
  27. data/ext/ruby_prof/rp_stack.c +212 -128
  28. data/ext/ruby_prof/rp_stack.h +53 -51
  29. data/ext/ruby_prof/rp_thread.c +362 -268
  30. data/ext/ruby_prof/rp_thread.h +39 -27
  31. data/ext/ruby_prof/ruby_prof.c +52 -695
  32. data/ext/ruby_prof/ruby_prof.h +26 -55
  33. data/ext/ruby_prof/vc/ruby_prof.sln +28 -21
  34. data/ext/ruby_prof/vc/{ruby_prof_20.vcxproj → ruby_prof.vcxproj} +56 -8
  35. data/lib/ruby-prof.rb +52 -67
  36. data/lib/ruby-prof/assets/call_stack_printer.html.erb +710 -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 -169
  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 -131
  45. data/lib/ruby-prof/printers/abstract_printer.rb +137 -85
  46. data/lib/ruby-prof/printers/call_info_printer.rb +53 -41
  47. data/lib/ruby-prof/printers/call_stack_printer.rb +180 -773
  48. data/lib/ruby-prof/printers/call_tree_printer.rb +151 -92
  49. data/lib/ruby-prof/printers/dot_printer.rb +132 -132
  50. data/lib/ruby-prof/printers/flat_printer.rb +53 -69
  51. data/lib/ruby-prof/printers/graph_html_printer.rb +63 -255
  52. data/lib/ruby-prof/printers/graph_printer.rb +113 -116
  53. data/lib/ruby-prof/printers/multi_printer.rb +127 -56
  54. data/lib/ruby-prof/profile.rb +37 -77
  55. data/lib/ruby-prof/rack.rb +62 -15
  56. data/lib/ruby-prof/task.rb +147 -147
  57. data/lib/ruby-prof/thread.rb +10 -12
  58. data/lib/ruby-prof/version.rb +3 -0
  59. data/lib/unprof.rb +10 -10
  60. data/ruby-prof.gemspec +65 -61
  61. data/test/abstract_printer_test.rb +26 -0
  62. data/test/alias_test.rb +126 -0
  63. data/test/basic_test.rb +43 -128
  64. data/test/call_tree_visitor_test.rb +32 -0
  65. data/test/call_trees_test.rb +66 -0
  66. data/test/duplicate_names_test.rb +32 -32
  67. data/test/dynamic_method_test.rb +53 -74
  68. data/test/enumerable_test.rb +21 -16
  69. data/test/exceptions_test.rb +24 -16
  70. data/test/exclude_methods_test.rb +151 -0
  71. data/test/exclude_threads_test.rb +53 -54
  72. data/test/fiber_test.rb +129 -65
  73. data/test/gc_test.rb +90 -0
  74. data/test/inverse_call_tree_test.rb +175 -0
  75. data/test/line_number_test.rb +158 -71
  76. data/test/marshal_test.rb +113 -0
  77. data/test/measure_allocations.rb +30 -0
  78. data/test/measure_allocations_test.rb +375 -25
  79. data/test/measure_allocations_trace_test.rb +375 -0
  80. data/test/measure_memory_trace_test.rb +1101 -0
  81. data/test/measure_process_time_test.rb +785 -62
  82. data/test/measure_times.rb +56 -0
  83. data/test/measure_wall_time_test.rb +434 -254
  84. data/test/multi_printer_test.rb +71 -82
  85. data/test/no_method_class_test.rb +15 -15
  86. data/test/pause_resume_test.rb +175 -166
  87. data/test/prime.rb +54 -54
  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 -257
  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 +206 -215
  99. data/test/singleton_test.rb +38 -38
  100. data/test/stack_printer_test.rb +64 -78
  101. data/test/start_stop_test.rb +109 -112
  102. data/test/test_helper.rb +13 -115
  103. data/test/thread_test.rb +144 -178
  104. data/test/unique_call_path_test.rb +120 -224
  105. data/test/yarv_test.rb +56 -0
  106. metadata +77 -133
  107. data/doc/LICENSE.html +0 -155
  108. data/doc/README_rdoc.html +0 -648
  109. data/doc/Rack.html +0 -167
  110. data/doc/Rack/RubyProf.html +0 -319
  111. data/doc/RubyProf.html +0 -1000
  112. data/doc/RubyProf/AbstractPrinter.html +0 -580
  113. data/doc/RubyProf/AggregateCallInfo.html +0 -570
  114. data/doc/RubyProf/CallInfo.html +0 -512
  115. data/doc/RubyProf/CallInfoPrinter.html +0 -190
  116. data/doc/RubyProf/CallInfoVisitor.html +0 -332
  117. data/doc/RubyProf/CallStackPrinter.html +0 -1600
  118. data/doc/RubyProf/CallTreePrinter.html +0 -413
  119. data/doc/RubyProf/Cmd.html +0 -669
  120. data/doc/RubyProf/DotPrinter.html +0 -312
  121. data/doc/RubyProf/FlatPrinter.html +0 -229
  122. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +0 -267
  123. data/doc/RubyProf/GraphHtmlPrinter.html +0 -630
  124. data/doc/RubyProf/GraphPrinter.html +0 -209
  125. data/doc/RubyProf/MethodInfo.html +0 -713
  126. data/doc/RubyProf/MultiPrinter.html +0 -407
  127. data/doc/RubyProf/Profile.html +0 -821
  128. data/doc/RubyProf/ProfileTask.html +0 -532
  129. data/doc/RubyProf/Test.html +0 -578
  130. data/doc/RubyProf/Thread.html +0 -262
  131. data/doc/created.rid +0 -32
  132. data/doc/examples/flat_txt.html +0 -191
  133. data/doc/examples/graph_txt.html +0 -305
  134. data/doc/images/add.png +0 -0
  135. data/doc/images/brick.png +0 -0
  136. data/doc/images/brick_link.png +0 -0
  137. data/doc/images/bug.png +0 -0
  138. data/doc/images/bullet_black.png +0 -0
  139. data/doc/images/bullet_toggle_minus.png +0 -0
  140. data/doc/images/bullet_toggle_plus.png +0 -0
  141. data/doc/images/date.png +0 -0
  142. data/doc/images/delete.png +0 -0
  143. data/doc/images/find.png +0 -0
  144. data/doc/images/loadingAnimation.gif +0 -0
  145. data/doc/images/macFFBgHack.png +0 -0
  146. data/doc/images/package.png +0 -0
  147. data/doc/images/page_green.png +0 -0
  148. data/doc/images/page_white_text.png +0 -0
  149. data/doc/images/page_white_width.png +0 -0
  150. data/doc/images/plugin.png +0 -0
  151. data/doc/images/ruby.png +0 -0
  152. data/doc/images/tag_blue.png +0 -0
  153. data/doc/images/tag_green.png +0 -0
  154. data/doc/images/transparent.png +0 -0
  155. data/doc/images/wrench.png +0 -0
  156. data/doc/images/wrench_orange.png +0 -0
  157. data/doc/images/zoom.png +0 -0
  158. data/doc/index.html +0 -647
  159. data/doc/js/darkfish.js +0 -155
  160. data/doc/js/jquery.js +0 -18
  161. data/doc/js/navigation.js +0 -142
  162. data/doc/js/search.js +0 -94
  163. data/doc/js/search_index.js +0 -1
  164. data/doc/js/searcher.js +0 -228
  165. data/doc/rdoc.css +0 -543
  166. data/doc/table_of_contents.html +0 -462
  167. data/examples/empty.png +0 -0
  168. data/examples/flat.txt +0 -55
  169. data/examples/graph.dot +0 -106
  170. data/examples/graph.html +0 -823
  171. data/examples/graph.png +0 -0
  172. data/examples/graph.txt +0 -170
  173. data/examples/minus.png +0 -0
  174. data/examples/multi.flat.txt +0 -23
  175. data/examples/multi.graph.html +0 -906
  176. data/examples/multi.grind.dat +0 -194
  177. data/examples/multi.stack.html +0 -573
  178. data/examples/plus.png +0 -0
  179. data/examples/stack.html +0 -573
  180. data/ext/ruby_prof/rp_call_info.c +0 -407
  181. data/ext/ruby_prof/rp_call_info.h +0 -48
  182. data/ext/ruby_prof/rp_measure.c +0 -48
  183. data/ext/ruby_prof/rp_measure.h +0 -45
  184. data/ext/ruby_prof/rp_measure_cpu_time.c +0 -112
  185. data/ext/ruby_prof/rp_measure_gc_runs.c +0 -65
  186. data/ext/ruby_prof/rp_measure_gc_time.c +0 -57
  187. data/ext/ruby_prof/vc/ruby_prof_18.vcxproj +0 -108
  188. data/ext/ruby_prof/vc/ruby_prof_19.vcxproj +0 -110
  189. data/ext/ruby_prof/version.h +0 -7
  190. data/lib/ruby-prof/aggregate_call_info.rb +0 -72
  191. data/lib/ruby-prof/call_info.rb +0 -89
  192. data/lib/ruby-prof/call_info_visitor.rb +0 -44
  193. data/lib/ruby-prof/images/empty.png +0 -0
  194. data/lib/ruby-prof/images/minus.png +0 -0
  195. data/lib/ruby-prof/images/plus.png +0 -0
  196. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -57
  197. data/lib/ruby-prof/test.rb +0 -150
  198. data/test/aggregate_test.rb +0 -136
  199. data/test/call_info_test.rb +0 -78
  200. data/test/call_info_visitor_test.rb +0 -31
  201. data/test/exec_test.rb +0 -14
  202. data/test/measure_cpu_time_test.rb +0 -220
  203. data/test/measure_gc_runs_test.rb +0 -32
  204. data/test/measure_gc_time_test.rb +0 -36
  205. data/test/measure_memory_test.rb +0 -31
  206. data/test/method_elimination_test.rb +0 -84
  207. data/test/module_test.rb +0 -45
  208. data/test/stack_test.rb +0 -138
  209. data/test/test_suite.rb +0 -37
@@ -1,407 +0,0 @@
1
- /* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
- Please see the LICENSE file for copyright and distribution information */
3
-
4
- #include "ruby_prof.h"
5
-
6
- #define INITIAL_CALL_INFOS_SIZE 2
7
-
8
- VALUE cCallInfo;
9
-
10
-
11
- // Forward declarations
12
- st_table * call_info_table_create();
13
-
14
-
15
- /* ======= prof_call_info_t ========*/
16
- prof_call_info_t *
17
- prof_call_info_create(prof_method_t* method, prof_call_info_t* parent)
18
- {
19
- prof_call_info_t *result = ALLOC(prof_call_info_t);
20
- result->object = Qnil;
21
- result->target = method;
22
- result->parent = parent;
23
- result->call_infos = call_info_table_create();
24
- result->children = Qnil;
25
-
26
- result->called = 0;
27
- result->total_time = 0;
28
- result->self_time = 0;
29
- result->wait_time = 0;
30
- result->line = 0;
31
- return result;
32
- }
33
- static void
34
- prof_call_info_ruby_gc_free(prof_call_info_t *call_info)
35
- {
36
- /* Has this thread object been accessed by Ruby? If
37
- yes clean it up so to avoid a segmentation fault. */
38
- if (call_info->object != Qnil)
39
- {
40
- RDATA(call_info->object)->data = NULL;
41
- RDATA(call_info->object)->dfree = NULL;
42
- RDATA(call_info->object)->dmark = NULL;
43
- }
44
- call_info->object = Qnil;
45
- }
46
-
47
- static void
48
- prof_call_info_free(prof_call_info_t *call_info)
49
- {
50
- prof_call_info_ruby_gc_free(call_info);
51
- st_free_table(call_info->call_infos);
52
- xfree(call_info);
53
- }
54
-
55
- static void
56
- prof_call_info_mark(prof_call_info_t *call_info)
57
- {
58
- if (call_info->object)
59
- rb_gc_mark(call_info->object);
60
-
61
- if (call_info->children)
62
- rb_gc_mark(call_info->children);
63
-
64
- /* We don't mark the call info child table since that will be done
65
- via the appropriate method */
66
- }
67
-
68
- VALUE
69
- prof_call_info_wrap(prof_call_info_t *call_info)
70
- {
71
- if (call_info->object == Qnil)
72
- {
73
- call_info->object = Data_Wrap_Struct(cCallInfo, prof_call_info_mark, prof_call_info_ruby_gc_free, call_info);
74
- }
75
- return call_info->object;
76
- }
77
-
78
- static prof_call_info_t *
79
- prof_get_call_info(VALUE self)
80
- {
81
- /* Can't use Data_Get_Struct because that triggers the event hook
82
- ending up in endless recursion. */
83
- prof_call_info_t* result = DATA_PTR(self);
84
-
85
- if (!result)
86
- rb_raise(rb_eRuntimeError, "This RubyProf::CallInfo instance has already been freed, likely because its profile has been freed.");
87
-
88
- return result;
89
- }
90
-
91
- /* ======= Call Info Table ========*/
92
- st_table *
93
- call_info_table_create()
94
- {
95
- return st_init_table(&type_method_hash);
96
- }
97
-
98
- size_t
99
- call_info_table_insert(st_table *table, const prof_method_key_t *key, prof_call_info_t *val)
100
- {
101
- return st_insert(table, (st_data_t) key, (st_data_t) val);
102
- }
103
-
104
- prof_call_info_t *
105
- call_info_table_lookup(st_table *table, const prof_method_key_t *key)
106
- {
107
- st_data_t val;
108
- if (st_lookup(table, (st_data_t) key, &val))
109
- {
110
- return (prof_call_info_t *) val;
111
- }
112
- else
113
- {
114
- return NULL;
115
- }
116
- }
117
-
118
-
119
- /* ======= RubyProf::CallInfo ========*/
120
-
121
- /* Document-class: RubyProf::CallInfo
122
- RubyProf::CallInfo is a helper class used by RubyProf::MethodInfo
123
- to keep track of which child methods were called and how long
124
- they took to execute. */
125
-
126
-
127
- /* call-seq:
128
- called -> MethodInfo
129
-
130
- Returns the target method. */
131
- static VALUE
132
- prof_call_info_target(VALUE self)
133
- {
134
- /* Target is a pointer to a method_info - so we have to be careful
135
- about the GC. We will wrap the method_info but provide no
136
- free method so the underlying object is not freed twice! */
137
-
138
- prof_call_info_t *result = prof_get_call_info(self);
139
- return prof_method_wrap(result->target);
140
- }
141
-
142
- /* call-seq:
143
- called -> int
144
-
145
- Returns the total amount of times this method was called. */
146
- static VALUE
147
- prof_call_info_called(VALUE self)
148
- {
149
- prof_call_info_t *result = prof_get_call_info(self);
150
- return INT2NUM(result->called);
151
- }
152
-
153
- /* call-seq:
154
- called=n -> n
155
-
156
- Sets the call count to n. */
157
- static VALUE
158
- prof_call_info_set_called(VALUE self, VALUE called)
159
- {
160
- prof_call_info_t *result = prof_get_call_info(self);
161
- result->called = NUM2INT(called);
162
- return called;
163
- }
164
-
165
- /* call-seq:
166
- depth -> int
167
-
168
- returns the depth of this call info in the call graph */
169
- static VALUE
170
- prof_call_info_depth(VALUE self)
171
- {
172
- prof_call_info_t *result = prof_get_call_info(self);
173
- return rb_int_new(result->depth);
174
- }
175
-
176
- /* call-seq:
177
- line_no -> int
178
-
179
- returns the line number of the method */
180
- static VALUE
181
- prof_call_info_line(VALUE self)
182
- {
183
- prof_call_info_t *result = prof_get_call_info(self);
184
- return rb_int_new(result->line);
185
- }
186
-
187
- /* call-seq:
188
- total_time -> float
189
-
190
- Returns the total amount of time spent in this method and its children. */
191
- static VALUE
192
- prof_call_info_total_time(VALUE self)
193
- {
194
- prof_call_info_t *result = prof_get_call_info(self);
195
- return rb_float_new(result->total_time);
196
- }
197
-
198
- /* call-seq:
199
- add_total_time(call_info) -> nil
200
-
201
- adds total time time from call_info to self. */
202
- static VALUE
203
- prof_call_info_add_total_time(VALUE self, VALUE other)
204
- {
205
- prof_call_info_t *result = prof_get_call_info(self);
206
- prof_call_info_t *other_info = prof_get_call_info(other);
207
-
208
- result->total_time += other_info->total_time;
209
- return Qnil;
210
- }
211
-
212
- /* call-seq:
213
- self_time -> float
214
-
215
- Returns the total amount of time spent in this method. */
216
- static VALUE
217
- prof_call_info_self_time(VALUE self)
218
- {
219
- prof_call_info_t *result = prof_get_call_info(self);
220
-
221
- return rb_float_new(result->self_time);
222
- }
223
-
224
- /* call-seq:
225
- add_self_time(call_info) -> nil
226
-
227
- adds self time from call_info to self. */
228
- static VALUE
229
- prof_call_info_add_self_time(VALUE self, VALUE other)
230
- {
231
- prof_call_info_t *result = prof_get_call_info(self);
232
- prof_call_info_t *other_info = prof_get_call_info(other);
233
-
234
- result->self_time += other_info->self_time;
235
- return Qnil;
236
- }
237
-
238
- /* call-seq:
239
- wait_time -> float
240
-
241
- Returns the total amount of time this method waited for other threads. */
242
- static VALUE
243
- prof_call_info_wait_time(VALUE self)
244
- {
245
- prof_call_info_t *result = prof_get_call_info(self);
246
-
247
- return rb_float_new(result->wait_time);
248
- }
249
-
250
- /* call-seq:
251
- add_wait_time(call_info) -> nil
252
-
253
- adds wait time from call_info to self. */
254
-
255
- static VALUE
256
- prof_call_info_add_wait_time(VALUE self, VALUE other)
257
- {
258
- prof_call_info_t *result = prof_get_call_info(self);
259
- prof_call_info_t *other_info = prof_get_call_info(other);
260
-
261
- result->wait_time += other_info->wait_time;
262
- return Qnil;
263
- }
264
-
265
- /* call-seq:
266
- parent -> call_info
267
-
268
- Returns the call_infos parent call_info object (the method that called this method).*/
269
- static VALUE
270
- prof_call_info_parent(VALUE self)
271
- {
272
- prof_call_info_t *result = prof_get_call_info(self);
273
- if (result->parent)
274
- return prof_call_info_wrap(result->parent);
275
- else
276
- return Qnil;
277
- }
278
-
279
- /* call-seq:
280
- parent=new_parent -> new_parent
281
-
282
- Changes the parent of self to new_parent and returns it.*/
283
- static VALUE
284
- prof_call_info_set_parent(VALUE self, VALUE new_parent)
285
- {
286
- prof_call_info_t *result = prof_get_call_info(self);
287
- if (new_parent == Qnil)
288
- result->parent = NULL;
289
- else
290
- result->parent = prof_get_call_info(new_parent);
291
- return prof_call_info_parent(self);
292
- }
293
-
294
- static int
295
- prof_call_info_collect_children(st_data_t key, st_data_t value, st_data_t result)
296
- {
297
- prof_call_info_t *call_info = (prof_call_info_t *) value;
298
- VALUE arr = (VALUE) result;
299
- rb_ary_push(arr, prof_call_info_wrap(call_info));
300
- return ST_CONTINUE;
301
- }
302
-
303
- /* call-seq:
304
- children -> hash
305
-
306
- Returns an array of call info objects of methods that this method
307
- called (ie, children).*/
308
- static VALUE
309
- prof_call_info_children(VALUE self)
310
- {
311
- prof_call_info_t *call_info = prof_get_call_info(self);
312
- if (call_info->children == Qnil)
313
- {
314
- call_info->children = rb_ary_new();
315
- st_foreach(call_info->call_infos, prof_call_info_collect_children, call_info->children);
316
- }
317
- return call_info->children;
318
- }
319
-
320
- /* ======= Call Infos ========*/
321
- prof_call_infos_t*
322
- prof_call_infos_create()
323
- {
324
- prof_call_infos_t *result = ALLOC(prof_call_infos_t);
325
- result->start = ALLOC_N(prof_call_info_t*, INITIAL_CALL_INFOS_SIZE);
326
- result->end = result->start + INITIAL_CALL_INFOS_SIZE;
327
- result->ptr = result->start;
328
- result->object = Qnil;
329
- return result;
330
- }
331
-
332
- void
333
- prof_call_infos_mark(prof_call_infos_t *call_infos)
334
- {
335
- prof_call_info_t **call_info;
336
-
337
- if (call_infos->object)
338
- rb_gc_mark(call_infos->object);
339
-
340
- for(call_info=call_infos->start; call_info<call_infos->ptr; call_info++)
341
- {
342
- prof_call_info_mark(*call_info);
343
- }
344
- }
345
-
346
- void
347
- prof_call_infos_free(prof_call_infos_t *call_infos)
348
- {
349
- prof_call_info_t **call_info;
350
-
351
- for(call_info=call_infos->start; call_info<call_infos->ptr; call_info++)
352
- {
353
- prof_call_info_free(*call_info);
354
- }
355
- }
356
-
357
- void
358
- prof_add_call_info(prof_call_infos_t *call_infos, prof_call_info_t *call_info)
359
- {
360
- if (call_infos->ptr == call_infos->end)
361
- {
362
- size_t len = call_infos->ptr - call_infos->start;
363
- size_t new_capacity = (call_infos->end - call_infos->start) * 2;
364
- REALLOC_N(call_infos->start, prof_call_info_t*, new_capacity);
365
- call_infos->ptr = call_infos->start + len;
366
- call_infos->end = call_infos->start + new_capacity;
367
- }
368
- *call_infos->ptr = call_info;
369
- call_infos->ptr++;
370
- }
371
-
372
- VALUE
373
- prof_call_infos_wrap(prof_call_infos_t *call_infos)
374
- {
375
- if (call_infos->object == Qnil)
376
- {
377
- prof_call_info_t **i;
378
- call_infos->object = rb_ary_new();
379
- for(i=call_infos->start; i<call_infos->ptr; i++)
380
- {
381
- VALUE call_info = prof_call_info_wrap(*i);
382
- rb_ary_push(call_infos->object, call_info);
383
- }
384
- }
385
- return call_infos->object;
386
- }
387
-
388
- void rp_init_call_info()
389
- {
390
- /* CallInfo */
391
- cCallInfo = rb_define_class_under(mProf, "CallInfo", rb_cObject);
392
- rb_undef_method(CLASS_OF(cCallInfo), "new");
393
- rb_define_method(cCallInfo, "parent", prof_call_info_parent, 0);
394
- rb_define_method(cCallInfo, "parent=", prof_call_info_set_parent, 1);
395
- rb_define_method(cCallInfo, "children", prof_call_info_children, 0);
396
- rb_define_method(cCallInfo, "target", prof_call_info_target, 0);
397
- rb_define_method(cCallInfo, "called", prof_call_info_called, 0);
398
- rb_define_method(cCallInfo, "called=", prof_call_info_set_called, 1);
399
- rb_define_method(cCallInfo, "total_time", prof_call_info_total_time, 0);
400
- rb_define_method(cCallInfo, "add_total_time", prof_call_info_add_total_time, 1);
401
- rb_define_method(cCallInfo, "self_time", prof_call_info_self_time, 0);
402
- rb_define_method(cCallInfo, "add_self_time", prof_call_info_add_self_time, 1);
403
- rb_define_method(cCallInfo, "wait_time", prof_call_info_wait_time, 0);
404
- rb_define_method(cCallInfo, "add_wait_time", prof_call_info_add_wait_time, 1);
405
- rb_define_method(cCallInfo, "depth", prof_call_info_depth, 0);
406
- rb_define_method(cCallInfo, "line", prof_call_info_line, 0);
407
- }
@@ -1,48 +0,0 @@
1
- /* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
- Please see the LICENSE file for copyright and distribution information */
3
-
4
- #ifndef __RP_CALL_INFO_H__
5
- #define __RP_CALL_INFO_H__
6
-
7
- #include "rp_measure.h"
8
- #include "rp_method.h"
9
-
10
- extern VALUE cCallInfo;
11
-
12
- /* Callers and callee information for a method. */
13
- typedef struct prof_call_info_t
14
- {
15
- prof_method_t *target; /* Use target instead of method to avoid conflict with Ruby method */
16
- struct prof_call_info_t *parent;
17
- st_table *call_infos;
18
- int called;
19
- int depth;
20
- double total_time;
21
- double self_time;
22
- double wait_time;
23
- int line;
24
- VALUE object;
25
- VALUE children;
26
- } prof_call_info_t;
27
-
28
- /* Array of call_info objects */
29
- typedef struct prof_call_infos_t
30
- {
31
- prof_call_info_t **start;
32
- prof_call_info_t **end;
33
- prof_call_info_t **ptr;
34
- VALUE object;
35
- } prof_call_infos_t;
36
-
37
-
38
- void rp_init_call_info(void);
39
- prof_call_infos_t* prof_call_infos_create();
40
- void prof_call_infos_mark(prof_call_infos_t *call_infos);
41
- void prof_call_infos_free(prof_call_infos_t *call_infos);
42
- void prof_add_call_info(prof_call_infos_t *call_infos, prof_call_info_t *call_info);
43
- VALUE prof_call_infos_wrap(prof_call_infos_t *call_infos);
44
- prof_call_info_t * prof_call_info_create(prof_method_t* method, prof_call_info_t* parent);
45
- prof_call_info_t * call_info_table_lookup(st_table *table, const prof_method_key_t *key);
46
- size_t call_info_table_insert(st_table *table, const prof_method_key_t *key, prof_call_info_t *val);
47
-
48
- #endif //__RP_CALL_INFO_H__