Guest User

Untitled

a guest
Jan 3rd, 2020
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. LOOPS=5 #How many times to run each test
  4. SIZE=1024 #Size of each test, multiples of 32 recommended for Q32 tests to give the most accurate results.
  5. WRITEZERO=0 #Set whether to write zeroes or randoms to testfile (random is the default for both fio and crystaldiskmark); dd benchmarks typically only write zeroes which is why there can be a speed difference.
  6.  
  7. QSIZE=$(($SIZE / 32)) #Size of Q32Seq tests
  8. SIZE+=m
  9. QSIZE+=m
  10.  
  11. if [ -z $2 ]; then
  12. echo "Usage: ssdbenchmark sda /path/to/mount"
  13. exit 1
  14. else
  15. TARGET="$2"
  16. echo "Testing in $TARGET"
  17. fi
  18.  
  19. if [ -z $1 ]; then
  20. echo "Usage: ssdbenchmark sda /path/to/mount"
  21. exit 1
  22. else
  23. DRIVE="$1"
  24. echo "Testing in $TARGET"
  25. fi
  26.  
  27. #DRIVE=$(df $TARGET | grep /dev | cut -d/ -f3 | cut -d" " -f1 | rev | cut -c 2- | rev)
  28. #DRIVE=nvme0n1
  29. DRIVEMODELSPACES=$(cat /sys/block/$DRIVE/device/model)
  30. DRIVEMODEL="$(echo -e "${DRIVEMODELSPACES}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
  31. DRIVESIZE=$(($(cat /sys/block/$DRIVE/size)*512/1024/1024/1024))GB
  32.  
  33. echo "Configuration: Size:$SIZE Loops:$LOOPS Write Only Zeroes:$WRITEZERO
  34. Running Benchmark on: /dev/$DRIVE, $DRIVEMODEL ($DRIVESIZE), please wait...
  35. "
  36.  
  37. fio --loops=$LOOPS --size=$SIZE --filename=$TARGET/.fiomark.tmp --stonewall --ioengine=libaio --direct=1 --zero_buffers=$WRITEZERO --output-format=json \
  38. --name=Bufread --loops=1 --bs=$SIZE --iodepth=1 --numjobs=1 --rw=readwrite \
  39. --name=Seqread --bs=$SIZE --iodepth=1 --numjobs=1 --rw=read \
  40. --name=Seqwrite --bs=$SIZE --iodepth=1 --numjobs=1 --rw=write \
  41. --name=512kread --bs=512k --iodepth=1 --numjobs=1 --rw=read \
  42. --name=512kwrite --bs=512k --iodepth=1 --numjobs=1 --rw=write \
  43. --name=SeqQ32T1read --bs=$QSIZE --iodepth=32 --numjobs=1 --rw=read \
  44. --name=SeqQ32T1write --bs=$QSIZE --iodepth=32 --numjobs=1 --rw=write \
  45. --name=4kread --bs=4k --iodepth=1 --numjobs=1 --rw=randread \
  46. --name=4kwrite --bs=4k --iodepth=1 --numjobs=1 --rw=randwrite \
  47. --name=4kQ32T1read --bs=4k --iodepth=32 --numjobs=1 --rw=randread \
  48. --name=4kQ32T1write --bs=4k --iodepth=32 --numjobs=1 --rw=randwrite \
  49. --name=4kQ8T8read --bs=4k --iodepth=8 --numjobs=8 --rw=randread \
  50. --name=4kQ8T8write --bs=4k --iodepth=8 --numjobs=8 --rw=randwrite > $TARGET/.fiomark.txt
  51.  
  52. SEQR="$(($(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "Seqread"' | grep bw_bytes | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "Seqread"' | grep -m1 iops | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  53. SEQW="$(($(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "Seqwrite"' | grep bw_bytes | sed '2!d' | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "Seqwrite"' | grep iops | sed '7!d' | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  54. F12KR="$(($(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "512kread"' | grep bw_bytes | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "512kread"' | grep -m1 iops | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  55. F12KW="$(($(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "512kwrite"' | grep bw_bytes | sed '2!d' | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "512kwrite"' | grep iops | sed '7!d' | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  56. SEQ32R="$(($(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "SeqQ32T1read"' | grep bw_bytes | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "SeqQ32T1read"' | grep -m1 iops | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  57. SEQ32W="$(($(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "SeqQ32T1write"' | grep bw_bytes | sed '2!d' | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "SeqQ32T1write"' | grep iops | sed '7!d' | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  58. FKR="$(($(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "4kread"' | grep bw_bytes | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "4kread"' | grep -m1 iops | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  59. FKW="$(($(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "4kwrite"' | grep bw_bytes | sed '2!d' | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "4kwrite"' | grep iops | sed '7!d' | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  60. FK32R="$(($(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "4kQ32T1read"' | grep bw_bytes | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "4kQ32T1read"' | grep -m1 iops | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  61. FK32W="$(($(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "4kQ32T1write"' | grep bw_bytes | sed '2!d' | cut -d: -f2 | sed s:,::g)/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "4kQ32T1write"' | grep iops | sed '7!d' | cut -d: -f2 | cut -d. -f1 | sed 's: ::g')"
  62. FK8R="$(($(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "4kQ8T8read"' | grep bw_bytes | sed 's/ "bw_bytes" : //g' | sed 's:,::g' | awk '{ SUM += $1} END { print SUM }')/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A15 '"name" : "4kQ8T8read"' | grep iops | sed 's/ "iops" : //g' | sed 's:,::g' | awk '{ SUM += $1} END { print SUM }' | cut -d. -f1)"
  63. FK8W="$(($(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "4kQ8T8write"' | grep bw_bytes | sed 's/ "bw_bytes" : //g' | sed 's:,::g' | awk '{ SUM += $1} END { print SUM }')/1024/1024))MB/s IOPS=$(cat $TARGET/.fiomark.txt | grep -A80 '"name" : "4kQ8T8write"' | grep '"iops" '| sed 's/ "iops" : //g' | sed 's:,::g' | awk '{ SUM += $1} END { print SUM }' | cut -d. -f1)"
  64.  
  65. echo -e "
  66. Results from /dev/$DRIVE, $DRIVEMODEL ($DRIVESIZE):
  67. \033[0;33m
  68. Sequential Read: $SEQR
  69. Sequential Write: $SEQW
  70. \033[0;32m
  71. 512KB Read: $F12KR
  72. 512KB Write: $F12KW
  73. \033[1;36m
  74. Sequential Q32T1 Read: $SEQ32R
  75. Sequential Q32T1 Write: $SEQ32W
  76. \033[0;36m
  77. 4KB Read: $FKR
  78. 4KB Write: $FKW
  79. \033[1;33m
  80. 4KB Q32T1 Read: $FK32R
  81. 4KB Q32T1 Write: $FK32W
  82. \033[1;35m
  83. 4KB Q8T8 Read: $FK8R
  84. 4KB Q8T8 Write: $FK8W
  85. "
  86. echo -e "\e[0m"
  87. echo
  88.  
  89. rm $TARGET/.fiomark.txt $TARGET/.fiomark.tmp
Advertisement
Add Comment
Please, Sign In to add comment