Last active
June 5, 2017 22:39
-
-
Save iMilnb/8b58d2d43e72a52a2256 to your computer and use it in GitHub Desktop.
Trivial disk troughput bench using dd(1)
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/sh | |
[ $# -lt 1 ] && echo "usage: $0 <path>" && exit 1 | |
bpath=$1 | |
# you might want to change these to suit your setup | |
bs=32k | |
count=30000 | |
echo "running tests with bs=${bs}, counting ${count} cycles" | |
speedtest() | |
{ | |
t1="$(date +%s)" | |
bytes=$($1 2>&1 && sync) | |
t2=$(($(date +%s)-$t1)) | |
bytes=$(echo "${bytes}"|awk '/[0-9]+\ bytes/ {print $1}') | |
mbps=$(($bytes / $t2 / 1024 / 1024)) | |
echo "${mbps}MB/s (${bytes} written in ${t2} seconds)" | |
} | |
echo -n "write speed... " | |
speedtest "dd if=/dev/zero of=$bpath bs=${bs} count=${count}" | |
echo -n "read speed... " | |
speedtest "dd if=$bpath of=/dev/null" | |
rm -f -- "$bpath" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment