Skip to content

Instantly share code, notes, and snippets.

@PhilippMundhenk
Last active November 15, 2015 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PhilippMundhenk/0c64e42077cba549387b to your computer and use it in GitHub Desktop.
Save PhilippMundhenk/0c64e42077cba549387b to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z "$1" ]; then
echo "Please supply target device"
else
echo "running test on '$1'"
numberRuns=$3
if [ -z "$numberRuns" ]; then
numberRuns=5
echo "running $numberRuns times (default)"
else
echo "running $numberRuns times"
fi
if [ -z "$4" ]; then
count="16"
echo "using count $count (default)"
else
size=$4
echo "using count $count"
fi
outFile=$2
if [ -n "$outFile" ]; then
echo "logging to $2"
else
echo "no logfile supplied => /dev/null"
outFile="/dev/null"
fi
outFileOrig=$outFile
outFile="$outFileOrig-write"
echo "$numberRuns runs of 128MBytes * $count to $1" > $outFile
for i in {1..5}
do
dd if=/dev/zero of=$1 bs=128M count=$count conv=fdatasync >> $outFile 2>&1
done
echo "summary of large files" >> $outFile
cat $outFile | grep "copied" | sed 's/.*, //g' >> $outFile
avg=$(cat $outFile | grep "copied" | sed 's/.*, //g' | sed 's/ MB\/s//g' | paste -sd+ | bc | awk -v var="$numberRuns" '{print $1"/"var}' | bc -l)
echo "average: $avg MB/s" >> $outFile
echo "$avg" >> $outFile
outFile="$outFileOrig-read"
echo "$numberRuns runs of 128MBytes * $count to $1" > $outFile
for i in {1..5}
do
dd if=$1 of=/dev/null bs=128M count=$count conv=fdatasync >> $outFile 2>&1
done
echo "summary of large files" >> $outFile
cat $outFile | grep "copied" | sed 's/.*, //g' >> $outFile
avg=$(cat $outFile | grep "copied" | sed 's/.*, //g' | sed 's/ MB\/s//g' | paste -sd+ | bc | awk -v var="$numberRuns" '{print $1"/"var}' | bc -l)
echo "average: $avg MB/s" >> $outFile
echo "$avg" >> $outFile
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment