Sha256: 58cc87ec21d746ab44b8462594d248a620bf33210cc2e6a4bb9b87039ed6f761

Contents?: true

Size: 1.36 KB

Versions: 59

Compression:

Stored size: 1.36 KB

Contents

if ARGV.empty?
  $stderr.puts "Usage: ./script/performance/profiler 'Person.expensive_method(10)' [times] [flat|graph|graph_html]"
  exit(1)
end

# Keep the expensive require out of the profile.
$stderr.puts 'Loading Rails...'
require RAILS_ROOT + '/config/environment'

# Define a method to profile.
if ARGV[1] and ARGV[1].to_i > 1
  eval "def profile_me() #{ARGV[1]}.times { #{ARGV[0]} } end"
else
  eval "def profile_me() #{ARGV[0]} end"
end

# Use the ruby-prof extension if available.  Fall back to stdlib profiler.
begin
  begin
    require "ruby-prof"
    $stderr.puts 'Using the ruby-prof extension.'
    RubyProf.measure_mode = RubyProf::WALL_TIME
    RubyProf.start
    profile_me
    results = RubyProf.stop
    if ARGV[2]
      printer_class = RubyProf.const_get((ARGV[2] + "_printer").classify)
    else
      printer_class = RubyProf::FlatPrinter
    end
    printer = printer_class.new(results)
    printer.print($stderr)
  rescue LoadError
    require "prof"
    $stderr.puts 'Using the old ruby-prof extension.'
    Prof.clock_mode = Prof::GETTIMEOFDAY
    Prof.start
    profile_me
    results = Prof.stop
    require 'rubyprof_ext'
    Prof.print_profile(results, $stderr)
  end
rescue LoadError
  require 'profiler'
  $stderr.puts 'Using the standard Ruby profiler.'
  Profiler__.start_profile
  profile_me
  Profiler__.stop_profile
  Profiler__.print_profile($stderr)
end

Version data entries

59 entries across 59 versions & 11 rubygems

Version Path
rails-2.3.18 lib/commands/performance/profiler.rb
rails_csi-2.3.5.p8 lib/commands/performance/profiler.rb
rails-2.3.17 lib/commands/performance/profiler.rb
rails_csi-2.3.5.p7 lib/commands/performance/profiler.rb
rails_csi-2.3.5.p6 lib/commands/performance/profiler.rb
rails-2.3.16 lib/commands/performance/profiler.rb
rails-2.3.15 lib/commands/performance/profiler.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rails-2.3.14/lib/commands/performance/profiler.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/rails-2.3.12/lib/commands/performance/profiler.rb
rails-2.3.14 lib/commands/performance/profiler.rb
kajam-1.0.3.rc2 vendor/rails/railties/lib/commands/performance/profiler.rb
rails-2.3.12 lib/commands/performance/profiler.rb
radiant-1.0.0.rc2 vendor/rails/railties/lib/commands/performance/profiler.rb
radiant-1.0.0.rc1 vendor/rails/railties/lib/commands/performance/profiler.rb
webroar-0.5.0 src/admin_panel/vendor/rails/railties/lib/commands/performance/profiler.rb
rails-2.3.11 lib/commands/performance/profiler.rb
radiantcms-couchrest_model-0.2.4 vendor/rails/railties/lib/commands/performance/profiler.rb
radiantcms-couchrest_model-0.2.2 vendor/rails/railties/lib/commands/performance/profiler.rb
radiantcms-couchrest_model-0.2.1 vendor/rails/railties/lib/commands/performance/profiler.rb
radiantcms-couchrest_model-0.2 vendor/rails/railties/lib/commands/performance/profiler.rb