Class: RubyProf::CallTrees
- Inherits:
-
Object
- Object
- RubyProf::CallTrees
- Defined in:
- ext/ruby_prof/rp_call_trees.c,
ext/ruby_prof/rp_call_trees.c
Overview
The RubyProf::MethodInfo class stores profiling data for a method. One instance of the RubyProf::MethodInfo class is created per method called per thread. Thus, if a method is called in two different thread then there will be two RubyProf::MethodInfo objects created. RubyProf::MethodInfo objects can be accessed via the RubyProf::Profile object.
Instance Method Summary collapse
-
#_dump_data ⇒ Object
:nodoc:.
-
#_load_data(data) ⇒ Object
:nodoc:.
-
#callers ⇒ Array
Returns an array of all CallTree objects that called this method.
-
#callees ⇒ Array
Returns an array of aggregated CallTree objects that this method called (ie, children).
-
#callers ⇒ Array
Returns an array of aggregated CallTree objects that called this method (ie, parents).
-
#min_depth ⇒ Integer
Returns the minimum depth of this method in any call tree.
Instance Method Details
#_dump_data ⇒ Object
:nodoc:
249 250 251 252 253 254 255 |
# File 'ext/ruby_prof/rp_call_trees.c', line 249
VALUE prof_call_trees_dump(VALUE self)
{
VALUE result = rb_hash_new();
rb_hash_aset(result, ID2SYM(rb_intern("call_trees")), prof_call_trees_call_trees(self));
return result;
}
|
#_load_data(data) ⇒ Object
:nodoc:
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'ext/ruby_prof/rp_call_trees.c', line 258
VALUE prof_call_trees_load(VALUE self, VALUE data)
{
prof_call_trees_t* call_trees_data = prof_get_call_trees(self);
call_trees_data->object = self;
VALUE call_trees = rb_hash_aref(data, ID2SYM(rb_intern("call_trees")));
for (int i = 0; i < rb_array_len(call_trees); i++)
{
VALUE call_tree = rb_ary_entry(call_trees, i);
prof_call_tree_t* call_tree_data = prof_get_call_tree(call_tree);
prof_add_call_tree(call_trees_data, call_tree_data);
}
return data;
}
|
#callers ⇒ Array
Returns an array of all CallTree objects that called this method.
181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'ext/ruby_prof/rp_call_trees.c', line 181
VALUE prof_call_trees_call_trees(VALUE self)
{
VALUE result = rb_ary_new();
prof_call_trees_t* call_trees = prof_get_call_trees(self);
for (prof_call_tree_t** p_call_tree = call_trees->start; p_call_tree < call_trees->ptr; p_call_tree++)
{
VALUE call_tree = prof_call_tree_wrap(*p_call_tree);
rb_ary_push(result, call_tree);
}
return result;
}
|
#callees ⇒ Array
Returns an array of aggregated CallTree objects that this method called (ie, children).
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'ext/ruby_prof/rp_call_trees.c', line 232
VALUE prof_call_trees_callees(VALUE self)
{
st_table* callees = rb_st_init_numtable();
prof_call_trees_t* call_trees = prof_get_call_trees(self);
for (prof_call_tree_t** call_tree = call_trees->start; call_tree < call_trees->ptr; call_tree++)
{
rb_st_foreach((*call_tree)->children, prof_call_trees_collect_callees, (st_data_t)callees);
}
VALUE result = rb_ary_new_capa(callees->num_entries);
rb_st_foreach(callees, prof_call_trees_collect_aggregates, result);
rb_st_free_table(callees);
return result;
}
|
#callers ⇒ Array
Returns an array of aggregated CallTree objects that called this method (ie, parents).
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'ext/ruby_prof/rp_call_trees.c', line 198
VALUE prof_call_trees_callers(VALUE self)
{
st_table* callers = rb_st_init_numtable();
prof_call_trees_t* call_trees = prof_get_call_trees(self);
for (prof_call_tree_t** p_call_tree = call_trees->start; p_call_tree < call_trees->ptr; p_call_tree++)
{
prof_call_tree_t* parent = (*p_call_tree)->parent;
if (parent == NULL)
continue;
prof_call_tree_t* aggregate_call_tree_data = NULL;
if (rb_st_lookup(callers, parent->method->key, (st_data_t*)&aggregate_call_tree_data))
{
prof_call_tree_merge(aggregate_call_tree_data, *p_call_tree);
}
else
{
aggregate_call_tree_data = prof_call_tree_copy(*p_call_tree);
rb_st_insert(callers, parent->method->key, (st_data_t)aggregate_call_tree_data);
}
}
VALUE result = rb_ary_new_capa(callers->num_entries);
rb_st_foreach(callers, prof_call_trees_collect_aggregates, result);
rb_st_free_table(callers);
return result;
}
|
#min_depth ⇒ Integer
Returns the minimum depth of this method in any call tree
162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'ext/ruby_prof/rp_call_trees.c', line 162
VALUE prof_call_trees_min_depth(VALUE self)
{
unsigned int depth = INT_MAX;
prof_call_trees_t* call_trees = prof_get_call_trees(self);
for (prof_call_tree_t** p_call_tree = call_trees->start; p_call_tree < call_trees->ptr; p_call_tree++)
{
unsigned int call_tree_depth = prof_call_figure_depth(*p_call_tree);
if (call_tree_depth < depth)
depth = call_tree_depth;
}
return UINT2NUM(depth);
}
|