Created
March 20, 2010 14:43
-
-
Save dcampano/338702 to your computer and use it in GitHub Desktop.
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/ruby | |
def print_responses(times) | |
%w{ 0.95 0.99 0.995 0.999 }.each do |percentile| | |
pos = (percentile.to_f * times.length).floor | |
p pos.to_s + ": " + times[pos].to_s | |
end | |
end | |
num = 0 | |
rows_to_process = 1000000 | |
times = [] | |
IO.popen("tail -n #{rows_to_process} /opt/nginx/logs/upstream.log | grep -v lobby.php"){|f| | |
while line = f.gets | |
response_time = line.split(' ')[0].to_f | |
times.push response_time | |
#p response_time | |
num = num + 1 | |
break if num > rows_to_process | |
end | |
} | |
times.sort! | |
print_responses times | |
p "finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment