Measure running time (for script blocks and cmdlets).
Syntax
Measure-Command [-expression] scriptblock
[-inputObject psobject] [CommonParameters]
Key
-expression
The expression to be timed.
Enclose the expression in {curly braces}
-inputObject
An object that represents an expression.
A command, expression or variable that contains the object(s).
CommonParameters:
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
-OutBuffer -OutVariable.
Examples
Measures the time it takes to run a "get-eventlog" command:
PS C:\> Measure-Command { get-eventlog "windows powershell" }
Compare the performance of -filter and -include:
PS C:\> measure-command {get-childitem c:\windows -include *.txt -recurse}
PS C:\> measure-command {get-childitem c:\windows -filter "*.txt" -recurse}
“There is no monument dedicated to the memory of a committee” ~ Lester J. Pourciau
Related PowerShell Cmdlets:
Compare-Object - Compare the properties of objects.
Trace-Command - Trace an expression or command.
Invoke-Expression - Run a PowerShell expression.
Equivalent CMD script: timer.cmd
Equivalent bash command: time - Measure program running time.