Class: RubyProf::Measurement
- Inherits:
-
Object
- Object
- RubyProf::Measurement
- Defined in:
- lib/ruby-prof/measurement.rb,
ext/ruby_prof/rp_measurement.c
Overview
The Measurement class is a helper class used by RubyProf::MethodInfo to store information about the method. You cannot create a CallTree object directly, they are generated while running a profile.
Instance Method Summary collapse
-
#_dump_data ⇒ Object
:nodoc:.
-
#_load_data(data) ⇒ Object
:nodoc:.
-
#called ⇒ Integer
Returns the total amount of times this method was called.
-
#called= ⇒ Object
Sets the call count to n.
- #children_time ⇒ Object
- #inspect ⇒ Object
-
#self_time ⇒ Float
Returns the total amount of time spent in this 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
#_dump_data ⇒ Object
:nodoc:
188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'ext/ruby_prof/rp_measurement.c', line 188
static VALUE
prof_measurement_dump(VALUE self)
{
prof_measurement_t* measurement_data = prof_get_measurement(self);
VALUE result = rb_hash_new();
rb_hash_aset(result, ID2SYM(rb_intern("total_time")), rb_float_new(measurement_data->total_time));
rb_hash_aset(result, ID2SYM(rb_intern("self_time")), rb_float_new(measurement_data->self_time));
rb_hash_aset(result, ID2SYM(rb_intern("wait_time")), rb_float_new(measurement_data->wait_time));
rb_hash_aset(result, ID2SYM(rb_intern("called")), INT2FIX(measurement_data->called));
return result;
}
|
#_load_data(data) ⇒ Object
:nodoc:
203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'ext/ruby_prof/rp_measurement.c', line 203
static VALUE
prof_measurement_load(VALUE self, VALUE data)
{
prof_measurement_t* measurement = prof_get_measurement(self);
measurement->object = self;
measurement->total_time = rb_num2dbl(rb_hash_aref(data, ID2SYM(rb_intern("total_time"))));
measurement->self_time = rb_num2dbl(rb_hash_aref(data, ID2SYM(rb_intern("self_time"))));
measurement->wait_time = rb_num2dbl(rb_hash_aref(data, ID2SYM(rb_intern("wait_time"))));
measurement->called = FIX2INT(rb_hash_aref(data, ID2SYM(rb_intern("called"))));
return data;
}
|
#called ⇒ Integer
Returns the total amount of times this method was called.
170 171 172 173 174 |
# File 'ext/ruby_prof/rp_measurement.c', line 170
static VALUE prof_measurement_called(VALUE self)
{
prof_measurement_t* result = prof_get_measurement(self);
return INT2NUM(result->called);
}
|
#called= ⇒ Object
Sets the call count to n.
180 181 182 183 184 185 |
# File 'ext/ruby_prof/rp_measurement.c', line 180
static VALUE prof_measurement_set_called(VALUE self, VALUE called)
{
prof_measurement_t* result = prof_get_measurement(self);
result->called = NUM2INT(called);
return called;
}
|
#children_time ⇒ Object
5 6 7 |
# File 'lib/ruby-prof/measurement.rb', line 5 def children_time self.total_time - self.self_time - self.wait_time end |
#inspect ⇒ Object
13 14 15 |
# File 'lib/ruby-prof/measurement.rb', line 13 def inspect super + "(#{self.to_s})" end |
#self_time ⇒ Float
Returns the total amount of time spent in this method.
147 148 149 150 151 152 153 |
# File 'ext/ruby_prof/rp_measurement.c', line 147
static VALUE
prof_measurement_self_time(VALUE self)
{
prof_measurement_t* result = prof_get_measurement(self);
return rb_float_new(result->self_time);
}
|
#to_s ⇒ Object
9 10 11 |
# File 'lib/ruby-prof/measurement.rb', line 9 def to_s "c: #{called}, tt: #{total_time}, st: #{self_time}" end |
#total_time ⇒ Float
Returns the total amount of time spent in this method and its children.
137 138 139 140 141 |
# File 'ext/ruby_prof/rp_measurement.c', line 137
static VALUE prof_measurement_total_time(VALUE self)
{
prof_measurement_t* result = prof_get_measurement(self);
return rb_float_new(result->total_time);
}
|
#wait_time ⇒ Float
Returns the total amount of time this method waited for other threads.
159 160 161 162 163 164 |
# File 'ext/ruby_prof/rp_measurement.c', line 159
static VALUE prof_measurement_wait_time(VALUE self)
{
prof_measurement_t* result = prof_get_measurement(self);
return rb_float_new(result->wait_time);
}
|