also bench a topic page

This commit is contained in:
Sam 2013-08-15 17:13:05 +10:00
parent d753cdb2f7
commit 5d4d72c19d

View file

@ -66,10 +66,10 @@ rescue Errno::EADDRINUSE
false false
end end
port = 60079 @port = 60079
while !port_available? port while !port_available? @port
port += 1 @port += 1
end end
puts "Ensuring profiling DB exists and is migrated" puts "Ensuring profiling DB exists and is migrated"
@ -84,27 +84,35 @@ end
puts "Populating Profile DB" puts "Populating Profile DB"
run("bundle exec ruby script/profile_db_generator.rb") run("bundle exec ruby script/profile_db_generator.rb")
begin def bench(path)
pid = spawn("bundle exec thin start -p #{port}")
while port_available? port
sleep 1
end
puts "Running apache bench warmup" puts "Running apache bench warmup"
`ab -n 100 http://localhost:#{port}/` `ab -n 100 http://localhost:#{@port}#{path}`
puts "Benchmarking front page" puts "Benchmarking #{path}"
`ab -n 100 -e tmp/ab.csv http://localhost:#{port}/` `ab -n 100 -e tmp/ab.csv http://localhost:#{@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|
percentiles[percent.to_i] = time.to_i if percentiles.key? percent.to_i percentiles[percent.to_i] = time.to_i if percentiles.key? percent.to_i
end end
percentiles
end
begin
pid = spawn("bundle exec thin start -p #{@port}")
while port_available? @port
sleep 1
end
home_page = bench("/")
topic_page = bench("/t/oh-how-i-wish-i-could-shut-up-like-a-tunnel-for-so/69")
puts "Your Results:" puts "Your Results:"
puts({ puts({
"home_page" => percentiles, "home_page" => home_page,
"topic_page" => topic_page,
"timings" => @timings "timings" => @timings
}.to_yaml) }.to_yaml)