RubyProf::CallInfo is a helper class used by RubyProf::MethodInfo to keep track of which child methods were called and how long they took to execute.
Public instance methods
# File lib/ruby-prof/call_info.rb, line 33 33: def call_sequence 34: @call_sequence ||= begin 35: stack.map {|method| method.full_name}.join('->') 36: end 37: end
called → int
Returns the total amount of time this method was called.
/* call-seq:
called -> int
Returns the total amount of time this method was called. */
static VALUE
prof_call_info_called(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
return INT2NUM(result->called);
}
children → hash
Returns an array of call info objects of methods that this method called (ie, children).
/* call-seq:
children -> hash
Returns an array of call info objects of methods that this method
called (ie, children).*/
static VALUE
prof_call_info_children(VALUE self)
{
prof_call_info_t *call_info = prof_get_call_info_result(self);
if (call_info->children == Qnil)
{
call_info->children = rb_ary_new();
st_foreach(call_info->call_infos, prof_call_info_collect_children, call_info->children);
}
return call_info->children;
}
# File lib/ruby-prof/call_info.rb, line 14 14: def children_time 15: children.inject(0) do |sum, call_info| 16: sum += call_info.total_time 17: end 18: end
# File lib/ruby-prof/call_info.rb, line 3 3: def depth 4: result = 0 5: call_info = self.parent 6: 7: while call_info 8: result += 1 9: call_info = call_info.parent 10: end 11: result 12: end
line_no → int
returns the line number of the method
/* call-seq:
line_no -> int
returns the line number of the method */
static VALUE
prof_call_info_line(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
return rb_int_new(result->line);
}
parent → call_info
Returns the call_infos parent call_info object (the method that called this method).
/* call-seq:
parent -> call_info
Returns the call_infos parent call_info object (the method that called this method).*/
static VALUE
prof_call_info_parent(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
if (result->parent)
return prof_call_info_wrap(result->parent);
else
return Qnil;
}
# File lib/ruby-prof/call_info.rb, line 39 39: def root? 40: self.parent.nil? 41: end
self_time → float
Returns the total amount of time spent in this method.
/* call-seq:
self_time -> float
Returns the total amount of time spent in this method. */
static VALUE
prof_call_info_self_time(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
return rb_float_new(convert_measurement(result->self_time));
}
# File lib/ruby-prof/call_info.rb, line 20 20: def stack 21: @stack ||= begin 22: methods = Array.new 23: call_info = self 24: 25: while call_info 26: methods << call_info.target 27: call_info = call_info.parent 28: end 29: methods.reverse 30: end 31: end
called → MethodInfo
Returns the target method.
/* call-seq:
called -> MethodInfo
Returns the target method. */
static VALUE
prof_call_info_target(VALUE self)
{
/* Target is a pointer to a method_info - so we have to be careful
about the GC. We will wrap the method_info but provide no
free method so the underlying object is not freed twice! */
prof_call_info_t *result = prof_get_call_info_result(self);
return prof_method_wrap(result->target);
}
# File lib/ruby-prof/call_info.rb, line 43 43: def to_s 44: "#{call_sequence}" 45: end
total_time → float
Returns the total amount of time spent in this method and its children.
/* call-seq:
total_time -> float
Returns the total amount of time spent in this method and its children. */
static VALUE
prof_call_info_total_time(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
return rb_float_new(convert_measurement(result->total_time));
}
wait_time → float
Returns the total amount of time this method waited for other threads.
/* call-seq:
wait_time -> float
Returns the total amount of time this method waited for other threads. */
static VALUE
prof_call_info_wait_time(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
return rb_float_new(convert_measurement(result->wait_time));
}