Sha256: fa48e2f98e2c023404cfc2a61ee7fd9e28263aba2a791e18a1e44980cebebde6

Contents?: true

Size: 1.04 KB

Versions: 28

Compression:

Stored size: 1.04 KB

Contents

require 'optparse'
require 'rails/test_help'
require 'rails/performance_test_help'

ARGV.push('--benchmark') # HAX
require 'active_support/testing/performance'
ARGV.pop

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.parse!(ARGV)
  end

  options
end

class BenchmarkerTest < ActionDispatch::PerformanceTest
  self.profile_options = options

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

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
railties-3.1.12 lib/rails/commands/benchmarker.rb
railties-3.1.11 lib/rails/commands/benchmarker.rb
railties-3.1.10 lib/rails/commands/benchmarker.rb
railties-3.1.9 lib/rails/commands/benchmarker.rb
railties-3.1.8 lib/rails/commands/benchmarker.rb
railties-3.1.7 lib/rails/commands/benchmarker.rb
railties-3.1.6 lib/rails/commands/benchmarker.rb
railties-3.1.5 lib/rails/commands/benchmarker.rb
railties-3.1.5.rc1 lib/rails/commands/benchmarker.rb
railties-3.1.4 lib/rails/commands/benchmarker.rb
railties-3.1.4.rc1 lib/rails/commands/benchmarker.rb
railties-3.2.0.rc2 lib/rails/commands/benchmarker.rb
railties-3.2.0.rc1 lib/rails/commands/benchmarker.rb
railties-3.1.3 lib/rails/commands/benchmarker.rb
railties-3.1.2 lib/rails/commands/benchmarker.rb
railties-3.1.2.rc2 lib/rails/commands/benchmarker.rb
railties-3.1.2.rc1 lib/rails/commands/benchmarker.rb
railties-3.1.1 lib/rails/commands/benchmarker.rb
railties-3.1.1.rc3 lib/rails/commands/benchmarker.rb
railties-3.1.1.rc2 lib/rails/commands/benchmarker.rb