Skip to content

Instantly share code, notes, and snippets.

Created December 28, 2010 20:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/757641 to your computer and use it in GitHub Desktop.
Save anonymous/757641 to your computer and use it in GitHub Desktop.
BEGIN {
lastUrl = "";
performanceHistory[1] = 0;
hitCount = 0;
total = 0;
print "Page\tCount\t95th\tAverage";
}
function EraseData()
{
for (i in performanceHistory) {
delete performanceHistory[i];
}
hitCount = 0;
total = 0;
}
function OutputLine()
{
if (lastUrl == "") {
return;
}
targetElt = int(0.95 * hitCount);
if (0 == targetElt) {
targetElt++;
}
print lastUrl "\t" hitCount "\t" performanceHistory[targetElt] "\t" (total / hitCount);
}
// {
nextUrl = tolower($1);
if (nextUrl != lastUrl) {
OutputLine();
EraseData();
lastUrl = nextUrl;
}
hitCount++;
performanceHistory[hitCount] = $2;
total += $2;
}
END {
OutputLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment