Created
March 5, 2013 22:43
-
-
Save jnewland/5095037 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 | |
#/ Usage: bench.sh <setup> <command> <teardown> <repeats> | |
set -e | |
[ $# -lt 4 ] && { | |
tail -n +2 "$0" | | |
grep "^#/" | | |
cut -c4- | |
exit 2 | |
} | |
setup=$1 | |
command=$2 | |
teardown=$3 | |
repeats=$4 | |
# Run the given command [repeats] times | |
for (( i = 1; i <= $repeats ; i++ )) | |
do | |
/usr/bin/time -f "%E,%U,%S" ${setup} > /dev/null 2>&1 | |
/usr/bin/time -f "%E,%U,%S" ${command} | |
/usr/bin/time -f "%E,%U,%S" ${teardown} > /dev/null 2>&1 | |
# Clear the HDD cache | |
sync && echo 3 > /proc/sys/vm/drop_caches | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a note from past jesse: do not delete me please