Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
blocks=$4
if [ -z "$blocks" ]; then
blocks="2000"
echo "using size $blocks (default)"
else
echo "using size $blocks"
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 $blocks * 512 Bytes to $1" > $outFile
for i in {1..5}
do
dd if=/dev/zero of=$1 bs=512 count=$blocks 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 $blocks * 512 Bytes to $1" > $outFile
for i in {1..5}
do
dd if=$1 of=/dev/null bs=512 count=$blocks 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
You can’t perform that action at this time.