Some coffee helped me come up with this:
function time { $Command = "$args"; Measure-Command { Invoke-Expression $Command 2>&1 | out-default} }
And if you want it to output nothing, just replace with out-null:
function timequiet { $Command = "$args"; Measure-Command { Invoke-Expression $Command 2>&1 | out-null} }
You use it like this:
PS C:\> time sleep 5
Days : 0
Hours : 0
Minutes : 0
Seconds : 4
Milliseconds : 990
Ticks : 49906722
TotalDays : 5,77624097222222E-05
TotalHours : 0,00138629783333333
TotalMinutes : 0,08317787
TotalSeconds : 4,9906722
TotalMilliseconds : 4990,6722
PS C:\>
2Windows has the standard cmd.exe but if you want something closer to the linux version get the powershell, its way better. – Guillermo Siliceo Trueba – 2011-01-01T22:53:48.687
I searched for "command time for windows" on google on the first result gives: http://stackoverflow.com/questions/673523/how-to-measure-execution-time-of-command-in-windows-command-line
– David Michel – 2011-01-01T22:55:01.523I'm on Windows 7 and I just tried the solution posted above. I get the following error:
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 – 2011-01-01T23:10:53.453@eff, timeit.exe is for server 2003 and XP AFAIK, I don't think its compatible with 7. – John T – 2011-01-01T23:39:56.147