Class: RubyProf::CallInfo
- Inherits:
-
Data
- Object
- Data
- RubyProf::CallInfo
- Defined in:
- lib/ruby-prof/call_info.rb,
ext/ruby_prof/rp_call_info.c
Overview
The CallInfo class is used to track the relationships between methods. It is a helper class used by RubyProf::MethodInfo to keep track of which methods called a given method and which methods a given method called. Each CallInfo has a parent and target method. You cannot create a CallInfo object directly, they are generated while running a profile.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compares two CallInfo instances.
-
#_dump_data ⇒ Object
:nodoc:.
-
#_load_data(data) ⇒ Object
:nodoc:.
-
#called ⇒ Object
The number of times the parent method called the target method.
-
#children_time ⇒ Object
The time spent in child methods resulting from the parent method calling the target method.
-
#depth ⇒ Integer
returns the depth of this call info in the call graph.
- #inspect ⇒ Object
-
#line_no ⇒ Integer
returns the line number of the method.
-
#called ⇒ Measurement
Returns the measurement associated with this call_info.
-
#parent ⇒ Object
Returns the call_infos parent call_info object (the method that called this method).
-
#self_time ⇒ Object
The self time (of the parent) resulting from the parent method calling the target method.
-
#source_file ⇒ String
return the source file of the method.
-
#called ⇒ MethodInfo
Returns the target method.
-
#to_s ⇒ Object
:nodoc:.
-
#total_time ⇒ Object
The total time resulting from the parent method calling the target method.
-
#wait_time ⇒ Object
The wait time (of the parent) resulting from the parent method calling the target method.
Instance Method Details
#<=>(other) ⇒ Object
Compares two CallInfo instances. The comparison is based on the CallInfo#parent, CallInfo#target, and total time.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby-prof/call_info.rb', line 36 def <=>(other) if self.target == other.target && self.parent == other.parent 0 elsif self.total_time < other.total_time -1 elsif self.total_time > other.total_time 1 else self.target.full_name <=> other.target.full_name end end |
#_dump_data ⇒ Object
:nodoc:
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'ext/ruby_prof/rp_call_info.c', line 210
static VALUE
prof_call_info_dump(VALUE self)
{
prof_call_info_t* call_info_data = prof_get_call_info(self);
VALUE result = rb_hash_new();
rb_hash_aset(result, ID2SYM(rb_intern("measurement")), prof_measurement_wrap(call_info_data->measurement));
rb_hash_aset(result, ID2SYM(rb_intern("depth")), INT2FIX(call_info_data->depth));
rb_hash_aset(result, ID2SYM(rb_intern("source_file")), call_info_data->source_file);
rb_hash_aset(result, ID2SYM(rb_intern("source_line")), INT2FIX(call_info_data->source_line));
rb_hash_aset(result, ID2SYM(rb_intern("parent")), prof_call_info_parent(self));
rb_hash_aset(result, ID2SYM(rb_intern("target")), prof_call_info_target(self));
return result;
}
|
#_load_data(data) ⇒ Object
:nodoc:
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'ext/ruby_prof/rp_call_info.c', line 229
static VALUE
prof_call_info_load(VALUE self, VALUE data)
{
VALUE target = Qnil;
VALUE parent = Qnil;
prof_call_info_t* call_info = prof_get_call_info(self);
call_info->object = self;
VALUE measurement = rb_hash_aref(data, ID2SYM(rb_intern("measurement")));
call_info->measurement = prof_get_measurement(measurement);
call_info->depth = FIX2INT(rb_hash_aref(data, ID2SYM(rb_intern("depth"))));
call_info->source_file = rb_hash_aref(data, ID2SYM(rb_intern("source_file")));
call_info->source_line = FIX2INT(rb_hash_aref(data, ID2SYM(rb_intern("source_line"))));
parent = rb_hash_aref(data, ID2SYM(rb_intern("parent")));
if (parent != Qnil)
call_info->parent = prof_method_get(parent);
target = rb_hash_aref(data, ID2SYM(rb_intern("target")));
call_info->method = prof_method_get(target);
return data;
}
|
#called ⇒ Object
The number of times the parent method called the target method
10 11 12 |
# File 'lib/ruby-prof/call_info.rb', line 10 def called self.measurement.called end |
#children_time ⇒ Object
The time spent in child methods resulting from the parent method calling the target method
30 31 32 |
# File 'lib/ruby-prof/call_info.rb', line 30 def children_time self.total_time - self.self_time - self.wait_time end |
#depth ⇒ Integer
returns the depth of this call info in the call graph
179 180 181 182 183 184 |
# File 'ext/ruby_prof/rp_call_info.c', line 179
static VALUE
prof_call_info_depth(VALUE self)
{
prof_call_info_t *result = prof_get_call_info(self);
return rb_int_new(result->depth);
}
|
#inspect ⇒ Object
53 54 55 |
# File 'lib/ruby-prof/call_info.rb', line 53 def inspect super + "(#{self.to_s})" end |
#line_no ⇒ Integer
returns the line number of the method
202 203 204 205 206 207 |
# File 'ext/ruby_prof/rp_call_info.c', line 202
static VALUE
prof_call_info_line(VALUE self)
{
prof_call_info_t *result = prof_get_call_info(self);
return INT2FIX(result->source_line);
}
|
#called ⇒ Measurement
Returns the measurement associated with this call_info.
168 169 170 171 172 173 |
# File 'ext/ruby_prof/rp_call_info.c', line 168
static VALUE
prof_call_info_measurement(VALUE self)
{
prof_call_info_t* call_info = prof_get_call_info(self);
return prof_measurement_wrap(call_info->measurement);
}
|
#parent ⇒ Object
Returns the call_infos parent call_info object (the method that called this method).
143 144 145 146 147 148 149 150 151 |
# File 'ext/ruby_prof/rp_call_info.c', line 143
static VALUE
prof_call_info_parent(VALUE self)
{
prof_call_info_t* call_info = prof_get_call_info(self);
if (call_info->parent)
return prof_method_wrap(call_info->parent);
else
return Qnil;
}
|
#self_time ⇒ Object
The self time (of the parent) resulting from the parent method calling the target method
20 21 22 |
# File 'lib/ruby-prof/call_info.rb', line 20 def self_time self.measurement.self_time end |
#source_file ⇒ String
return the source file of the method
191 192 193 194 195 196 |
# File 'ext/ruby_prof/rp_call_info.c', line 191
static VALUE
prof_call_info_source_file(VALUE self)
{
prof_call_info_t* result = prof_get_call_info(self);
return result->source_file;
}
|
#called ⇒ MethodInfo
Returns the target method.
157 158 159 160 161 162 |
# File 'ext/ruby_prof/rp_call_info.c', line 157
static VALUE
prof_call_info_target(VALUE self)
{
prof_call_info_t *call_info = prof_get_call_info(self);
return prof_method_wrap(call_info->method);
}
|
#to_s ⇒ Object
:nodoc:
49 50 51 |
# File 'lib/ruby-prof/call_info.rb', line 49 def to_s "#{parent ? parent.full_name : '<nil>'} - #{target.full_name}" end |
#total_time ⇒ Object
The total time resulting from the parent method calling the target method
15 16 17 |
# File 'lib/ruby-prof/call_info.rb', line 15 def total_time self.measurement.total_time end |
#wait_time ⇒ Object
The wait time (of the parent) resulting from the parent method calling the target method
25 26 27 |
# File 'lib/ruby-prof/call_info.rb', line 25 def wait_time self.measurement.wait_time end |