Class: RubyProf::CallInfo
- Inherits:
-
Object
- Object
- RubyProf::CallInfo
- Defined in:
- ext/ruby_prof.c,
lib/ruby-prof/call_info.rb,
ext/ruby_prof.c
Overview
RubyProf::CallInfo is a helper class used by RubyProf::MethodInfo to keep track of which child methods were called and how long they took to execute.
Instance Method Summary collapse
- #call_sequence ⇒ Object
-
#called ⇒ Integer
Returns the total amount of time this method was called.
-
#children ⇒ Hash
Returns an array of call info objects of methods that this method called (ie, children).
- #children_time ⇒ Object
- #depth ⇒ Object
-
#line_no ⇒ Integer
returns the line number of the method.
-
#parent ⇒ Object
Returns the call_infos parent call_info object (the method that called this method).
- #root? ⇒ Boolean
-
#self_time ⇒ Float
Returns the total amount of time spent in this method.
- #stack ⇒ Object
-
#called ⇒ MethodInfo
Returns the target method.
- #to_s ⇒ Object
-
#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
#call_sequence ⇒ Object
33 34 35 36 37 |
# File 'lib/ruby-prof/call_info.rb', line 33 def call_sequence @call_sequence ||= begin stack.map {|method| method.full_name}.join('->') end end |
#called ⇒ Integer
Returns the total amount of time this method was called.
382 383 384 385 386 387 |
# File 'ext/ruby_prof.c', line 382
static VALUE
prof_call_info_called(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
return INT2NUM(result->called);
}
|
#children ⇒ Hash
Returns an array of call info objects of methods that this method called (ie, children).
463 464 465 466 467 468 469 470 471 472 473 |
# File 'ext/ruby_prof.c', line 463
static VALUE
prof_call_info_children(VALUE self)
{
prof_call_info_t *call_info = prof_get_call_info_result(self);
if (call_info->children == Qnil)
{
call_info->children = rb_ary_new();
st_foreach(call_info->call_infos, prof_call_info_collect_children, call_info->children);
}
return call_info->children;
}
|
#children_time ⇒ Object
14 15 16 17 18 |
# File 'lib/ruby-prof/call_info.rb', line 14 def children_time children.inject(0) do |sum, call_info| sum += call_info.total_time end end |
#depth ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/ruby-prof/call_info.rb', line 3 def depth result = 0 call_info = self.parent while call_info result += 1 call_info = call_info.parent end result end |
#line_no ⇒ Integer
returns the line number of the method
393 394 395 396 397 398 |
# File 'ext/ruby_prof.c', line 393
static VALUE
prof_call_info_line(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
return rb_int_new(result->line);
}
|
#parent ⇒ Object
Returns the call_infos parent call_info object (the method that called this method).
439 440 441 442 443 444 445 446 447 |
# File 'ext/ruby_prof.c', line 439
static VALUE
prof_call_info_parent(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
if (result->parent)
return prof_call_info_wrap(result->parent);
else
return Qnil;
}
|
#root? ⇒ Boolean
39 40 41 |
# File 'lib/ruby-prof/call_info.rb', line 39 def root? self.parent.nil? end |
#self_time ⇒ Float
Returns the total amount of time spent in this method.
415 416 417 418 419 420 421 |
# File 'ext/ruby_prof.c', line 415
static VALUE
prof_call_info_self_time(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
return rb_float_new(convert_measurement(result->self_time));
}
|
#stack ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby-prof/call_info.rb', line 20 def stack @stack ||= begin methods = Array.new call_info = self while call_info methods << call_info.target call_info = call_info.parent end methods.reverse end end |
#called ⇒ MethodInfo
Returns the target method.
367 368 369 370 371 372 373 374 375 376 |
# File 'ext/ruby_prof.c', line 367
static VALUE
prof_call_info_target(VALUE self)
{
/* 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! */
prof_call_info_t *result = prof_get_call_info_result(self);
return prof_method_wrap(result->target);
}
|
#to_s ⇒ Object
43 44 45 |
# File 'lib/ruby-prof/call_info.rb', line 43 def to_s "#{call_sequence}" end |
#total_time ⇒ Float
Returns the total amount of time spent in this method and its children.
404 405 406 407 408 409 |
# File 'ext/ruby_prof.c', line 404
static VALUE
prof_call_info_total_time(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(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.
427 428 429 430 431 432 433 |
# File 'ext/ruby_prof.c', line 427
static VALUE
prof_call_info_wait_time(VALUE self)
{
prof_call_info_t *result = prof_get_call_info_result(self);
return rb_float_new(convert_measurement(result->wait_time));
}
|