speed up bench add param for iterations
This commit is contained in:
parent
1915f292ad
commit
b8184d8b92
|
@ -5,6 +5,7 @@ require "optparse"
|
||||||
|
|
||||||
@include_env = false
|
@include_env = false
|
||||||
@result_file = nil
|
@result_file = nil
|
||||||
|
@iterations = 500
|
||||||
opts = OptionParser.new do |o|
|
opts = OptionParser.new do |o|
|
||||||
o.banner = "Usage: ruby bench.rb [options]"
|
o.banner = "Usage: ruby bench.rb [options]"
|
||||||
|
|
||||||
|
@ -14,6 +15,9 @@ opts = OptionParser.new do |o|
|
||||||
o.on("-o", "--output [FILE]", "Output results to this file") do |f|
|
o.on("-o", "--output [FILE]", "Output results to this file") do |f|
|
||||||
@result_file = f
|
@result_file = f
|
||||||
end
|
end
|
||||||
|
o.on("-i", "--iterations [ITERATIONS]", "Number of iterations to run the bench for") do |i|
|
||||||
|
@iterations = i.to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
opts.parse!
|
opts.parse!
|
||||||
|
|
||||||
|
@ -25,9 +29,7 @@ begin
|
||||||
require 'facter'
|
require 'facter'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
run "gem install facter"
|
run "gem install facter"
|
||||||
puts "just installed the facter gem, rerunning script"
|
require 'facter'
|
||||||
exec("ruby " + [ File.absolute_path(__FILE__), __FILE__ ], *ARGV)
|
|
||||||
exit
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@timings = {}
|
@timings = {}
|
||||||
|
@ -86,11 +88,10 @@ if @include_env
|
||||||
ENV.delete "RUBY_FREE_MIN"
|
ENV.delete "RUBY_FREE_MIN"
|
||||||
else
|
else
|
||||||
# clean env
|
# clean env
|
||||||
puts "Running with default environment"
|
puts "Running with the following custom environment"
|
||||||
ENV.delete "RUBY_GC_MALLOC_LIMIT"
|
%w{RUBY_GC_MALLOC_LIMIT RUBY_HEAP_MIN_SLOTS RUBY_FREE_MIN}.each do |w|
|
||||||
ENV.delete "RUBY_HEAP_SLOTS_GROWTH_FACTOR"
|
puts "#{w}: #{ENV[w]}"
|
||||||
ENV.delete "RUBY_HEAP_MIN_SLOTS"
|
end
|
||||||
ENV.delete "RUBY_FREE_MIN"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def port_available? port
|
def port_available? port
|
||||||
|
@ -124,9 +125,9 @@ api_key = `bundle exec rake api_key:get`.split("\n")[-1]
|
||||||
|
|
||||||
def bench(path)
|
def bench(path)
|
||||||
puts "Running apache bench warmup"
|
puts "Running apache bench warmup"
|
||||||
`ab -n 100 "http://127.0.0.1:#{@port}#{path}"`
|
`ab -n 10 "http://127.0.0.1:#{@port}#{path}"`
|
||||||
puts "Benchmarking #{path}"
|
puts "Benchmarking #{path}"
|
||||||
`ab -n 500 -e tmp/ab.csv "http://127.0.0.1:#{@port}#{path}"`
|
`ab -n #{@iterations} -e tmp/ab.csv "http://127.0.0.1:#{@port}#{path}"`
|
||||||
|
|
||||||
percentiles = Hash[*[50, 75, 90, 99].zip([]).flatten]
|
percentiles = Hash[*[50, 75, 90, 99].zip([]).flatten]
|
||||||
CSV.foreach("tmp/ab.csv") do |percent, time|
|
CSV.foreach("tmp/ab.csv") do |percent, time|
|
||||||
|
|
Loading…
Reference in New Issue