Created
September 21, 2012 15:46
-
-
Save gcatlin/3762264 to your computer and use it in GitHub Desktop.
crappy ab output parser
This file contains 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
<?php | |
$files = array_slice($argv, 1); | |
echo "[cache],[concurrency_level],[time],[requests],[failures],[requests_per_second],[time_per_request],[concurrent_time_per_request],[transfer_rate],[p50],[p66],[p75],[p80],[p90],[p95],[p98],[p99],[max]\n"; | |
foreach ($files as $file) { | |
if (in_array(array('run', 'summarize.php'), $files)) { | |
continue; | |
} | |
$lines = file($file, FILE_IGNORE_NEW_LINES); | |
if (count($lines) != 46) { | |
// delete the file? | |
continue; | |
} | |
$cache = substr($file, 0 , strpos($file, '-')); | |
$concurrency_level = substr($lines[15], 24); | |
$time = substr(substr($lines[16], 24), 0, strpos($lines[16], ' ', 24) - 24); | |
$requests = substr($lines[17], 24); | |
$failures = substr($lines[18], 24); | |
$requests_per_second = substr(substr($lines[24], 24), 0, strpos($lines[24], ' ', 24) - 24); | |
$time_per_request = substr(substr($lines[25], 24), 0, strpos($lines[25], ' ', 24) - 24); | |
$concurrent_time_per_request = substr(substr($lines[26], 24), 0, strpos($lines[26], ' ', 24) - 24); | |
$transfer_rate = substr(substr($lines[27], 24), 0, strpos($lines[27], ' ', 24) - 24); | |
$p50 = trim(substr($lines[37], 5)); | |
$p66 = trim(substr($lines[38], 5)); | |
$p75 = trim(substr($lines[39], 5)); | |
$p80 = trim(substr($lines[40], 5)); | |
$p90 = trim(substr($lines[41], 5)); | |
$p95 = trim(substr($lines[42], 5)); | |
$p98 = trim(substr($lines[43], 5)); | |
$p99 = trim(substr($lines[44], 5)); | |
$max = substr(trim(substr($lines[45], 5)), 0, strpos(trim(substr($lines[45], 5)), ' ')); | |
echo "{$file},{$cache},{$concurrency_level},{$time},{$requests},{$failures},{$requests_per_second},{$time_per_request},{$concurrent_time_per_request},{$transfer_rate},{$p50},{$p66},{$p75},{$p80},{$p90},{$p95},{$p98},{$p99},{$max}\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment