Created
March 11, 2010 02:00
-
-
Save mattknox/328722 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
function step_std_dev(val) { | |
n += 1 | |
delta = val - mean | |
mean = mean + delta/n | |
M2 = M2 + delta*(val - mean) # This expression uses the new value of mean | |
if (n > 1) { | |
variance_n = M2/n | |
variance = M2/(n - 1) | |
} | |
} | |
BEGIN { | |
sum = 0 | |
max = 0 | |
count = 0 | |
min = 1000000000000000 | |
n = 0 | |
mean = 0 | |
M2 = 0 | |
} | |
{ requests += 1 } | |
{ sum += $2 } | |
{ step_std_dev($2) } | |
{ if ($1 > max) max = $1 } | |
{ if ($1 < min) min = $1 } | |
END { | |
seconds = (max - min) / 1000 | |
printf( "requests: %d\n sum: %d\n elapsed time: %d seconds\n rate: %f req/s\n mean: %f\n stddev: %f\n\n", | |
requests, sum, seconds, requests / seconds, mean, sqrt(variance)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment