Class: RubyProf::MethodInfo
- Inherits:
-
Object
- Object
- RubyProf::MethodInfo
- Includes:
- Comparable
- Defined in:
- ext/ruby_prof.c,
ext/ruby_prof.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::Result object.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
:nodoc:.
-
#called ⇒ MethodInfo
For recursively called methods, returns the base method.
-
#called ⇒ Integer
Returns the number of times this method was called.
-
#children ⇒ Hash
Returns an array of call info objects of methods that this method called (ie, children).
-
#children_time ⇒ Float
Returns the total amount of time spent in this method’s children.
-
#full_name ⇒ String
Returns the full name of this method in the format Object#method.
-
#method_class ⇒ Object
Returns the Ruby klass that owns this method.
-
#klass_name ⇒ String
Returns the name of this method’s class.
-
#line_no ⇒ Integer
returns the line number of the method.
-
#method_id ⇒ Object
Returns the id of this method.
-
#method_name ⇒ String
Returns the name of this method in the format Object#method.
-
#children ⇒ Hash
Returns an array of call info objects of methods that this method was called by (ie, parents).
-
#self_time ⇒ Float
Returns the total amount of time spent in this method.
-
#source_file ⇒ String
return the source file of the method.
-
#total_time ⇒ Float
Returns the total amount of time spent in this method and its children.
-
#wait_time ⇒ Float
Returns the total amount of time this method waited for other threads.
Instance Method Details
#<=>(other) ⇒ Object
:nodoc:
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
# File 'ext/ruby_prof.c', line 848
static VALUE
prof_method_cmp(VALUE self, VALUE other)
{
/* For call graphs we want to sort methods by
their total time, not self time. */
prof_method_t *x = get_prof_method(self);
prof_method_t *y = get_prof_method(other);
if (x->called == 0)
return INT2FIX(1);
else if (y->called == 0)
return INT2FIX(-1);
else if (x->total_time < y->total_time)
return INT2FIX(-1);
else if (x->total_time == y->total_time)
return INT2FIX(0);
else
return INT2FIX(1);
}
|
#called ⇒ MethodInfo
For recursively called methods, returns the base method. Otherwise, returns self.
785 786 787 788 789 790 791 792 793 794 795 796 797 |
# File 'ext/ruby_prof.c', line 785
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);
}
|
#called ⇒ Integer
Returns the number of times this method was called.
632 633 634 635 636 637 638 |
# File 'ext/ruby_prof.c', line 632
static VALUE
prof_method_called(VALUE self)
{
prof_method_t *result = get_prof_method(self);
return INT2NUM(result->called);
}
|
#children ⇒ Hash
Returns an array of call info objects of methods that this method called (ie, children).
835 836 837 838 839 840 841 842 843 844 845 |
# File 'ext/ruby_prof.c', line 835
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;
}
|
#children_time ⇒ Float
Returns the total amount of time spent in this method’s children.
691 692 693 694 695 696 697 |
# File 'ext/ruby_prof.c', line 691
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));
}
|
#full_name ⇒ String
Returns the full name of this method in the format Object#method.
773 774 775 776 777 778 |
# File 'ext/ruby_prof.c', line 773
static VALUE
prof_full_name(VALUE self)
{
prof_method_t *method = get_prof_method(self);
return full_name(method->klass, method->mid, method->depth);
}
|
#method_class ⇒ Object
Returns the Ruby klass that owns this method.
722 723 724 725 726 727 728 |
# File 'ext/ruby_prof.c', line 722
static VALUE
prof_method_klass(VALUE self)
{
prof_method_t *result = get_prof_method(self);
return result->klass;
}
|
#klass_name ⇒ String
Returns the name of this method’s class. Singleton classes will have the form <Object::Object>.
748 749 750 751 752 753 |
# File 'ext/ruby_prof.c', line 748
static VALUE
prof_klass_name(VALUE self)
{
prof_method_t *method = get_prof_method(self);
return klass_name(method->klass);
}
|
#line_no ⇒ Integer
returns the line number of the method
681 682 683 684 685 |
# File 'ext/ruby_prof.c', line 681
static VALUE
prof_method_line(VALUE self)
{
return rb_int_new(get_prof_method(self)->line);
}
|
#method_id ⇒ Object
Returns the id of this method.
734 735 736 737 738 739 740 |
# File 'ext/ruby_prof.c', line 734
static VALUE
prof_method_id(VALUE self)
{
prof_method_t *result = get_prof_method(self);
return ID2SYM(result->mid);
}
|
#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.
761 762 763 764 765 766 |
# File 'ext/ruby_prof.c', line 761
static VALUE
prof_method_name(VALUE self)
{
prof_method_t *method = get_prof_method(self);
return method_name(method->mid, method->depth);
}
|
#children ⇒ Hash
Returns an array of call info objects of methods that this method was called by (ie, parents).
817 818 819 820 821 822 823 824 825 826 827 |
# File 'ext/ruby_prof.c', line 817
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;
}
|
#self_time ⇒ Float
Returns the total amount of time spent in this method.
657 658 659 660 661 662 663 |
# File 'ext/ruby_prof.c', line 657
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));
}
|
#source_file ⇒ String
return the source file of the method
704 705 706 707 708 709 710 711 712 713 714 715 |
# File 'ext/ruby_prof.c', line 704
static VALUE prof_method_source_file(VALUE self)
{
const char* sf = get_prof_method(self)->source_file;
if(!sf)
{
return Qnil;
}
else
{
return rb_str_new2(sf);
}
}
|
#total_time ⇒ Float
Returns the total amount of time spent in this method and its children.
645 646 647 648 649 650 651 |
# File 'ext/ruby_prof.c', line 645
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));
}
|
#wait_time ⇒ Float
Returns the total amount of time this method waited for other threads.
669 670 671 672 673 674 675 |
# File 'ext/ruby_prof.c', line 669
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));
}
|