Skip to content

Instantly share code, notes, and snippets.

@llaumgui
Created January 10, 2014 15:19
Show Gist options
  • Save llaumgui/8356216 to your computer and use it in GitHub Desktop.
Save llaumgui/8356216 to your computer and use it in GitHub Desktop.
Script that benchmark the files creation.
#!/bin/sh
#
# Script who bench file creation
#
HOSTNAME=$(hostname)
PID=$$
USAGE="Usage: iobench.sh TIMEOUT PATH"
if [ $1 ]; then
TIMEOUT=$1
else
echo ${USAGE}
exit
fi
if [ $2 ]; then
BASEDIR=$2
else
echo ${USAGE}
exit
fi
echo "Timout: ${TIMEOUT}"
echo "BaseDir: ${BASEDIR}"
echo -e "HostName: ${HOSTNAME}\n"
TIMESTART=$(date '+%s')
TIMEEND=$(expr $TIMESTART + $TIMEOUT)
FILECNT=0
RCNT=1
while [ 1 ]; do
ROOTPATH=${BASEDIR}/${HOSTNAME}_${PID}_${RCNT}
mkdir ${ROOTPATH}
DCNT=1
while [ ${DCNT} -le 100 ]; do
DIRPATH=${ROOTPATH}/dir_${DCNT}
mkdir ${DIRPATH}
FCNT=1
while [ ${FCNT} -le 100 ]; do
FILEPATH=${DIRPATH}/file_${FCNT}.bin
dd if=/dev/zero of=${FILEPATH} bs=65536 count=16 &> /dev/null
sync
echo -n "."
let FILECNT=FILECNT+1
let FCNT=FCNT+1
TIMENOW=$(date '+%s')
if [ ${TIMENOW} -ge ${TIMEEND} ]; then
echo "PID ${PID} : ${FILECNT} files created in $[${TIMENOW} - ${TIMESTART}] seconds."
exit
fi
done
echo ""
let DCNT=DCNT+1
done
let RCNT=RCNT+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment