Parent

Included Modules

Object

Constants

GCAttributes

Sentinel: HEAP[ 0]: size= 300000 HEAP[ 1]: size= 600000 ... number of requests processed: 1000 128334 nodes malloced for 17345 KB 396 leaks for 10464 total leaked bytes.

GCSummaries
PerfAttributes

/home/skaes/railsbench/script/perf_bench 100 -bm=all -mysql_session -patched_gc -links -OT

user     system      total        real

loading environment 0.954000 1.938000 2.892000 ( 2.890000) /empty/index 0.093000 0.000000 0.093000 ( 0.172000) /welcome/index 0.156000 0.000000 0.156000 ( 0.172000) /rezept/index 0.125000 0.015000 0.140000 ( 0.203000) /rezept/myknzlpzl 0.125000 0.000000 0.125000 ( 0.203000) /rezept/show/413 0.406000 0.094000 0.500000 ( 0.594000) /rezept/cat/Hauptspeise 0.547000 0.094000 0.641000 ( 0.688000) /rezept/cat/Hauptspeise?page=5 0.531000 0.047000 0.578000 ( 0.688000) /rezept/letter/G 0.422000 0.078000 0.500000 ( 0.609000) GC.collections=0, GC.time=0.0

user     system      total        real

loading environment 0.813000 2.078000 2.891000 ( 2.890000) /empty/index 0.125000 0.016000 0.141000 ( 0.157000) /welcome/index 0.109000 0.000000 0.109000 ( 0.187000) /rezept/index 0.110000 0.031000 0.141000 ( 0.219000) /rezept/myknzlpzl 0.109000 0.016000 0.125000 ( 0.219000) /rezept/show/413 0.422000 0.078000 0.500000 ( 0.625000) /rezept/cat/Hauptspeise 0.437000 0.125000 0.562000 ( 0.656000) /rezept/cat/Hauptspeise?page=5 0.453000 0.125000 0.578000 ( 0.688000) /rezept/letter/G 0.438000 0.000000 0.438000 ( 0.594000) GC.collections=0, GC.time=0.0

user     system      total        real

loading environment 0.938000 1.968000 2.906000 ( 2.906000) /empty/index 0.109000 0.000000 0.109000 ( 0.172000) /welcome/index 0.094000 0.031000 0.125000 ( 0.171000) /rezept/index 0.110000 0.047000 0.157000 ( 0.219000) /rezept/myknzlpzl 0.140000 0.016000 0.156000 ( 0.203000) /rezept/show/413 0.422000 0.047000 0.469000 ( 0.593000) /rezept/cat/Hauptspeise 0.515000 0.015000 0.530000 ( 0.672000) /rezept/cat/Hauptspeise?page=5 0.484000 0.063000 0.547000 ( 0.672000) /rezept/letter/G 0.453000 0.015000 0.468000 ( 0.610000) GC.collections=0, GC.time=0.0

PerfSummaries
RAILSBENCH_BINDIR

Public Instance Methods

benchmark_file_name(benchmark, config_name, prefix=nil, suffix=nil) click to toggle source
# File lib/railsbench/perf_utils.rb, line 110
def benchmark_file_name(benchmark, config_name, prefix=nil, suffix=nil)
  perf_data_dir = (ENV['RAILS_PERF_DATA'] ||= ENV['HOME'])
  date = Time.now.strftime '%m-%d'
  suffix = ".#{suffix}" if suffix
  ENV['RAILS_BENCHMARK_FILE'] =
    if config_name
      "#{perf_data_dir}/#{date}.#{benchmark}.#{config_name}#{suffix}.txt"
    else
      "#{perf_data_dir}/perf_run#{prefix}.#{benchmark}#{suffix}.txt"
    end
end
determine_rails_root_or_die!(msg=nil) click to toggle source
# File lib/railsbench/perf_utils.rb, line 35
def determine_rails_root_or_die!(msg=nil)
  unless ENV['RAILS_ROOT']
    if File.directory?("config") && File.exists?("config/environment.rb")
      ENV['RAILS_ROOT'] = File.expand_path(".")
    else
      die(msg || "#{File.basename $PROGRAM_NAME}: $RAILS_ROOT not set and could not be configured automatically")
    end
  end
end
die(msg, error_code=1) click to toggle source
# File lib/railsbench/perf_utils.rb, line 45
def die(msg, error_code=1)
  $stderr.puts msg
  exit error_code
end
disable_gc_stats() click to toggle source
# File lib/railsbench/perf_utils.rb, line 84
def disable_gc_stats
  ENV.delete 'RUBY_GC_STATS'
  ENV.delete 'RUBY_GC_DATA_FILE'
end
enable_gc_stats(file) click to toggle source
# File lib/railsbench/perf_utils.rb, line 79
def enable_gc_stats(file)
  ENV['RUBY_GC_STATS'] = "1"
  ENV['RUBY_GC_DATA_FILE'] = file
end
load_gc_variables(gc_spec) click to toggle source
# File lib/railsbench/perf_utils.rb, line 93
def load_gc_variables(gc_spec)
  File.open_or_die("#{ENV['RAILS_ROOT']}/config/#{gc_spec}.gc").each_line do |line|
    ENV[$1] = $2 if line =~ /^(?:export )?(.*)=(.*)$/
  end
end
perf_run(script, iterations, options, raw_data_file) click to toggle source
# File lib/railsbench/perf_utils.rb, line 130
def perf_run(script, iterations, options, raw_data_file)
  perf_runs = (ENV['RAILS_PERF_RUNS'] ||= "3").to_i

  disable_gc_stats
  set_gc_variables([iterations, options])

  perf_options = "#{iterations} #{options}"
  null = (RUBY_PLATFORM =~ /win32/) ? 'nul' : '/dev/null'

  perf_cmd = "#{ruby} #{RAILSBENCH_BINDIR}/perf_bench #{perf_options}"
  print_cmd = "#{ruby} #{RAILSBENCH_BINDIR}/perf_times #{raw_data_file}"

  puts "benchmarking #{perf_runs} runs with options #{perf_options}"

  File.open(raw_data_file, "w"){ |f| f.puts perf_cmd }
  perf_runs.times do
    system("#{perf_cmd} >#{null}") || die("#{script}: #{perf_cmd} returned #{$?}")
  end
  File.open(raw_data_file, "a" ){|f| f.puts }

  unset_gc_variables
  system(print_cmd) || die("#{script}: #{print_cmd} returned #{$?}")
end
perf_run_gc(script, iterations, options, raw_data_file) click to toggle source
# File lib/railsbench/perf_utils.rb, line 154
def perf_run_gc(script, iterations, options, raw_data_file)
  warmup = "-warmup"
  warmup = "" if options =~ /-warmup/

  enable_gc_stats(raw_data_file)
  set_gc_variables([options])

  perf_options = "#{iterations} #{warmup} #{options}"
  null = (RUBY_PLATFORM =~ /win32/) ? 'nul' : '/dev/null'

  perf_cmd = "#{ruby} #{RAILSBENCH_BINDIR}/run_urls #{perf_options} >#{null}"
  print_cmd = "#{ruby} #{RAILSBENCH_BINDIR}/perf_times_gc #{raw_data_file}"

  if options =~ /-leaks/
    if RUBY_PLATFORM =~ /darwin9/
      puts "enabling MallocStackLogging"
      perf_cmd.insert(0, "MallocStackLogging=1 ")
    else
      die "leak debugging not supported on #{RUBY_PLATFORM}"
    end
  end

  puts "benchmarking GC performance with options #{perf_options}"
  puts

  system(perf_cmd) || die("#{script}: #{perf_cmd} returned #{$?}")

  disable_gc_stats
  unset_gc_variables
  system(print_cmd) || die("#{script}: #{print_cmd} returned #{$?}")
end
quote_arguments(argv) click to toggle source
# File lib/railsbench/perf_utils.rb, line 122
def quote_arguments(argv)
  argv.map{|a| a.include?(' ') ? "'#{a}'" : a.to_s}.join(' ')
end
ruby() click to toggle source
# File lib/railsbench/perf_utils.rb, line 126
def ruby
  ENV['RUBY'] || "ruby"
end
set_gc_variables(argv) click to toggle source
# File lib/railsbench/perf_utils.rb, line 99
def set_gc_variables(argv)
  gc_spec = nil
  argv.each{|arg| gc_spec=$1 if arg =~ /-gc=([^ ]*)/}

  if gc_spec
    load_gc_variables(gc_spec)
  else
    unset_gc_variables
  end
end
stddev_percentage(stddev, mean) click to toggle source
# File lib/railsbench/perf_utils.rb, line 31
def stddev_percentage(stddev, mean)
  stddev.zero? ? 0.0 : (stddev/mean)*100
end
truncate(text, length = 32, truncate_string = "...") click to toggle source
# File lib/railsbench/perf_utils.rb, line 65
def truncate(text, length = 32, truncate_string = "...")
  if text.nil? then return "" end
  l = truncate_string.length + 1

  if RUBY_VERSION !~ /1.9/ && $KCODE == "NONE"
    text.length > length ? text[0..(length - l)] + truncate_string : text
  else
    chars = text.split(//)
    chars.length > length ? chars[0..(length - l)].join + truncate_string : text
  end
end
unset_gc_variables() click to toggle source
# File lib/railsbench/perf_utils.rb, line 89
def unset_gc_variables
  %(RUBY_HEAP_MIN_SLOTS RUBY_GC_MALLOC_LIMIT RUBY_HEAP_FREE_MIN).each{|v| ENV.delete v}
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.