Skip to content

Instantly share code, notes, and snippets.

@youyo
Created February 23, 2015 11:40
Show Gist options
  • Select an option

  • Save youyo/0bca9672ad665b33c262 to your computer and use it in GitHub Desktop.

Select an option

Save youyo/0bca9672ad665b33c262 to your computer and use it in GitHub Desktop.
#!/bin/bash -u
#BS=('4k' '16k' '1m')
#TYPE=('read' 'write' 'randread' 'randwrite')
#IODEPTH=(1 2 4 8 16 32 64)
BS=('4k')
TYPE=('read' 'write' 'randread' 'randwrite')
IODEPTH=(1 2 4 8 16 32 64)
OUTPUT='/tmp/fio.json'
BASE_CMD='fio -ioengine=libaio -direct=1 -invalidate=1 -filename=/tmp/fio.bin -size=10G -numjobs=1 -runtime=60 -group_reporting -name=fio --output-format=json'
rm -f $OUTPUT{}
for blocksize in ${BS[@]}; do
for rwtype in ${TYPE[@]}; do
TMPIOPS=()
TMPBW=()
for iodepth in ${IODEPTH[@]}; do
TMPFILE=`mktemp`
${BASE_CMD} -rw=${rwtype} -bs=${blocksize} -iodepth=${iodepth} --output ${TMPFILE}
case ${rwtype} in
'read' )
IOPS=`cat ${TMPFILE} | jq ."jobs[0].read.iops"`
BW=`cat ${TMPFILE} | jq ."jobs[0].read.bw"`
;;
'randread' )
IOPS=`cat ${TMPFILE} | jq ."jobs[0].read.iops"`
BW=`cat ${TMPFILE} | jq ."jobs[0].read.bw"`
;;
'write' )
IOPS=`cat ${TMPFILE} | jq ."jobs[0].write.iops"`
BW=`cat ${TMPFILE} | jq ."jobs[0].write.bw"`
;;
'randwrite' )
IOPS=`cat ${TMPFILE} | jq ."jobs[0].write.iops"`
BW=`cat ${TMPFILE} | jq ."jobs[0].write.bw"`
;;
esac
TMPIOPS+=( ${IOPS} )
TMPBW+=( ${BW} )
rm -f ${TMPFILE}
sleep 60
done
echo "{\"blocksize\": \"${blocksize}\", \"rwtype\": \"${rwtype}\", \"iops\": [`echo ${TMPIOPS[@]} | tr -s ' ' ','`], \"bw\": [`echo ${TMPBW[@]} | tr -s ' ' ','`]}" >> ${OUTPUT}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment