#!/bin/bash # This script is loosely based on https://unix.stackexchange.com/revisions/480191/9. command -v fio >/dev/null 2>&1 || { echo >&2 "Package 'fio' not installed. Aborting."; exit 1; } command -v jq >/dev/null 2>&1 || { echo >&2 "Package 'jq' not installed. Aborting."; exit 1; } LOOPS=1 # How many times to run each test SIZE=1024m # File size if [ -z "$1" ]; then TARGET=$HOME echo "Defaulting to $TARGET for testing" else TARGET="$1" echo "Testing in $TARGET" fi fio --loops=$LOOPS --size=$SIZE --filename="$TARGET/.fiomark.tmp" --stonewall --ioengine=libaio --direct=1 --output-format=json --output "$TARGET/.fiomark.txt" \ --name=Bufread --loops=1 --bs=$SIZE --iodepth=1 --numjobs=1 --rw=readwrite \ --name=Seq1MQ8T1read --bs=1M --iodepth=8 --numjobs=1 --rw=read \ --name=Seq1MQ8T1write --bs=1M --iodepth=8 --numjobs=1 --rw=write \ --name=Seq128kQ32T1read --bs=128k --iodepth=32 --numjobs=1 --rw=read \ --name=Seq128kQ32T1write --bs=128k --iodepth=32 --numjobs=1 --rw=write \ --name=4kQ32T16read --bs=4k --iodepth=32 --numjobs=16 --rw=randread \ --name=4kQ32T16write --bs=4k --iodepth=32 --numjobs=16 --rw=randwrite \ --name=4kQ1T1read --bs=4k --iodepth=1 --numjobs=1 --rw=randread \ --name=4kQ1T1write --bs=4k --iodepth=1 --numjobs=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("Seq128kQ32T1"), job_summary("4kQ32T16"), job_summary("4kQ1T1")' read -d '\n' -ra V <<< "$(jq "$QUERY" "$TARGET/.fiomark.txt")" rm "$TARGET/.fiomark.tmp" # Only load curses interface if it exists if test -f "./simple_curses.sh"; then source ./simple_curses.sh main() { window "NCDM" "green" append_tabbed "SEQ1M: Read ${V[0]}MB/s: Write ${V[2]}MB/s" 3 ":" "blue" append_tabbed "Q8T1: IOPS ${V[1]}: IOPS ${V[3]}" 3 ":" "red" addsep append_tabbed "SEQ128k: Read ${V[4]}MB/s: Write ${V[6]}MB/s" 3 ":" "blue" append_tabbed "Q32T1: IOPS ${V[5]}: IOPS ${V[7]}" 3 ":" "red" addsep append_tabbed "RND4K: Read ${V[8]}MB/s: Write ${V[10]}MB/s" 3 ":" "blue" append_tabbed "Q32T16: IOPS ${V[9]}: IOPS ${V[11]}" 3 ":" "red" addsep append_tabbed "RND4K: Read ${V[12]}MB/s: Write ${V[14]}MB/s" 3 ":" "blue" append_tabbed "Q1T1: IOPS ${V[13]}: IOPS ${V[5]}" 3 ":" "red" endwin } update() { # immediately exit the script exit 0 } main_loop else echo -e " Results: \033[0;33m SEQ1M Read: ${V[0]}MB/s Write: ${V[2]}MB/s Q8T1 IOPS: ${V[1]} IOPS: ${V[3]} \033[0;32m SEQ128k Read: ${V[4]}MB/s Write: ${V[6]}MB/s Q32T1 IOPS: ${V[5]} IOPS: ${V[7]} \033[1;33m RNT4K Read: ${V[8]}MB/s Write: ${V[10]}MB/s Q32T16 IOPS: ${V[9]} IOPS: ${V[11]} \033[0;32m RND4K Read: ${V[12]}MB/s Write: ${V[14]}MB/s Q1T1 IOPS: ${V[13]} IOPS: ${V[15]} " fi