Skip to content

Instantly share code, notes, and snippets.

@memoryleak
Created July 29, 2022 14:47
Show Gist options
  • Save memoryleak/8b8a7b4e6ea16a70255fb566b5e94854 to your computer and use it in GitHub Desktop.
Save memoryleak/8b8a7b4e6ea16a70255fb566b5e94854 to your computer and use it in GitHub Desktop.
Disk Performance test
#!/usr/bin/env bash
if [ $# -eq 0 ]
then
echo "Please provide path to test file."
exit 1
fi
LOGFILE="./benchmark.log" #filename of the logfile
TESTFILE="$1"
iostat | tee -a "${LOGFILE}"
# sync randwrite = (writes 1G)
fio --filename=${TESTFILE} --name=sync_randwrite --rw=randwrite --bs=4k --direct=1 --sync=1 --numjobs=1 --ioengine=psync --iodepth=1 --refill_buffers --size=1G --loops=1 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
# sync randread (writes 1G)
fio --filename=${TESTFILE} --name=sync_randread --rw=randread --bs=4k --direct=1 --sync=1 --numjobs=1 --ioengine=psync --iodepth=1 --refill_buffers --size=1G --loops=10 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
# seq sync seqwrite (writes 5G)
fio --filename=${TESTFILE} --name=sync_seqwrite --rw=write --bs=4M --direct=1 --sync=1 --numjobs=1 --ioengine=psync --iodepth=1 --refill_buffers --size=5G --loops=1 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
# seq sync seqread (writes 1G)
fio --filename=${TESTFILE} --name=sync_seqread --rw=read --bs=4M --direct=1 --sync=1 --numjobs=1 --ioengine=psync --iodepth=1 --refill_buffers --size=1G --loops=10 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
#async uncached randwrite (writes 4G)
fio --filename=${TESTFILE} --name=async_uncached_randwrite --rw=randwrite --bs=4k --direct=1 --sync=0 --numjobs=4 --ioengine=libaio --iodepth=32 --refill_buffers --size=1G --loops=1 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
#async cached randwrite (writes 4G)
fio --filename=${TESTFILE} --name=async_cached_randwrite --rw=randwrite --bs=4k --direct=0 --sync=0 --numjobs=4 --ioengine=libaio --iodepth=32 --refill_buffers --size=1G --loops=1 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
#async uncached randread (writes 4G)
fio --filename=${TESTFILE} --name=async_uncached_randread --rw=randread --bs=4k --direct=1 --sync=0 --numjobs=4 --ioengine=libaio --iodepth=32 --refill_buffers --size=1G --loops=10 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
#async cached randread (writes 4G)
fio --filename=${TESTFILE} --name=async_cached_randread --rw=randread --bs=4k --direct=0 --sync=0 --numjobs=4 --ioengine=libaio --iodepth=32 --refill_buffers --size=1G --loops=10 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
#async uncached seqwrite (writes 8G)
fio --filename=${TESTFILE} --name=async_uncached_seqwrite --rw=write --bs=4M --direct=1 --sync=0 --numjobs=4 --ioengine=libaio --iodepth=32 --refill_buffers --size=2G --loops=1 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
#async cached seqwrite (writes 8G)
fio --filename=${TESTFILE} --name=async_cached_seqwrite --rw=write --bs=4M --direct=0 --sync=0 --numjobs=4 --ioengine=libaio --iodepth=32 --refill_buffers --size=2G --loops=1 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
#async uncached seqread (writes 4G)
fio --filename=${TESTFILE} --name=async_uncached_seqread --rw=read --bs=4M --direct=1 --sync=0 --numjobs=4 --ioengine=libaio --iodepth=32 --refill_buffers --size=1G --loops=50 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
#async cached seqread (writes 4G)
fio --filename=${TESTFILE} --name=async_cached_seqread --rw=read --bs=4M --direct=0 --sync=0 --numjobs=4 --ioengine=libaio --iodepth=32 --refill_buffers --size=1G --loops=50 --group_reporting | tee -a "${LOGFILE}"
rm ${TESTFILE}
fstrim -a
sleep 60
iostat | tee -a "${LOGFILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment