profiler.rb

Path: lib/profiler.rb
Last Update: Thu Jul 11 05:43:10 +0000 2013

Methods

Public Instance methods

[Source]

    # File lib/profiler.rb, line 32
32:   def print_profile(f)
33:     stop_profile
34:     total = Process.times[0] - @@start
35:     if total == 0 then total = 0.01 end
36:     data = @@map.values
37:     data.sort!{|a,b| b[2] <=> a[2]}
38:     sum = 0
39:     f.printf "  %%   cumulative   self              self     total\n"
40:     f.printf " time   seconds   seconds    calls  ms/call  ms/call  name\n"
41:     for d in data
42:       sum += d[2]
43:       f.printf "%6.2f %8.2f  %8.2f %8d ", d[2]/total*100, sum, d[2], d[0]
44:       f.printf "%8.2f %8.2f  %s\n", d[2]*1000/d[0], d[1]*1000/d[0], get_name(*d[3])
45:     end
46:     f.printf "%6.2f %8.2f  %8.2f %8d ", 0.0, total, 0.0, 1     # ???
47:     f.printf "%8.2f %8.2f  %s\n", 0.0, total*1000, "#toplevel" # ???
48:   end

[Source]

    # File lib/profiler.rb, line 23
23:   def start_profile
24:     @@start = Process.times[0]
25:     @@stack = []
26:     @@map = {}
27:     set_trace_func PROFILE_PROC
28:   end

[Source]

    # File lib/profiler.rb, line 29
29:   def stop_profile
30:     set_trace_func nil
31:   end

Private Instance methods

[Source]

    # File lib/profiler.rb, line 49
49:   def get_name(klass, id)
50:     name = klass.to_s || ""
51:     if klass.kind_of? Class
52:       name += "#"
53:     else
54:       name += "."
55:     end
56:     name + id.id2name
57:   end

[Validate]