Merge pull request #4810 from yjukaku/fix-minor-bench-script-bugs

Fix bench script
This commit is contained in:
Guo Xiang Tan 2017-04-27 10:41:57 +08:00 committed by GitHub
commit 5404fb31f8
2 changed files with 7 additions and 5 deletions

View File

@ -49,13 +49,15 @@ def run(command, opt = nil)
system(command, out: $stdout, err: :out)
end
exit unless exit_status
abort("Command '#{command}' failed with exit status #{$?}") unless exit_status
end
begin
require 'facter'
rescue LoadError
run "gem install facter"
# Facter requires CFPropertyList, but doesn't install it.
run "gem install CFPropertyList"
puts "please rerun script"
exit
end
@ -151,12 +153,12 @@ run("bundle exec ruby script/profile_db_generator.rb")
puts "Getting api key"
api_key = `bundle exec rake api_key:get`.split("\n")[-1]
def bench(path)
def bench(path, name)
puts "Running apache bench warmup"
add = ""
add = "-c 3 " if @unicorn
`ab #{add} -n 10 "http://127.0.0.1:#{@port}#{path}"`
puts "Benchmarking #{path}"
puts "Benchmarking #{name} @ #{path}"
`ab -n #{@iterations} -e tmp/ab.csv "http://127.0.0.1:#{@port}#{path}"`
percentiles = Hash[*[50, 75, 90, 99].zip([]).flatten]
@ -212,7 +214,7 @@ begin
results = {}
@best_of.times do
tests.each do |name, url|
results[name] = best_of(bench(url),results[name])
results[name] = best_of(bench(url, name),results[name])
end
end

View File

@ -44,7 +44,7 @@ end
def create_admin(seq)
User.new.tap { |admin|
admin.email = "admin@localhost#{seq}"
admin.email = "admin@localhost#{seq}.fake"
admin.username = "admin#{seq}"
admin.password = "password"
admin.save