Skip to content

Instantly share code, notes, and snippets.

@hervenivon
Created January 15, 2018 15:26
Show Gist options
  • Save hervenivon/f5acb52b57d7aba4d949c59a5047f729 to your computer and use it in GitHub Desktop.
Save hervenivon/f5acb52b57d7aba4d949c59a5047f729 to your computer and use it in GitHub Desktop.
Quick performance read/write comparison based on linux `dd`
#!/bin/bash
BUFFERSIZE=1048576
WHERE="/dev/shm/test /mnt/data/test"
RESULTS="/tmp/benchmark_results.csv"
echo "WHERE;TYPE;SIZE;DURATION;SPEED;SPEEDUNIT" > $RESULTS
for i in `seq 1 10`;
do
size=$(($i * 1024))
echo "Testing $size MB files"
for w in $WHERE;
do
echo "- Writing on $w"
printf "$w;write;$size;" >> $RESULTS
dd if=/dev/urandom of=$w bs=$BUFFERSIZE count=$size 2>&1 | awk '$2 == "bytes" {print $6";"$8";"$9 }' >> $RESULTS
echo "- Reading $w"
printf "$w;read;$size;" >> $RESULTS
dd if=$w of=/dev/zero bs=$BUFFERSIZE 2>&1 | awk '$2 == "bytes" {print $6";"$8";"$9 }' >> $RESULTS
echo "- Deleting $w"
rm -f $w
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment