Search notes:
PowerShell cmdLet measure-command
Unsurprisingly, it takes 3 seconds to sleep for 3 seconds:
measure-command { start-sleep 3 }
Days : 0
Hours : 0
Minutes : 0
Seconds : 3
Milliseconds : 1
Ticks : 30013870
TotalDays : 3.4738275462963E-05
TotalHours : 0.000833718611111111
TotalMinutes : 0.0500231166666667
TotalSeconds : 3.001387
TotalMilliseconds : 3001.387
Of course, if I am only interested in the (rounded) number of seconds, I can
pipe the result through
select-object
:
measure-command { start-sleep 3 } | select-object seconds
Seconds
-------
3
Measure the time of any command or pipeline
measure-command {
1 .. 1mb |
get-random
}