Sha256: 128e03a56ad778c6a427564647cfc0fa9e391e0e6d43653017c1d89bcc375b5a

Contents?: true

Size: 1.36 KB

Versions: 17

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, 0)
  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

17 entries across 17 versions & 7 rubygems

Version Path
radiant-0.7.2 vendor/rails/railties/lib/commands/performance/profiler.rb
vibes-bj-1.2.2 spec/rails_root/vendor/rails/railties/lib/commands/performance/profiler.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/railties/lib/commands/performance/profiler.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/railties/lib/commands/performance/profiler.rb
rails-2.2.3 lib/commands/performance/profiler.rb
webroar-0.2.2 src/admin_panel/vendor/rails/railties/lib/commands/performance/profiler.rb
antfarm-0.3.0 rails/vendor/rails/railties/lib/commands/performance/profiler.rb
antfarm-0.4.0 rails/vendor/rails/railties/lib/commands/performance/profiler.rb
erails-2.1.2 lib/commands/performance/profiler.rb
radiant-0.7.0 vendor/rails/railties/lib/commands/performance/profiler.rb
radiant-0.8.0 vendor/rails/railties/lib/commands/performance/profiler.rb
radiant-0.7.1 vendor/rails/railties/lib/commands/performance/profiler.rb
rails-2.1.0 lib/commands/performance/profiler.rb
rails-2.1.2 lib/commands/performance/profiler.rb
rails-2.1.1 lib/commands/performance/profiler.rb
rails-2.3.2 lib/commands/performance/profiler.rb
rails-2.2.2 lib/commands/performance/profiler.rb