Class: RubyProf::Thread
- Inherits:
-
Object
- Object
- RubyProf::Thread
- Defined in:
- lib/ruby-prof/thread.rb,
ext/ruby_prof/rp_thread.c
Instance Method Summary collapse
-
#fiber_id ⇒ Numeric
Returns the fiber id of this thread.
-
#id ⇒ Numeric
Returns the id of this thread.
-
#index ⇒ Numeric
Returns the index of this thread.
-
#main? ⇒ Boolean
Returns the true if this is the main thread.
-
#methods ⇒ Array of MethodInfo
Returns an array of methods that were called from this thread during program execution.
- #top_call_infos ⇒ Object
- #top_methods ⇒ Object
- #total_time ⇒ Object
- #wait_time ⇒ Object
Instance Method Details
#fiber_id ⇒ Numeric
Returns the fiber id of this thread.
277 278 279 280 281 282 |
# File 'ext/ruby_prof/rp_thread.c', line 277
static VALUE
prof_fiber_id(VALUE self)
{
thread_data_t* thread = prof_get_thread(self);
return thread->fiber_id;
}
|
#id ⇒ Numeric
Returns the id of this thread.
266 267 268 269 270 271 |
# File 'ext/ruby_prof/rp_thread.c', line 266
static VALUE
prof_thread_id(VALUE self)
{
thread_data_t* thread = prof_get_thread(self);
return thread->thread_id;
}
|
#index ⇒ Numeric
Returns the index of this thread.
244 245 246 247 248 249 |
# File 'ext/ruby_prof/rp_thread.c', line 244
static VALUE
prof_thread_index(VALUE self)
{
thread_data_t* thread = prof_get_thread(self);
return ULL2NUM(thread->thread_index);
}
|
#main? ⇒ Boolean
Returns the true if this is the main thread.
255 256 257 258 259 260 |
# File 'ext/ruby_prof/rp_thread.c', line 255
static VALUE
prof_thread_main(VALUE self)
{
thread_data_t* thread = prof_get_thread(self);
return thread->thread_index == 0 ? Qtrue : Qfalse;
}
|
#methods ⇒ Array of MethodInfo
Returns an array of methods that were called from this thread during program execution.
289 290 291 292 293 294 295 296 297 298 299 |
# File 'ext/ruby_prof/rp_thread.c', line 289
static VALUE
prof_thread_methods(VALUE self)
{
thread_data_t* thread = prof_get_thread(self);
if (thread->methods == Qnil)
{
thread->methods = rb_ary_new();
st_foreach(thread->method_table, collect_methods, thread->methods);
}
return thread->methods;
}
|
#top_call_infos ⇒ Object
9 10 11 |
# File 'lib/ruby-prof/thread.rb', line 9 def top_call_infos top_methods.map(&:call_infos).flatten.select(&:root?) end |
#top_methods ⇒ Object
3 4 5 6 7 |
# File 'lib/ruby-prof/thread.rb', line 3 def top_methods self.methods.select do |method_info| method_info.call_infos.detect(&:root?) end end |
#total_time ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby-prof/thread.rb', line 13 def total_time self.top_methods.inject(0) do |sum, method_info| method_info.call_infos.each do |call_info| if call_info.parent.nil? sum += call_info.total_time end end sum end end |
#wait_time ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby-prof/thread.rb', line 24 def wait_time # wait_time, like self:time, is always method local # thus we need to sum over all methods and call infos self.methods.inject(0) do |sum, method_info| method_info.call_infos.each do |call_info| sum += call_info.wait_time end sum end end |