Created
April 27, 2013 00:00
-
-
Save jelder/5471234 to your computer and use it in GitHub Desktop.
( while :; do date ; /usr/bin/time heroku run false ; sleep 1; done ) 2>&1 | ruby parse_bench.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
samples = [] | |
STDIN.lines.each do |line| | |
next if line =~ /^stty/ | |
next if line =~ /^Running/ | |
if line =~ /real.*user.*sys/ | |
real,_,user,_,sys = line.strip.split(/\s+/) | |
samples << [Float(real),Float(user),Float(sys)] | |
end | |
end | |
def percentile(values, percentile) | |
values_sorted = values.sort | |
k = (percentile*(values_sorted.length-1)+1).floor - 1 | |
f = (percentile*(values_sorted.length-1)+1).modulo(1) | |
return values_sorted[k] + (f * (values_sorted[k+1] - values_sorted[k])) | |
end | |
puts percentile(samples.map{|s|s[0]}, 0.95) | |
puts "#{samples.length} samples" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment