ruby-prof 0.18.0-x64-mingw32 → 1.1.0-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +32 -0
  3. data/LICENSE +2 -2
  4. data/README.rdoc +1 -483
  5. data/Rakefile +3 -6
  6. data/bin/ruby-prof +65 -30
  7. data/ext/ruby_prof/extconf.rb +6 -38
  8. data/ext/ruby_prof/rp_allocation.c +279 -0
  9. data/ext/ruby_prof/rp_allocation.h +31 -0
  10. data/ext/ruby_prof/rp_call_info.c +129 -283
  11. data/ext/ruby_prof/rp_call_info.h +16 -34
  12. data/ext/ruby_prof/rp_measure_allocations.c +25 -49
  13. data/ext/ruby_prof/rp_measure_memory.c +21 -56
  14. data/ext/ruby_prof/rp_measure_process_time.c +35 -39
  15. data/ext/ruby_prof/rp_measure_wall_time.c +36 -19
  16. data/ext/ruby_prof/rp_measurement.c +230 -0
  17. data/ext/ruby_prof/rp_measurement.h +50 -0
  18. data/ext/ruby_prof/rp_method.c +389 -389
  19. data/ext/ruby_prof/rp_method.h +34 -39
  20. data/ext/ruby_prof/rp_profile.c +895 -0
  21. data/ext/ruby_prof/rp_profile.h +37 -0
  22. data/ext/ruby_prof/rp_stack.c +103 -80
  23. data/ext/ruby_prof/rp_stack.h +5 -12
  24. data/ext/ruby_prof/rp_thread.c +143 -83
  25. data/ext/ruby_prof/rp_thread.h +15 -6
  26. data/ext/ruby_prof/ruby_prof.c +11 -757
  27. data/ext/ruby_prof/ruby_prof.h +4 -47
  28. data/ext/ruby_prof/vc/ruby_prof.vcxproj +10 -8
  29. data/lib/{2.6.3 → 2.6.5}/ruby_prof.so +0 -0
  30. data/lib/ruby-prof.rb +2 -18
  31. data/lib/ruby-prof/assets/call_stack_printer.html.erb +713 -0
  32. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  33. data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
  34. data/lib/ruby-prof/call_info.rb +35 -93
  35. data/lib/ruby-prof/call_info_visitor.rb +19 -21
  36. data/lib/ruby-prof/compatibility.rb +37 -107
  37. data/lib/ruby-prof/exclude_common_methods.rb +198 -0
  38. data/lib/ruby-prof/measurement.rb +14 -0
  39. data/lib/ruby-prof/method_info.rb +52 -83
  40. data/lib/ruby-prof/printers/abstract_printer.rb +73 -50
  41. data/lib/ruby-prof/printers/call_info_printer.rb +13 -3
  42. data/lib/ruby-prof/printers/call_stack_printer.rb +62 -145
  43. data/lib/ruby-prof/printers/call_tree_printer.rb +20 -12
  44. data/lib/ruby-prof/printers/dot_printer.rb +5 -5
  45. data/lib/ruby-prof/printers/flat_printer.rb +6 -24
  46. data/lib/ruby-prof/printers/graph_html_printer.rb +6 -192
  47. data/lib/ruby-prof/printers/graph_printer.rb +13 -15
  48. data/lib/ruby-prof/printers/multi_printer.rb +66 -23
  49. data/lib/ruby-prof/profile.rb +10 -3
  50. data/lib/ruby-prof/rack.rb +0 -3
  51. data/lib/ruby-prof/thread.rb +12 -12
  52. data/lib/ruby-prof/version.rb +1 -1
  53. data/ruby-prof.gemspec +2 -2
  54. data/test/abstract_printer_test.rb +0 -27
  55. data/test/alias_test.rb +129 -0
  56. data/test/basic_test.rb +41 -40
  57. data/test/call_info_visitor_test.rb +3 -3
  58. data/test/dynamic_method_test.rb +0 -2
  59. data/test/fiber_test.rb +11 -17
  60. data/test/gc_test.rb +96 -0
  61. data/test/line_number_test.rb +120 -39
  62. data/test/marshal_test.rb +119 -0
  63. data/test/measure_allocations.rb +30 -0
  64. data/test/measure_allocations_test.rb +371 -12
  65. data/test/measure_allocations_trace_test.rb +385 -0
  66. data/test/measure_memory_trace_test.rb +756 -0
  67. data/test/measure_process_time_test.rb +821 -33
  68. data/test/measure_times.rb +54 -0
  69. data/test/measure_wall_time_test.rb +349 -145
  70. data/test/multi_printer_test.rb +1 -34
  71. data/test/parser_timings.rb +24 -0
  72. data/test/pause_resume_test.rb +5 -5
  73. data/test/prime.rb +2 -0
  74. data/test/printer_call_stack_test.rb +28 -0
  75. data/test/printer_call_tree_test.rb +31 -0
  76. data/test/printer_flat_test.rb +68 -0
  77. data/test/printer_graph_html_test.rb +60 -0
  78. data/test/printer_graph_test.rb +41 -0
  79. data/test/printers_test.rb +32 -166
  80. data/test/printing_recursive_graph_test.rb +26 -72
  81. data/test/recursive_test.rb +72 -77
  82. data/test/stack_printer_test.rb +2 -15
  83. data/test/start_stop_test.rb +22 -25
  84. data/test/test_helper.rb +5 -248
  85. data/test/thread_test.rb +11 -54
  86. data/test/unique_call_path_test.rb +16 -28
  87. data/test/yarv_test.rb +1 -0
  88. metadata +28 -36
  89. data/examples/flat.txt +0 -50
  90. data/examples/graph.dot +0 -84
  91. data/examples/graph.html +0 -823
  92. data/examples/graph.txt +0 -139
  93. data/examples/multi.flat.txt +0 -23
  94. data/examples/multi.graph.html +0 -760
  95. data/examples/multi.grind.dat +0 -114
  96. data/examples/multi.stack.html +0 -547
  97. data/examples/stack.html +0 -547
  98. data/ext/ruby_prof/rp_measure.c +0 -40
  99. data/ext/ruby_prof/rp_measure.h +0 -45
  100. data/ext/ruby_prof/rp_measure_cpu_time.c +0 -136
  101. data/ext/ruby_prof/rp_measure_gc_runs.c +0 -73
  102. data/ext/ruby_prof/rp_measure_gc_time.c +0 -60
  103. data/lib/ruby-prof/aggregate_call_info.rb +0 -76
  104. data/lib/ruby-prof/assets/call_stack_printer.css.html +0 -117
  105. data/lib/ruby-prof/assets/call_stack_printer.js.html +0 -385
  106. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -83
  107. data/lib/ruby-prof/profile/exclude_common_methods.rb +0 -207
  108. data/lib/ruby-prof/profile/legacy_method_elimination.rb +0 -50
  109. data/test/aggregate_test.rb +0 -136
  110. data/test/block_test.rb +0 -74
  111. data/test/call_info_test.rb +0 -78
  112. data/test/issue137_test.rb +0 -63
  113. data/test/measure_cpu_time_test.rb +0 -212
  114. data/test/measure_gc_runs_test.rb +0 -32
  115. data/test/measure_gc_time_test.rb +0 -36
  116. data/test/measure_memory_test.rb +0 -33
  117. data/test/method_elimination_test.rb +0 -84
  118. data/test/module_test.rb +0 -45
  119. data/test/stack_test.rb +0 -138
@@ -0,0 +1,31 @@
1
+ /* Copyright (C) 2005-2019 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_ALLOCATION_
5
+ #define _RP_ALLOCATION_
6
+
7
+ #include "ruby_prof.h"
8
+ #include "rp_method.h"
9
+
10
+ typedef struct
11
+ {
12
+ st_data_t key; /* Key in hash table */
13
+ unsigned int klass_flags; /* Information about the type of class */
14
+ VALUE klass; /* Klass that was created */
15
+ VALUE klass_name; /* Name of the class that was created */
16
+ VALUE source_file; /* Line number where allocation happens */
17
+ int source_line; /* Line number where allocation happens */
18
+ int count; /* Number of allocations */
19
+ size_t memory; /* Amount of allocated memory */
20
+ VALUE object; /* Cache to wrapped object */
21
+ } prof_allocation_t;
22
+
23
+ void rp_init_allocation(void);
24
+ void prof_allocation_free(prof_allocation_t* allocation);
25
+ void prof_allocation_mark(void *data);
26
+ VALUE prof_allocation_wrap(prof_allocation_t* allocation);
27
+ prof_allocation_t* prof_allocation_get(VALUE self);
28
+ prof_allocation_t* prof_allocate_increment(prof_method_t *method, rb_trace_arg_t *trace_arg);
29
+
30
+
31
+ #endif //_RP_ALLOCATION_
@@ -1,86 +1,100 @@
1
1
  /* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
2
  Please see the LICENSE file for copyright and distribution information */
3
3
 
4
- #include "ruby_prof.h"
4
+ #include "rp_call_info.h"
5
5
 
6
6
  #define INITIAL_CALL_INFOS_SIZE 2
7
7
 
8
- VALUE cCallInfo;
9
-
10
-
11
- // Forward declarations
12
- st_table * call_info_table_create();
13
-
8
+ VALUE cRpCallnfo;
14
9
 
15
10
  /* ======= prof_call_info_t ========*/
16
11
  prof_call_info_t *
17
- prof_call_info_create(prof_method_t* method, prof_call_info_t* parent)
12
+ prof_call_info_create(prof_method_t *method, prof_method_t *parent, VALUE source_file, int source_line)
18
13
  {
19
14
  prof_call_info_t *result = ALLOC(prof_call_info_t);
20
- result->object = Qnil;
21
- result->target = method;
15
+ result->method = method;
22
16
  result->parent = parent;
23
- result->call_infos = call_info_table_create();
24
- result->children = Qnil;
25
-
26
- result->total_time = 0;
27
- result->self_time = 0;
28
- result->wait_time = 0;
17
+ result->object = Qnil;
18
+ result->measurement = prof_measurement_create();
29
19
 
30
- result->called = 0;
20
+ result->visits = 0;
31
21
 
32
- result->recursive = 0;
33
22
  result->depth = 0;
34
- result->line = 0;
23
+ result->source_line = source_line;
24
+ result->source_file = source_file;
35
25
 
36
26
  return result;
37
27
  }
28
+
38
29
  static void
39
- prof_call_info_ruby_gc_free(prof_call_info_t *call_info)
30
+ prof_call_info_ruby_gc_free(void *data)
40
31
  {
41
- /* Has this thread object been accessed by Ruby? If
32
+ prof_call_info_t *call_info = (prof_call_info_t*)data;
33
+
34
+ /* Has this call info object been accessed by Ruby? If
42
35
  yes clean it up so to avoid a segmentation fault. */
43
36
  if (call_info->object != Qnil)
44
37
  {
45
- RDATA(call_info->object)->data = NULL;
46
- RDATA(call_info->object)->dfree = NULL;
47
- RDATA(call_info->object)->dmark = NULL;
38
+ RDATA(call_info->object)->dmark = NULL;
39
+ RDATA(call_info->object)->dfree = NULL;
40
+ RDATA(call_info->object)->data = NULL;
41
+ call_info->object = Qnil;
48
42
  }
49
- call_info->object = Qnil;
50
43
  }
51
44
 
52
- static void
45
+ void
53
46
  prof_call_info_free(prof_call_info_t *call_info)
