Skip to content

Instantly share code, notes, and snippets.

@jnewland
Created March 5, 2013 22:43
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 jnewland/5095037 to your computer and use it in GitHub Desktop.
Save jnewland/5095037 to your computer and use it in GitHub Desktop.
#!/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;
@jnewland
Copy link
Author

a note from past jesse: do not delete me please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment