Last active
November 15, 2015 04:26
-
-
Save PhilippMundhenk/5d796ee6c19dbb8f005c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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