Skip to content

Instantly share code, notes, and snippets.

@iMilnb
Last active June 5, 2017 22:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iMilnb/8b58d2d43e72a52a2256 to your computer and use it in GitHub Desktop.
Save iMilnb/8b58d2d43e72a52a2256 to your computer and use it in GitHub Desktop.
Trivial disk troughput bench using dd(1)
#!/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