Skip to content

Instantly share code, notes, and snippets.

@nadavoid
Created December 22, 2011 23:30
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 nadavoid/1512319 to your computer and use it in GitHub Desktop.
Save nadavoid/1512319 to your computer and use it in GitHub Desktop.
Execute an arbitrary command and track how much time it takes, in seconds.
if [ "$1" ]; then
START=$(date +"%s")
echo "Doing: $1"
$1
END=$(date +"%s")
ELAPSED=`expr $END - $START`
echo "Operation took $ELAPSED seconds."
else
echo "Usage:
exec_with_timer.sh 'command to run'
exec_with_timer.sh 'date'
exec_with_timer.sh 'drush cc all'"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment