Created
July 19, 2011 19:41
-
-
Save nomatteus/1093518 to your computer and use it in GitHub Desktop.
Really simple task (i.e. Rake) timing in Bash
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
# Just copy this line into your terminal | |
# Replace "clear ; rake" with whatever command(s) you want to time. | |
start=`date +'%s'` ; clear ; rake ; end=`date +'%s'`; echo \*\*\* Task took `expr $end - $start` seconds to run. | |
# Even better, add this to your ~/.bash_profile (or similar) file: | |
function timer() { | |
start=`date +'%s'`; | |
$@ | |
end=`date +'%s'`; | |
echo \*\*\* Task took `expr $end - $start` seconds to run.; | |
} | |
# Reload your bash profile by restarting terminal or type | |
source ~/.bash_profile | |
# then run the timer using | |
timer your_command_here | |
# For example, running: | |
timer sleep 3 | |
# outputs: | |
# *** Task took 3 seconds to run. | |
# This only works for single commands at the moment, and will break and/or be inaccurate if you use pipes or semicolons. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment