Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FIO benchmarking with stats per job
<?php
/**
* Agregate stats per job on a unique file compatible with fio2gnuplot
**/
if (!$argv[1]) {
echo "syntax: ".$argv[0]." <prefix-file>\n";
echo "Example : ".$argv[0]." nametest\n";
}
$tests = array('bw','lat','slat','clat','iops');
foreach ($tests as $testName) {
$files = glob($argv[1].'_'.$testName.'.*.log');
if (count($files) == 0) {
exit('cannot find files matching '.$argv[1].'_'.$testName.'.*.log');
}
$result = array();
foreach ($files as $file) {
$data = file($file);
foreach ($data as $lineNum => $line) {
$line = preg_split('@\s+@', $line);
$ts = $lineNum*1000;
for ($i = 1; $i<=3; $i++) {
if (!isset($result[$ts][$i])) $result[$ts][$i] = 0;
$result[$ts][$i] += $line[$i];
}
}
}
ksort($result);
$fileName = $argv[1].'_'.$testName.'.log';
$fp = fopen($fileName, 'w');
foreach ($result as $ts => $val) {
if (strpos($testName, 'lat') !== false) {
// average
foreach ($val as $i => $v)
$val[$i] = round($v/count($files));
}
fwrite($fp, $ts.', '.implode(', ', $val));
fwrite($fp, "\n");
}
fclose($fp);
echo "Written ".$fileName." (".filesize($fileName)." bytes)\n";
}
;COMMAND LINE :
;DIRTEST=/home/user/tests NAMETEST=appliance-version DEVICE=/dev/sdX fio file.fio
[global]
filename=${DEVICE}
numjobs=16
iodepth=256
ioengine=libaio
direct=1
time_based=1
runtime=300
stonewall
continue_on_error=all
group_reporting=1
per_job_logs=0
bwavgtime=1000
iopsavgtime=1000
log_avg_msec=1000
[random-write-4k]
rw=randwrite
bs=4k
write_bw_log=${DIRTEST}/${NAMETEST}-random-write-4k
write_iops_log=${DIRTEST}/${NAMETEST}-random-write-4k
write_lat_log=${DIRTEST}/${NAMETEST}-random-write-4k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.