class RubyProf::Profile

Public Instance Methods

exclude_common_methods!() click to toggle source

Hides methods that, when represented as a call graph, have extremely large in and out degrees and make navigation impossible.

   # File lib/ruby-prof/profile.rb
22 def exclude_common_methods!
23   ExcludeCommonMethods.apply!(self)
24 end
exclude_methods!(mod, *method_or_methods) click to toggle source
   # File lib/ruby-prof/profile.rb
26 def exclude_methods!(mod, *method_or_methods)
27   [method_or_methods].flatten.each do |name|
28     exclude_method!(mod, name)
29   end
30 end
exclude_singleton_methods!(mod, *method_or_methods) click to toggle source
   # File lib/ruby-prof/profile.rb
32 def exclude_singleton_methods!(mod, *method_or_methods)
33   exclude_methods!(mod.singleton_class, *method_or_methods)
34 end
measure_mode_string() click to toggle source
   # File lib/ruby-prof/profile.rb
 7 def measure_mode_string
 8   case self.measure_mode
 9     when WALL_TIME
10       "wall_time"
11     when PROCESS_TIME
12       "process_time"
13     when ALLOCATIONS
14       "allocations"
15     when MEMORY
16       "memory"
17   end
18 end
merge! → self click to toggle source

Merges RubyProf threads whose root call_trees reference the same target method. This is useful when profiling code that uses a main thread/fiber to distribute work to multiple workers. If there are tens or hundreds of workers, viewing results per worker thread/fiber can be overwhelming. Using merge! will combine the worker times together into one result.

Note the reported time will be much greater than the actual wall time. For example, if there are 10 workers that each run for 5 seconds, merged results will show one thread that ran for 50 seconds.

   # File lib/ruby-prof/profile.rb
48 def merge!
49   # First group threads by their root call tree target (method). If the methods are
50   # different than there is nothing to merge
51   grouped = threads.group_by do |thread|
52     thread.call_tree.target
53   end
54 
55   # For each target, get the first thread. Then loop over the remaining threads,
56   # and merge them into the first one and ten delete them. So we will be left with
57   # one thread per target.
58   grouped.each do |target, threads|
59     thread = threads.shift
60     threads.each do |other_thread|
61       thread.merge!(other_thread)
62       remove_thread(other_thread)
63     end
64     thread
65   end
66 
67   self
68 end