Sha256: cce278cef41d3391f415511318c9935b03238720872c13976b2784a2afd919e3

Contents?: true

Size: 985 Bytes

Versions: 74

Compression:

Stored size: 985 Bytes

Contents

require 'prof'

module Prof #:nodoc:
  # Adapted from Shugo Maeda's unprof.rb
  def self.print_profile(results, io = $stderr)
    total = results.detect { |i|
      i.method_class.nil? && i.method_id == :"#toplevel"
    }.total_time
    total = 0.001 if total < 0.001

    io.puts "  %%   cumulative   self              self     total"
    io.puts " time   seconds   seconds    calls  ms/call  ms/call  name"

    sum = 0.0
    results.each do |r|
      sum += r.self_time

      name =  if r.method_class.nil?
                r.method_id.to_s
              elsif r.method_class.is_a?(Class)
                "#{r.method_class}##{r.method_id}"
              else
                "#{r.method_class}.#{r.method_id}"
              end
      io.printf "%6.2f %8.3f  %8.3f %8d %8.2f %8.2f  %s\n",
        r.self_time / total * 100,
        sum,
        r.self_time,
        r.count,
        r.self_time * 1000 / r.count,
        r.total_time * 1000 / r.count,
        name
    end
  end
end

Version data entries

74 entries across 74 versions & 4 rubygems

Version Path
railties-4.1.16 lib/rails/rubyprof_ext.rb
railties-4.1.16.rc1 lib/rails/rubyprof_ext.rb
railties-4.1.15 lib/rails/rubyprof_ext.rb
railties-4.1.15.rc1 lib/rails/rubyprof_ext.rb
railties-4.1.14.2 lib/rails/rubyprof_ext.rb
railties-4.1.14.1 lib/rails/rubyprof_ext.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/railties-4.1.13/lib/rails/rubyprof_ext.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/railties-4.1.13/lib/rails/rubyprof_ext.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/railties-4.1.13/lib/rails/rubyprof_ext.rb
railties-4.1.14 lib/rails/rubyprof_ext.rb
railties-4.1.14.rc2 lib/rails/rubyprof_ext.rb
railties-4.1.14.rc1 lib/rails/rubyprof_ext.rb
railties-4.1.13 lib/rails/rubyprof_ext.rb
railties-4.1.13.rc1 lib/rails/rubyprof_ext.rb
railties-4.1.12 lib/rails/rubyprof_ext.rb
railties-4.1.12.rc1 lib/rails/rubyprof_ext.rb
railties-4.1.11 lib/rails/rubyprof_ext.rb
railties-4.1.10 lib/rails/rubyprof_ext.rb
railties-4.1.10.rc4 lib/rails/rubyprof_ext.rb
railties-4.1.10.rc3 lib/rails/rubyprof_ext.rb