webhead's blog

Crude way to measure disk speed

Simple script to crudely measure disk speed. Take file name and test file size as argument - e.g.

./bench /tmp/test 2048 # create 2GB test file /tmp/test

#!/bin/bash
if [ $# -lt 2 ] ; then
echo Usage: ./bench FILE_NAME SIZE_IN_MB
exit 1
fi

sync
echo 3 > /proc/sys/vm/drop_caches
dd if=/dev/zero of=$1 bs=1M count=$2 oflag=direct 
sync
echo 3 > /proc/sys/vm/drop_caches
dd if=$1 of=/dev/null bs=1M count=$2 iflag=direct
rm -rf $1