Skip to content

Instantly share code, notes, and snippets.

@iMilnb iMilnb/ddbench.sh
Last active Jun 5, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.