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:
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 |
# File 'ext/ruby_prof.c', line 851
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.
788 789 790 791 792 793 794 795 796 797 798 799 800 |
# File 'ext/ruby_prof.c', line 788
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.
635 636 637 638 639 640 641 |
# File 'ext/ruby_prof.c', line 635
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).
838 839 840 841 842 843 844 845 846 847 848 |
# File 'ext/ruby_prof.c', line 838
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.
694 695 696 697 698 699 700 |
# File 'ext/ruby_prof.c', line 694
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.
776 777 778 779 780 781 |
# File 'ext/ruby_prof.c', line 776
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.
725 726 727 728 729 730 731 |
# File 'ext/ruby_prof.c', line 725
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>.
751 752 753 754 755 756 |
# File 'ext/ruby_prof.c', line 751
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
684 685 686 687 688 |
# File 'ext/ruby_prof.c', line 684
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.
737 738 739 740 741 742 743 |
# File 'ext/ruby_prof.c', line 737
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.
764 765 766 767 768 769 |
# File 'ext/ruby_prof.c', line 764
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).
820 821 822 823 824 825 826 827 828 829 830 |
# File 'ext/ruby_prof.c', line 820
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.
660 661 662 663 664 665 666 |
# File 'ext/ruby_prof.c', line 660
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
707 708 709 710 711 712 713 714 715 716 717 718 |
# File 'ext/ruby_prof.c', line 707
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);
}
}
|
#total_time ⇒ Float
Returns the total amount of time spent in this method and its children.
648 649 650 651 652 653 654 |
# File 'ext/ruby_prof.c', line 648
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.
672 673 674 675 676 677 678 |
# File 'ext/ruby_prof.c', line 672
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));
}
|