There are a couple different options to get a 'time' command. My preference is to just install Cygwin (which comes with a UNIX-like time
command).
Alternatively, you can write a script and add it to your path (so that you can execute it without specifying the entire path).
If you have Powershell available, try this script (works when calling files--'.exe',etc.):
$start = get-date
if ($args.length -gt 1) {
start-process $args[0] $args[1..$args.length] -workingdirectory $pwd -nonewwindow -wait
} else {
start-process $args[0] -workingdirectory $pwd -nonewwindow -wait
}
$end = get-date
$elapsed = $end - $start
write-host $end-$start
# datetime format
write-host $elapsed
# easy-to-read format
echo $elapsed
Run the code with (for instance):
time.ps1 python program.py
Using Batch, I'd suggest either of the top answers from here (on Stackoverflow.com). Both just need to be copy-pasted. Note that if you use paxdiablo's solution, you should replace
ping -n 11 127.0.0.1 >nul: 2>nul:
with
%*
Unable to query system performance data (c0000004)
. I googled it and someone else had the exact same problem, but the forum suggests no solution. Thanks for the suggestion anyway. Can someone suggest something for the other part? – efficiencyIsBliss Jan 1 '11 at 23:10