Skip to content

Commit d397b17

Browse files
authored
Merge pull request #35 from redhat-performance/jsonification
Jsonification of fio output and updates to built-in data reduction to handle it
2 parents 885e56b + 0035f83 commit d397b17

1 file changed

Lines changed: 54 additions & 18 deletions

File tree

fio/fio_run

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -254,22 +254,58 @@ report_info()
254254
echo $1 >> /tmp/log
255255
}
256256

257+
#
258+
# Averaging function for json formatted bw and iops
259+
#
257260
obtain_avg()
258261
{
259-
value=`grep "${1}" fio-result.txt | grep max | cut -d'=' -f ${2} | grep -v percentiles | cut -d',' -f 1`
260-
nitems=0
261-
calc="scale=2;("
262-
field_separ=""
263-
for val in $value; do
264-
calc="${calc}${field_separ}$val"
265-
let "nitems=$nitems+1"
266-
field_separ="+"
267-
done
268-
calc="${calc})/${nitems}"
262+
FIELD=${1}
263+
value=`jq '.. | select(type == "object" and has('\"$FIELD\"')).'\"$FIELD\"'' fio-results.json`
264+
nitems=0
265+
calc="scale=2;("
266+
field_separ=""
267+
for val in $value; do
268+
calc="${calc}${field_separ}$val"
269+
let "nitems=$nitems+1"
270+
field_separ="+"
271+
done
272+
if [ ${nitems} -eq 0]; then
273+
calc=0
274+
else
275+
# Divide by 3 since the json output includes all three I/O types and we only care about one
276+
calc="${calc})/(${nitems}/3)"
277+
fi
269278
rtval=`echo $calc | bc`
270-
echo $rtval
279+
echo $rtval
271280
}
272281

282+
#
283+
# A latency-specific averaging function to handle how the json output is formatted for clat, lat, and slat
284+
#
285+
obtain_avg_lat()
286+
{
287+
FIELD=${1}
288+
value=`jq '.. | select(type == "object" and has('\"$FIELD\"')).'\"$FIELD\"'.mean' fio-results.json`
289+
nitems=0
290+
calc="scale=2;("
291+
field_separ=""
292+
for val in $value; do
293+
calc="${calc}${field_separ}$val"
294+
let "nitems=$nitems+1"
295+
field_separ="+"
296+
done
297+
if [ ${nitems} -eq 0]; then
298+
calc=0
299+
else
300+
# Divide by 3 since the json output includes all three I/O types and we only care about one
301+
# Divide by 1000 because the json output is nsec but usec is a bit more friendly for now
302+
calc="${calc})/(${nitems}/3)/1000"
303+
fi
304+
rtval=`echo $calc | bc`
305+
echo $rtval
306+
}
307+
308+
273309
reduce_data()
274310
{
275311
file=`ls -d fio* | head -n 1`
@@ -300,11 +336,11 @@ reduce_data()
300336
if [ -d "$dir" ]; then
301337
fname=`echo $dir | cut -d'-' -f 2-30`
302338
cd $dir
303-
bw=$(obtain_avg "bw" 5)
304-
iops=$(obtain_avg "iops" 4)
305-
clat=$(obtain_avg "clat" 4)
306-
slat=$(obtain_avg "slat" 4)
307-
lat=$(obtain_avg " lat (usec" 4)
339+
bw=$(obtain_avg "bw_mean")
340+
iops=$(obtain_avg "iops")
341+
clat=$(obtain_avg_lat "clat_ns")
342+
slat=$(obtain_avg_lat "slat_ns")
343+
lat=$(obtain_avg_lat "lat_ns")
308344
echo "${njobs}:${ndisks}:${iodepth}:${bw}" >> $rdir/results_${fname}/results_bw.csv
309345
echo "${njobs}:${ndisks}:${iodepth}:${iops}" >> $rdir/results_${fname}/results_iops.csv
310346
echo "${njobs}:${ndisks}:${iodepth}:${slat}" >> $rdir/results_${fname}/results_slat.csv
@@ -652,9 +688,9 @@ loop_io_tests()
652688
build_run_file $ios $ioe $iodepth $njobs $run_time $disk_list $io_test
653689
cp /tmp/fio_run ${out_dir}/file_run_${test_index}
654690
let "test_index=${test_index}+1"
655-
fio /tmp/fio_run >> $rdir/fio-result.txt
691+
fio --output-format=json /tmp/fio_run >> $rdir/fio-results.json
656692
mv *.log $rdir # preserve raw data
657-
lines=`wc -l $rdir/fio-result.txt | cut -d' ' -f 1`
693+
lines=`wc -l $rdir/fio-results.json | cut -d' ' -f 1`
658694
if [ $lines -lt 2 ]; then
659695
run_results="Failed"
660696
fi

0 commit comments

Comments
 (0)