Class: RubyProf::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-prof/thread.rb,
ext/ruby_prof/rp_thread.c

Instance Method Summary collapse

Instance Method Details

#detect_recursionObject

This method detect recursive calls in the call tree of a given thread It should be called only once for each thread



15
16
17
# File 'lib/ruby-prof/thread.rb', line 15

def detect_recursion
  top_call_infos.each(&:detect_recursion)
end

#fiber_idNumeric

Returns the fiber id of this thread.

Returns:

  • (Numeric)


236
237
238
239
240
241
# File 'ext/ruby_prof/rp_thread.c', line 236

static VALUE
prof_fiber_id(VALUE self)
{
    thread_data_t* thread = prof_get_thread(self);
	return thread->fiber_id;
}

#idNumeric

Returns the id of this thread.

Returns:

  • (Numeric)


225
226
227
228
229
230
# File 'ext/ruby_prof/rp_thread.c', line 225

static VALUE
prof_thread_id(VALUE self)
{
    thread_data_t* thread = prof_get_thread(self);
	return thread->thread_id;
}

#methodsArray of MethodInfo

Returns an array of methods that were called from this thread during program execution.

Returns:



248
249
250
251
252
253
254
255
256
257
258
# File 'ext/ruby_prof/rp_thread.c', line 248

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;
}

#recalc_recursionObject



19
20
21
# File 'lib/ruby-prof/thread.rb', line 19

def recalc_recursion
  top_call_infos.each(&:recalc_recursion)
end

#top_call_infosObject



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_methodsObject



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_timeObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/ruby-prof/thread.rb', line 23

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