| Class | RubyProf::MethodInfo |
| In: |
ext/ruby_prof.c
|
| Parent: | Object |
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::Result object.
For recursively called methods, returns the base method. Otherwise, returns self.
/* call-seq:
called -> MethodInfo
For recursively called methods, returns the base method. Otherwise,
returns self. */
static VALUE
prof_method_base(VALUE self)
{
prof_method_t *method = get_prof_method(self);
if (method == method->base)
return self;
else
/* 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! */
return Data_Wrap_Struct(cMethodInfo, NULL, NULL, method->base);
}
Returns the number of times this method was called.
/* call-seq:
called -> int
Returns the number of times this method was called. */
static VALUE
prof_method_called(VALUE self)
{
prof_method_t *result = get_prof_method(self);
return INT2NUM(result->called);
}
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_method_children(VALUE self)
{
/* Returns an array of call info objects for this
method's callees (the methods this method called). */
VALUE children = rb_ary_new();
prof_method_t *result = get_prof_method(self);
st_foreach(result->children, prof_method_collect_call_infos, children);
return children;
}
Returns the total amount of time spent in this method’s children.
/* call-seq:
children_time -> float
Returns the total amount of time spent in this method's children. */
static VALUE
prof_method_children_time(VALUE self)
{
prof_method_t *result = get_prof_method(self);
prof_measure_t children_time = result->total_time - result->self_time - result->wait_time;
return rb_float_new(convert_measurement(children_time));
}
Returns the full name of this method in the format Object#method.
/* call-seq:
full_name -> string
Returns the full name of this method in the format Object#method.*/
static VALUE
prof_full_name(VALUE self)
{
prof_method_t *method = get_prof_method(self);
return full_name(method->klass, method->mid, method->depth);
}
Returns the Ruby klass that owns this method.
/* call-seq:
method_class -> klass
Returns the Ruby klass that owns this method. */
static VALUE
prof_method_klass(VALUE self)
{
prof_method_t *result = get_prof_method(self);
return result->klass;
}
Returns the name of this method’s class. Singleton classes will have the form <Object::Object>.
/* call-seq:
klass_name -> string
Returns the name of this method's class. Singleton classes
will have the form <Object::Object>. */
static VALUE
prof_klass_name(VALUE self)
{
prof_method_t *method = get_prof_method(self);
return klass_name(method->klass);
}
returns the line number of the method
/* call-seq:
line_no -> int
returns the line number of the method */
static VALUE
prof_method_line(VALUE self)
{
return rb_int_new(get_prof_method(self)->line);
}
Returns the id of this method.
/* call-seq:
method_id -> ID
Returns the id of this method. */
static VALUE
prof_method_id(VALUE self)
{
prof_method_t *result = get_prof_method(self);
return ID2SYM(result->mid);
}
Returns the name of this method in the format Object#method. Singletons methods will be returned in the format <Object::Object>method.
/* call-seq:
method_name -> string
Returns the name of this method in the format Object#method. Singletons
methods will be returned in the format <Object::Object>#method.*/
static VALUE
prof_method_name(VALUE self)
{
prof_method_t *method = get_prof_method(self);
return method_name(method->mid, method->depth);
}
Returns an array of call info objects of methods that this method was called by (ie, parents).
/* call-seq:
children -> hash
Returns an array of call info objects of methods that this method
was called by (ie, parents).*/
static VALUE
prof_method_parents(VALUE self)
{
/* Returns an array of call info objects for this
method's callers (the methods this method called). */
VALUE children = rb_ary_new();
prof_method_t *result = get_prof_method(self);
st_foreach(result->parents, prof_method_collect_call_infos, children);
return children;
}
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_method_self_time(VALUE self)
{
prof_method_t *result = get_prof_method(self);
return rb_float_new(convert_measurement(result->self_time));
}
return the source file of the method
/* call-seq:
source_file => string
return the source file of the method
*/
static VALUE prof_method_source_file(VALUE self)
{
const char* sf = get_prof_method(self)->source_file;
if(!sf)
{
return rb_str_new2("ruby_runtime");
}
else
{
return rb_str_new2(sf);
}
}
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_method_total_time(VALUE self)
{
prof_method_t *result = get_prof_method(self);
return rb_float_new(convert_measurement(result->total_time));
}
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_method_wait_time(VALUE self)
{
prof_method_t *result = get_prof_method(self);
return rb_float_new(convert_measurement(result->wait_time));
}