Skip to content

Instantly share code, notes, and snippets.

@fukayatsu
Created August 17, 2013 07:25
Show Gist options
  • Save fukayatsu/6255716 to your computer and use it in GitHub Desktop.
Save fukayatsu/6255716 to your computer and use it in GitHub Desktop.
# usage:
# $ git bisect start HEAD [past good commit]
# $ git bisect run ruby ab_bisect.rb
require 'systemu'
systemu 'bundle'
systemu 'bundle exec rails s -d'
sleep 5
# abコマンドでベンチマーク
status, stdout, stderr = systemu "ab -n 10 -c 10 'http://0.0.0.0:3000/'"
Process.kill 'KILL', `cat tmp/pids/server.pid`.to_i
sleep 3
# Requests per secondを抽出
stdout =~ /Requests per second:\s+([0-9\.]+)/
request_per_second = $1.to_f
puts "request_per_second: #{request_per_second}"
if request_per_second < 1.0
puts 'bad'
exit 1
end
puts 'good'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment