Sha256: 39ca017fe2527d7569eee65f9b2bda33254566bdc7510fc80b6abefc290e3f4e

Contents?: true

Size: 1.17 KB

Versions: 19

Compression:

Stored size: 1.17 KB

Contents

require 'optparse'
require 'rails/test_help'
require 'rails/performance_test_help'
require 'active_support/testing/performance'

def options
  options = {}
  defaults = ActiveSupport::Testing::Performance::DEFAULTS

  OptionParser.new do |opt|
    opt.banner = "Usage: rails benchmarker 'Ruby.code' 'Ruby.more_code' ... [OPTS]"
    opt.on('-r', '--runs N', Numeric, 'Number of runs.', "Default: #{defaults[:runs]}") { |r| options[:runs] = r }
    opt.on('-o', '--output PATH', String, 'Directory to use when writing the results.', "Default: #{defaults[:output]}") { |o| options[:output] = o }
    opt.on('-m', '--metrics a,b,c', Array, 'Metrics to use.', "Default: #{defaults[:metrics].join(",")}") { |m| options[:metrics] = m.map(&:to_sym) }
    opt.on('-f', '--formats x,y,z', Array, 'Formats to output to.', "Default: #{defaults[:formats].join(",")}") { |m| options[:formats] = m.map(&:to_sym) }
    opt.parse!(ARGV)
  end

  options
end

class ProfilerTest < ActionDispatch::PerformanceTest #:nodoc:
  self.profile_options = options

  ARGV.each do |expression|
    eval <<-RUBY
      def test_#{expression.parameterize('_')}
        #{expression}
      end
    RUBY
  end
  ARGV.clear
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
railties-3.2.22.5 lib/rails/commands/profiler.rb
railties-3.2.22.4 lib/rails/commands/profiler.rb
railties-3.2.22.3 lib/rails/commands/profiler.rb
railties-3.2.22.2 lib/rails/commands/profiler.rb
railties-3.2.22.1 lib/rails/commands/profiler.rb
railties-3.2.22 lib/rails/commands/profiler.rb
railties-3.2.21 lib/rails/commands/profiler.rb
railties-3.2.20 lib/rails/commands/profiler.rb
railties-3.2.19 lib/rails/commands/profiler.rb
railties-3.2.18 lib/rails/commands/profiler.rb
railties-3.2.17 lib/rails/commands/profiler.rb
railties-3.2.16 lib/rails/commands/profiler.rb
railties-3.2.15 lib/rails/commands/profiler.rb
railties-3.2.15.rc3 lib/rails/commands/profiler.rb
railties-3.2.15.rc2 lib/rails/commands/profiler.rb
railties-3.2.15.rc1 lib/rails/commands/profiler.rb
railties-3.2.14 lib/rails/commands/profiler.rb
railties-3.2.14.rc2 lib/rails/commands/profiler.rb
railties-3.2.14.rc1 lib/rails/commands/profiler.rb