Search notes:

PowerShell cmdLet measure-command

measure-command clocks the time it is needed to run a script block or execute a cmdLet. The cmdLet returns a System.TimeSpan object.
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 reports the time needed to finish any command or pipeline:
measure-command {
   1 .. 1mb     |
   get-random
}
Github repository about-PowerShell, path: /cmdlets/command/measure/pipeline.ps1

See also

Powershell command noun: command

Index