Sha256: 1eef1dcd5dc51a6a33ded61d4907cdf160d4d5dab5dbb993af3d4293cb49c5e0

Contents?: true

Size: 907 Bytes

Versions: 26

Compression:

Stored size: 907 Bytes

Contents

#!/usr/bin/env ruby
if ARGV.empty?
  $stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times]"
  exit(1)
end

# Keep the expensive require out of the profile.
$stderr.puts 'Loading Rails...'
require File.dirname(__FILE__) + '/../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
  require 'prof'
  $stderr.puts 'Using the ruby-prof extension.'
  Prof.clock_mode = Prof::GETTIMEOFDAY
  Prof.start
  profile_me
  results = Prof.stop
  require 'rubyprof_ext'
  Prof.print_profile(results, $stderr)
rescue LoadError
  $stderr.puts 'Using the standard Ruby profiler.'
  Profiler__.start_profile
  profile_me
  Profiler__.stop_profile
  Profiler__.print_profile($stderr)
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
typo-5.4.1 script/profiler
typo-5.4 script/profiler
typo-3.99.0 script/profiler
typo-3.99.1 script/profiler
typo-3.99.3 script/profiler
typo-3.99.2 script/profiler
typo-3.99.4 script/profiler
typo-4.0.1 script/profiler
typo-4.0.2 script/profiler
typo-4.0.0 script/profiler
typo-4.0.3 script/profiler
typo-4.1.1 script/profiler
typo-5.0.1 script/profiler
typo-4.1 script/profiler
typo-5.0.2 script/profiler
typo-5.0.3.98.1 script/profiler
typo-5.0 script/profiler
typo-5.0.3.98 script/profiler
typo-5.1.2 script/profiler
typo-5.1.1 script/profiler