54
47
  {
55
- prof_call_info_ruby_gc_free(call_info);
56
- st_free_table(call_info->call_infos);
57
- xfree(call_info);
48
+ prof_measurement_free(call_info->measurement);
49
+ prof_call_info_ruby_gc_free(call_info);
50
+ xfree(call_info);
58
51
  }
59
52
 
60
- static void
61
- prof_call_info_mark(prof_call_info_t *call_info)
53
+ size_t
54
+ prof_call_info_size(const void *data)
55
+ {
56
+ return sizeof(prof_call_info_t);
57
+ }
58
+
59
+ void
60
+ prof_call_info_mark(void *data)
62
61
  {
63
- if (call_info->object)
62
+ prof_call_info_t *call_info = (prof_call_info_t*)data;
63
+
64
+ if (call_info->source_file != Qnil)
65
+ rb_gc_mark(call_info->source_file);
66
+
67
+ if (call_info->object != Qnil)
64
68
  rb_gc_mark(call_info->object);
65
69
 
66
- if (call_info->children)
67
- rb_gc_mark(call_info->children);
70
+ if (call_info->method && call_info->method->object != Qnil)
71
+ rb_gc_mark(call_info->method->object);
72
+
73
+ if (call_info->parent && call_info->parent->object != Qnil)
74
+ rb_gc_mark(call_info->parent->object);
68
75
 
69
- /* We don't mark the call info child table since that will be done
70
- via the appropriate method */
76
+ prof_measurement_mark(call_info->measurement);
71
77
  }
72
78
 
73
79
  VALUE
74
80
  prof_call_info_wrap(prof_call_info_t *call_info)
75
81
  {
76
- if (call_info->object == Qnil)
77
- {
78
- call_info->object = Data_Wrap_Struct(cCallInfo, prof_call_info_mark, prof_call_info_ruby_gc_free, call_info);
79
- }
80
- return call_info->object;
82
+ if (call_info->object == Qnil)
83
+ {
84
+ call_info->object = Data_Wrap_Struct(cRpCallnfo, prof_call_info_mark, prof_call_info_ruby_gc_free, call_info);
85
+ }
86
+ return call_info->object;
81
87
  }
82
88
 
83
- static prof_call_info_t *
89
+ static VALUE
90
+ prof_call_info_allocate(VALUE klass)
91
+ {
92
+ prof_call_info_t* call_info = prof_call_info_create(NULL, NULL, Qnil, 0);
93
+ call_info->object = prof_call_info_wrap(call_info);
94
+ return call_info->object;
95
+ }
96
+
97
+ prof_call_info_t *
84
98
  prof_get_call_info(VALUE self)
