Froze rails gems
[depot.git] / vendor / rails / railties / lib / rubyprof_ext.rb
1 require 'prof'
2
3 module Prof #:nodoc:
4 # Adapted from Shugo Maeda's unprof.rb
5 def self.print_profile(results, io = $stderr)
6 total = results.detect { |i|
7 i.method_class.nil? && i.method_id == :"#toplevel"
8 }.total_time
9 total = 0.001 if total < 0.001
10
11 io.puts " %% cumulative self self total"
12 io.puts " time seconds seconds calls ms/call ms/call name"
13
14 sum = 0.0
15 for r in results
16 sum += r.self_time
17
18 name = if r.method_class.nil?
19 r.method_id.to_s
20 elsif r.method_class.is_a?(Class)
21 "#{r.method_class}##{r.method_id}"
22 else
23 "#{r.method_class}.#{r.method_id}"
24 end
25 io.printf "%6.2f %8.3f %8.3f %8d %8.2f %8.2f %s\n",
26 r.self_time / total * 100,
27 sum,
28 r.self_time,
29 r.count,
30 r.self_time * 1000 / r.count,
31 r.total_time * 1000 / r.count,
32 name
33 end
34 end
35 end