Class: RubyProf::Result
- Inherits:
-
Object
- Object
- RubyProf::Result
- Defined in:
- ext/ruby_prof.c,
ext/ruby_prof.c
Overview
The RubyProf::Result class is used to store the results of a profiling run. And instace of the class is returned from the methods RubyProf#stop and RubyProf#profile.
RubyProf::Result has one field, called threads, which is a hash table keyed on thread ID. For each thread id, the hash table stores another hash table that contains profiling information for each method called during the threads execution. That hash table is keyed on method name and contains RubyProf::MethodInfo objects.
Instance Method Summary collapse
-
#threads ⇒ Hash
Returns a hash table keyed on thread ID.
-
#toplevel(thread_id) ⇒ Object
Returns the RubyProf::MethodInfo object that represents the root calling method for this thread.
Instance Method Details
#threads ⇒ Hash
Returns a hash table keyed on thread ID. For each thread id, the hash table stores another hash table that contains profiling information for each method called during the threads execution. That hash table is keyed on method name and contains RubyProf::MethodInfo objects.
1206 1207 1208 1209 1210 1211 |
# File 'ext/ruby_prof.c', line 1206 static VALUE prof_result_threads(VALUE self) { prof_result_t *prof_result = get_prof_result(self); return prof_result->threads; } |
#thread_id=(int) ⇒ Object #toplevel(thread_id) ⇒ RubyProf::MethodInfo
Returns the RubyProf::MethodInfo object that represents the root calling method for this thread. This method will always be named #toplevel and contains the total amount of time spent executing code in this thread.
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 |
# File 'ext/ruby_prof.c', line 1222 static VALUE prof_result_toplevel(VALUE self, VALUE thread_id) { prof_result_t *prof_result = get_prof_result(self); VALUE methods = rb_hash_aref(prof_result->threads, thread_id); VALUE key = method_name(Qnil, toplevel_id); VALUE result = rb_hash_aref(methods, key); if (result == Qnil) { /* Should never happen */ rb_raise(rb_eRuntimeError, "Could not find toplevel method information"); } return result; } |