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.
Methods
public instance
Included modules
- Comparable
Public instance methods
# File lib/ruby-prof/method_info.rb, line 5 5: def <=>(other) 6: if self.total_time < other.total_time 7: -1 8: elsif self.total_time > other.total_time 9: 1 10: elsif self.min_depth < other.min_depth 11: 1 12: elsif self.min_depth > other.min_depth 13: -1 14: else 15: -1 * (self.full_name <=> other.full_name) 16: end 17: end
# File lib/ruby-prof/method_info.rb, line 94 94: def aggregate_children 95: # Group call info's based on their targets 96: groups = self.children.inject(Hash.new) do |hash, call_info| 97: key = call_info.target 98: (hash[key] ||= []) << call_info 99: hash 100: end 101: 102: groups.map do |key, value| 103: AggregateCallInfo.new(value) 104: end 105: end
# File lib/ruby-prof/method_info.rb, line 81 81: def aggregate_parents 82: # Group call info's based on their parents 83: groups = self.call_infos.inject(Hash.new) do |hash, call_info| 84: key = call_info.parent ? call_info.parent.target : self 85: (hash[key] ||= []) << call_info 86: hash 87: end 88: 89: groups.map do |key, value| 90: AggregateCallInfo.new(value) 91: end 92: end
call_infos → Array of call_info
Returns an array of call info objects that contain profiling information about the current method.
/* call-seq:
call_infos -> Array of call_info
Returns an array of call info objects that contain profiling information
about the current method.*/
static VALUE
prof_method_call_infos(VALUE self)
{
prof_method_t *method = get_prof_method(self);
return prof_call_infos_wrap(method->call_infos);
}
# File lib/ruby-prof/method_info.rb, line 19 19: def called 20: @called ||= begin 21: call_infos.inject(0) do |sum, call_info| 22: sum += call_info.called 23: end 24: end 25: end
# File lib/ruby-prof/method_info.rb, line 73 73: def children 74: @children ||= begin 75: call_infos.map do |call_info| 76: call_info.children 77: end.flatten 78: end 79: end
# File lib/ruby-prof/method_info.rb, line 51 51: def children_time 52: @children_time ||= begin 53: call_infos.inject(0) do |sum, call_info| 54: sum += call_info.children_time 55: end 56: end 57: end
full_name → string
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->key->klass, method->key->mid, method->key->depth);
}
method_class → klass
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->key->klass;
}
klass_name → string
Returns the name of this method’s class. Singleton classes will have
the form
/* 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->key->klass);
}
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_method_line(VALUE self)
{
return rb_int_new(get_prof_method(self)->line);
}
method_id → ID
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->key->mid);
}
method_name → string
Returns the name of this method in the format Object#method. Singletons
methods will be returned in the format
/* 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, int depth)
{
prof_method_t *method = get_prof_method(self);
return method_name(method->key->mid, depth);
}
# File lib/ruby-prof/method_info.rb, line 59 59: def min_depth 60: call_infos.map do |call_info| 61: call_info.depth 62: end.min 63: end
# File lib/ruby-prof/method_info.rb, line 65 65: def root? 66: @root ||= begin 67: call_infos.find do |call_info| 68: not call_info.root? 69: end.nil? 70: end 71: end
# File lib/ruby-prof/method_info.rb, line 35 35: def self_time 36: @self_time ||= begin 37: call_infos.inject(0) do |sum, call_info| 38: sum += call_info.self_time 39: end 40: end 41: end
source_file => string
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);
}
}
# File lib/ruby-prof/method_info.rb, line 107 107: def to_s 108: full_name 109: end
# File lib/ruby-prof/method_info.rb, line 27 27: def total_time 28: @total_time ||= begin 29: call_infos.inject(0) do |sum, call_info| 30: sum += call_info.total_time 31: end 32: end 33: end
# File lib/ruby-prof/method_info.rb, line 43 43: def wait_time 44: @wait_time ||= begin 45: call_infos.inject(0) do |sum, call_info| 46: sum += call_info.wait_time 47: end 48: end 49: end