Class/Module Index [+]

Quicksearch

ActiveSupport::Testing::Performance::Benchmarker

Constants

HEADER

Public Instance Methods

environment() click to toggle source
# File lib/active_support/testing/performance.rb, line 122
def environment
  unless defined? @env
    require 'rails/version'
    app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/

    rails = Rails::VERSION::STRING
    if File.directory?('vendor/rails/.git')
      Dir.chdir('vendor/rails') do
        rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/
      end
    end

    ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
    ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"

    @env = [app, rails, ruby, RUBY_PLATFORM] * ','
  end

  @env
end
record() click to toggle source
# File lib/active_support/testing/performance.rb, line 114
def record
  avg = @metric.total / profile_options[:runs].to_i
  now = Time.now.utc.xmlschema
  with_output_file do |file|
    file.puts "#{avg},#{now},#{environment}"
  end
end
run() click to toggle source
# File lib/active_support/testing/performance.rb, line 109
def run
  profile_options[:runs].to_i.times { run_test(@metric, :benchmark) }
  @total = @metric.total
end

Protected Instance Methods

output_filename() click to toggle source
# File lib/active_support/testing/performance.rb, line 159
def output_filename
  "#{super}.csv"
end
with_output_file() click to toggle source
# File lib/active_support/testing/performance.rb, line 146
def with_output_file
  fname = output_filename

  if new = !File.exist?(fname)
    FileUtils.mkdir_p(File.dirname(fname))
  end

  File.open(fname, 'ab') do |file|
    file.puts(HEADER) if new
    yield file
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.