85
99
  {
86
100
  /* Can't use Data_Get_Struct because that triggers the event hook
@@ -97,17 +111,17 @@ prof_get_call_info(VALUE self)
97
111
  st_table *
98
112
  call_info_table_create()
99
113
  {
100
- return st_init_table(&type_method_hash);
114
+ return st_init_numtable();
101
115
  }
102
116
 
103
117
  size_t
104
- call_info_table_insert(st_table *table, const prof_method_key_t *key, prof_call_info_t *val)
118
+ call_info_table_insert(st_table *table, st_data_t key, prof_call_info_t *val)
105
119
  {
106
120
  return st_insert(table, (st_data_t) key, (st_data_t) val);
107
121
  }
108
122
 
109
123
  prof_call_info_t *
110
- call_info_table_lookup(st_table *table, const prof_method_key_t *key)
124
+ call_info_table_lookup(st_table *table, st_data_t key)
111
125
  {
112
126
  st_data_t val;
113
127
  if (st_lookup(table, (st_data_t) key, &val))
@@ -120,62 +134,42 @@ call_info_table_lookup(st_table *table, const prof_method_key_t *key)
120
134
  }
121
135
  }
122
136
 
123
-
124
137
  /* ======= RubyProf::CallInfo ========*/
125
138
 
126
- /* Document-class: RubyProf::CallInfo
127
- RubyProf::CallInfo is a helper class used by RubyProf::MethodInfo
128
- to keep track of which child methods were called and how long
129
- they took to execute. */
130
-
131
-
132
- /* call-seq:
133
- called -> MethodInfo
134
-
135
- Returns the target method. */
136
- static VALUE
137
- prof_call_info_target(VALUE self)
138
- {
139
- /* Target is a pointer to a method_info - so we have to be careful
140
- about the GC. We will wrap the method_info but provide no
141
- free method so the underlying object is not freed twice! */
142
-
143
- prof_call_info_t *result = prof_get_call_info(self);
144
- return prof_method_wrap(result->target);
145
- }
146
-
147
139
  /* call-seq:
148
- called -> int
140
+ parent -> call_info
149
141
 
150
- Returns the total amount of times this method was called. */
142
+ Returns the call_infos parent call_info object (the method that called this method).*/
151
143
  static VALUE
152
- prof_call_info_called(VALUE self)
144
+ prof_call_info_parent(VALUE self)
153
145
  {
154
- prof_call_info_t *result = prof_get_call_info(self);
155
- return INT2NUM(result->called);
146
+ prof_call_info_t* call_info = prof_get_call_info(self);
147
+ if (call_info->parent)
148
+ return prof_method_wrap(call_info->parent);
149
+ else
150
+ return Qnil;
156
151
  }
157
152
 
158
153
  /* call-seq:
159
- called=n -> n
154
+ called -> MethodInfo
160
155
 
161
- Sets the call count to n. */
156
+ Returns the target method. */
162
157
  static VALUE
163
- prof_call_info_set_called(VALUE self, VALUE called)
158
+ prof_call_info_target(VALUE self)
164
159
  {
165
- prof_call_info_t *result = prof_get_call_info(self);
166
- result->called = NUM2INT(called);
167
- return called;
160
+ prof_call_info_t *call_info = prof_get_call_info(self);
161
+ return prof_method_wrap(call_info->method);
168
162
  }
169
163
 
170
164
  /* call-seq:
171
- recursive? -> boolean
165
+ called -> Measurement
172
166
 
173
- Returns the true if this call info is a recursive invocation */
167
+ Returns the measurement associated with this call_info. */
174
168
  static VALUE
175
- prof_call_info_recursive(VALUE self)
169
+ prof_call_info_measurement(VALUE self)
176
170
  {
177
- prof_call_info_t *result = prof_get_call_info(self);
178
- return result->recursive ? Qtrue : Qfalse;
171
+ prof_call_info_t* call_info = prof_get_call_info(self);
172
+ return prof_measurement_wrap(call_info->measurement);
179
173
  }
180
174
 
181
175
  /* call-seq:
@@ -190,236 +184,88 @@ prof_call_info_depth(VALUE self)
190
184
  }
191
185
 
192
186
  /* call-seq:
193
- line_no -> int
194
-
195
- returns the line number of the method */
196
- static VALUE
197
- prof_call_info_line(VALUE self)
198
- {
199
- prof_call_info_t *result = prof_get_call_info(self);
200
- return rb_int_new(result->line);
201
- }
202
-
203
- /* call-seq:
204
- total_time -> float
187
+ source_file => string
205
188
 
206
- Returns the total amount of time spent in this method and its children. */
189
+ return the source file of the method
190
+ */
207
191
  static VALUE
208
- prof_call_info_total_time(VALUE self)
192
+ prof_call_info_source_file(VALUE self)
209
193
  {
210
- prof_call_info_t *result = prof_get_call_info(self);
211
- return rb_float_new(result->total_time);
194
+ prof_call_info_t* result = prof_get_call_info(self);
195
+ return result->source_file;
212
196
  }
213
197
 
214
198
  /* call-seq:
215
- add_total_time(call_info) -> nil
216
-
217
- adds total time time from call_info to self. */
218
- static VALUE
219
- prof_call_info_add_total_time(VALUE self, VALUE other)
220
- {
221
- prof_call_info_t *result = prof_get_call_info(self);
222
- prof_call_info_t *other_info = prof_get_call_info(other);
223
-
224
- result->total_time += other_info->total_time;
225
- return Qnil;
226
- }
227
-
228
- /* call-seq:
229
- self_time -> float
230
-
231
- Returns the total amount of time spent in this method. */
232
- static VALUE
233
- prof_call_info_self_time(VALUE self)
234
- {
235
- prof_call_info_t *result = prof_get_call_info(self);
236
-
237
- return rb_float_new(result->self_time);
238
- }
239
-
240
- /* call-seq:
241
- add_self_time(call_info) -> nil
199
+ line_no -> int
242
200
 
243
- adds self time from call_info to self. */
201
+ returns the line number of the method */
244
202
  static VALUE
245
- prof_call_info_add_self_time(VALUE self, VALUE other)
203
+ prof_call_info_line(VALUE self)
246
204
  {
247
- prof_call_info_t *result = prof_get_call_info(self);
248
- prof_call_info_t *other_info = prof_get_call_info(other);
249
-
250
- result->self_time += other_info->self_time;
251
- return Qnil;
205
+ prof_call_info_t *result = prof_get_call_info(self);
206
+ return INT2FIX(result->source_line);
252
207
  }
253
208
 
254
- /* call-seq:
255
- wait_time -> float
256
-
257
- Returns the total amount of time this method waited for other threads. */
209
+ /* :nodoc: */
258
210
  static VALUE
259
- prof_call_info_wait_time(VALUE self)
211
+ prof_call_info_dump(VALUE self)
260
212
  {
261
- prof_call_info_t *result = prof_get_call_info(self);
262
-
263
- return rb_float_new(result->wait_time);
264
- }
213
+ prof_call_info_t* call_info_data = prof_get_call_info(self);
214
+ VALUE result = rb_hash_new();
265
215
 
266
- /* call-seq:
267
- add_wait_time(call_info) -> nil
216
+ rb_hash_aset(result, ID2SYM(rb_intern("measurement")), prof_measurement_wrap(call_info_data->measurement));
268
217
 
269
- adds wait time from call_info to self. */
218
+ rb_hash_aset(result, ID2SYM(rb_intern("depth")), INT2FIX(call_info_data->depth));
219
+ rb_hash_aset(result, ID2SYM(rb_intern("source_file")), call_info_data->source_file);
220
+ rb_hash_aset(result, ID2SYM(rb_intern("source_line")), INT2FIX(call_info_data->source_line));
270
221
 
271
- static VALUE
272
- prof_call_info_add_wait_time(VALUE self, VALUE other)
273
- {
274
- prof_call_info_t *result = prof_get_call_info(self);
275
- prof_call_info_t *other_info = prof_get_call_info(other);
222
+ rb_hash_aset(result, ID2SYM(rb_intern("parent")), prof_call_info_parent(self));
223
+ rb_hash_aset(result, ID2SYM(rb_intern("target")), prof_call_info_target(self));
276
224
 
277
- result->wait_time += other_info->wait_time;
278
- return Qnil;
225
+ return result;
279
226
  }
280
227
 
281
- /* call-seq:
282
- parent -> call_info
283
-
284
- Returns the call_infos parent call_info object (the method that called this method).*/
228
+ /* :nodoc: */
285
229
  static VALUE
286
- prof_call_info_parent(VALUE self)
230
+ prof_call_info_load(VALUE self, VALUE data)
287
231
  {
288
- prof_call_info_t *result = prof_get_call_info(self);
289
- if (result->parent)
290
- return prof_call_info_wrap(result->parent);
291
- else
292
- return Qnil;
293
- }
232
+ VALUE target = Qnil;
233
+ VALUE parent = Qnil;
234
+ prof_call_info_t* call_info = prof_get_call_info(self);
235
+ call_info->object = self;
294
236
 
295
- /* call-seq:
296
- parent=new_parent -> new_parent
237
+ VALUE measurement = rb_hash_aref(data, ID2SYM(rb_intern("measurement")));
238
+ call_info->measurement = prof_get_measurement(measurement);
297
239
 
298
- Changes the parent of self to new_parent and returns it.*/
299
- static VALUE
300
- prof_call_info_set_parent(VALUE self, VALUE new_parent)
301
- {
302
- prof_call_info_t *result = prof_get_call_info(self);
303
- if (new_parent == Qnil)
304
- result->parent = NULL;
305
- else
306
- result->parent = prof_get_call_info(new_parent);
307
- return prof_call_info_parent(self);
308
- }
240
+ call_info->depth = FIX2INT(rb_hash_aref(data, ID2SYM(rb_intern("depth"))));
241
+ call_info->source_file = rb_hash_aref(data, ID2SYM(rb_intern("source_file")));
242
+ call_info->source_line = FIX2INT(rb_hash_aref(data, ID2SYM(rb_intern("source_line"))));
309
243
 
310
- static int
311
- prof_call_info_collect_children(st_data_t key, st_data_t value, st_data_t result)
312
- {
313
- prof_call_info_t *call_info = (prof_call_info_t *) value;
314
- VALUE arr = (VALUE) result;
315
- rb_ary_push(arr, prof_call_info_wrap(call_info));
316
- return ST_CONTINUE;
317
- }
244
+ parent = rb_hash_aref(data, ID2SYM(rb_intern("parent")));
245
+ if (parent != Qnil)
246
+ call_info->parent = prof_method_get(parent);
318
247
 
319
- /* call-seq:
320
- children -> hash
248
+ target = rb_hash_aref(data, ID2SYM(rb_intern("target")));
249
+ call_info->method = prof_method_get(target);
321
250
 
322
- Returns an array of call info objects of methods that this method
323
- called (ie, children).*/
324
- static VALUE
325
- prof_call_info_children(VALUE self)
326
- {
327
- prof_call_info_t *call_info = prof_get_call_info(self);
328
- if (call_info->children == Qnil)
329
- {
330
- call_info->children = rb_ary_new();
331
- st_foreach(call_info->call_infos, prof_call_info_collect_children, call_info->children);
332
- }
333
- return call_info->children;
251
+ return data;
334
252
  }
335
253
 
336
- /* ======= Call Infos ========*/
337
- prof_call_infos_t*
338
- prof_call_infos_create()
339
- {
340
- prof_call_infos_t *result = ALLOC(prof_call_infos_t);
341
- result->start = ALLOC_N(prof_call_info_t*, INITIAL_CALL_INFOS_SIZE);
342
- result->end = result->start + INITIAL_CALL_INFOS_SIZE;
343
- result->ptr = result->start;
344
- result->object = Qnil;
345
- return result;
346
- }
347
-
348
- void
349
- prof_call_infos_mark(prof_call_infos_t *call_infos)
350
- {
351
- prof_call_info_t **call_info;
352
-
353
- if (call_infos->object)
354
- rb_gc_mark(call_infos->object);
355
-
356
- for(call_info=call_infos->start; call_info<call_infos->ptr; call_info++)
357
- {
358
- prof_call_info_mark(*call_info);
359
- }
360
- }
361
-
362
- void
363
- prof_call_infos_free(prof_call_infos_t *call_infos)
254
+ void rp_init_call_info()
364
255
  {
365
- prof_call_info_t **call_info;
366
-
367
- for(call_info=call_infos->start; call_info<call_infos->ptr; call_info++)
368
- {
369
- prof_call_info_free(*call_info);
370
- }
371
- }
256
+ /* CallInfo */
257
+ cRpCallnfo = rb_define_class_under(mProf, "CallInfo", rb_cData);
258
+ rb_undef_method(CLASS_OF(cRpCallnfo), "new");
259
+ rb_define_alloc_func(cRpCallnfo, prof_call_info_allocate);
372
260
 
373
- void
374
- prof_add_call_info(prof_call_infos_t *call_infos, prof_call_info_t *call_info)
375
- {
376
- if (call_infos->ptr == call_infos->end)
377
- {
378
- size_t len = call_infos->ptr - call_infos->start;
379
- size_t new_capacity = (call_infos->end - call_infos->start) * 2;
380
- REALLOC_N(call_infos->start, prof_call_info_t*, new_capacity);
381
- call_infos->ptr = call_infos->start + len;
382
- call_infos->end = call_infos->start + new_capacity;
383
- }
384
- *call_infos->ptr = call_info;
385
- call_infos->ptr++;
386
- }
261
+ rb_define_method(cRpCallnfo, "parent", prof_call_info_parent, 0);
262
+ rb_define_method(cRpCallnfo, "target", prof_call_info_target, 0);
263
+ rb_define_method(cRpCallnfo, "measurement", prof_call_info_measurement, 0);
387
264
 
388
- VALUE
389
- prof_call_infos_wrap(prof_call_infos_t *call_infos)
390
- {
391
- if (call_infos->object == Qnil)
392
- {
393
- prof_call_info_t **i;
394
- call_infos->object = rb_ary_new();
395
- for(i=call_infos->start; i<call_infos->ptr; i++)
396
- {
397
- VALUE call_info = prof_call_info_wrap(*i);
398
- rb_ary_push(call_infos->object, call_info);
399
- }
400
- }
401
- return call_infos->object;
402
- }
265
+ rb_define_method(cRpCallnfo, "depth", prof_call_info_depth, 0);
266
+ rb_define_method(cRpCallnfo, "source_file", prof_call_info_source_file, 0);
267
+ rb_define_method(cRpCallnfo, "line", prof_call_info_line, 0);
403
268
 
404
- void rp_init_call_info()
405
- {
406
- /* CallInfo */
407
- cCallInfo = rb_define_class_under(mProf, "CallInfo", rb_cObject);
408
- rb_undef_method(CLASS_OF(cCallInfo), "new");
409
- rb_define_method(cCallInfo, "parent", prof_call_info_parent, 0);
410
- rb_define_method(cCallInfo, "parent=", prof_call_info_set_parent, 1);
411
- rb_define_method(cCallInfo, "children", prof_call_info_children, 0);
412
- rb_define_method(cCallInfo, "target", prof_call_info_target, 0);
413
- rb_define_method(cCallInfo, "called", prof_call_info_called, 0);
414
- rb_define_method(cCallInfo, "called=", prof_call_info_set_called, 1);
415
- rb_define_method(cCallInfo, "total_time", prof_call_info_total_time, 0);
416
- rb_define_method(cCallInfo, "add_total_time", prof_call_info_add_total_time, 1);
417
- rb_define_method(cCallInfo, "self_time", prof_call_info_self_time, 0);
418
- rb_define_method(cCallInfo, "add_self_time", prof_call_info_add_self_time, 1);
419
- rb_define_method(cCallInfo, "wait_time", prof_call_info_wait_time, 0);
420
- rb_define_method(cCallInfo, "add_wait_time", prof_call_info_add_wait_time, 1);
421
-
422
- rb_define_method(cCallInfo, "recursive?", prof_call_info_recursive, 0);
423
- rb_define_method(cCallInfo, "depth", prof_call_info_depth, 0);
424
- rb_define_method(cCallInfo, "line", prof_call_info_line, 0);
269
+ rb_define_method(cRpCallnfo, "_dump_data", prof_call_info_dump, 0);
270
+ rb_define_method(cRpCallnfo, "_load_data", prof_call_info_load, 1);
425
271
  }