Last active
December 9, 2024 14:13
-
-
Save DamianPala/f8edb62dc322e9d1402e9cf639fe0385 to your computer and use it in GitHub Desktop.
Disk benchmark script using FIO
This file contains hidden or 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
| #!/bin/bash | |
| # This script is based on https://unix.stackexchange.com/revisions/480191/9 | |
| RUNTIME=30 # Single test duration | |
| is_installed() { | |
| dpkg -s "$1" &> /dev/null | |
| } | |
| if ! is_installed fio; then | |
| sudo apt install fio | |
| fi | |
| if ! is_installed jq; then | |
| sudo apt install jq | |
| fi | |
| if [ -z $1 ]; then | |
| TARGET=$(pwd) | |
| else | |
| TARGET="$1" | |
| fi | |
| echo "Testing in $TARGET" | |
| echo "Configuration: | |
| Single test runtime = $RUNTIME | |
| Running Benchmark, please wait... | |
| " | |
| fio --runtime=$RUNTIME --size=1g --io_size=100g --filename="$TARGET/.fiomark.tmp" --stonewall --ioengine=libaio --direct=1 --output-format=json --output "$TARGET/.fiomark.txt" \ | |
| --name=SEQ1MQ8T1read --bs=1024k --iodepth=8 --numjobs=1 --fsync=10000 --rw=read \ | |
| --name=SEQ1MQ8T1write --bs=1024k --iodepth=8 --numjobs=1 --fsync=10000 --rw=write \ | |
| --name=SEQ1MQ1T1read --bs=1024k --iodepth=1 --numjobs=1 --fsync=10000 --rw=read \ | |
| --name=SEQ1MQ1T1write --bs=1024k --iodepth=1 --numjobs=1 --fsync=10000 --rw=write \ | |
| --name=RND4KQ32T1read --bs=4k --iodepth=32 --numjobs=1 --fsync=1 --rw=randread \ | |
| --name=RND4KQ32T1write --bs=4k --iodepth=32 --numjobs=1 --fsync=1 --rw=randwrite \ | |
| --name=RND4KQ1T1read --bs=4k --iodepth=1 --numjobs=1 --fsync=1 --rw=randread \ | |
| --name=RND4KQ1T1write --bs=4k --iodepth=1 --numjobs=1 --fsync=1 --rw=randwrite | |
| QUERY='def read_bw(name): [.jobs[] | select(.jobname==name+"read").read.bw] | add / 1024 | floor; | |
| def read_iops(name): [.jobs[] | select(.jobname==name+"read").read.iops] | add | floor; | |
| def write_bw(name): [.jobs[] | select(.jobname==name+"write").write.bw] | add / 1024 | floor; | |
| def write_iops(name): [.jobs[] | select(.jobname==name+"write").write.iops] | add | floor; | |
| def job_summary(name): read_bw(name), read_iops(name), write_bw(name), write_iops(name); | |
| job_summary("SEQ1MQ8T1"), job_summary("SEQ1MQ1T1"), job_summary("RND4KQ32T1"), job_summary("RND4KQ1T1")' | |
| read -d '\n' -ra V <<< "$(jq "$QUERY" "$TARGET/.fiomark.txt")" | |
| echo -e " | |
| Results: | |
| SEQ1MQ8T1 Read | BW: \033[0;32m${V[0]} MB/s\033[0m IOPS: \033[0;32m${V[1]}\033[0m | |
| SEQ1MQ8T1 Write | BW: \033[0;32m${V[2]} MB/s\033[0m IOPS: \033[0;32m${V[3]}\033[0m | |
| SEQ1MQ1T1 Read | BW: \033[0;32m${V[4]} MB/s\033[0m IOPS: \033[0;32m${V[5]}\033[0m | |
| SEQ1MQ1T1 Write | BW: \033[0;32m${V[6]} MB/s\033[0m IOPS: \033[0;32m${V[7]}\033[0m | |
| RND4KQ32T1 Read | BW: \033[0;32m${V[8]} MB/s\033[0m IOPS: \033[0;32m${V[9]}\033[0m | |
| RND4KQ32T1 Write | BW: \033[0;32m${V[10]} MB/s\033[0m IOPS: \033[0;32m${V[11]}\033[0m | |
| RND4KQ1T1 Read | BW: \033[0;32m${V[12]} MB/s\033[0m IOPS: \033[0;32m${V[13]}\033[0m | |
| RND4KQ1T1 Write | BW: \033[0;32m${V[14]} MB/s\033[0m IOPS: \033[0;32m${V[15]}\033[0m" | |
| rm "$TARGET/.fiomark.tmp" "$TARGET/.fiomark.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment