PowerShell Logo Small

Measure-Command



This is the built-in help made by Microsoft for the command 'Measure-Command', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Measures the time it takes to run script blocks and cmdlets.

SYNTAX


Measure-Command [-Expression] <scriptblock> [-InputObject <psobject>] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Measure-Command cmdlet runs a script block or cmdlet internally, times the execution of the operation, and returns the execution time.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113348
Trace-Command
Invoke-Command

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>Measure-Command { get-eventlog "windows powershell" }



Description
-----------
This command measures the time it takes to run a "get-eventlog" command that gets the events in the Windows PowerShell event log.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>measure-command {get-childitem c:\windows -include *.txt -recurse}

Days : 0
Hours : 0
Minutes : 0
Seconds : 8
Milliseconds : 618
Ticks : 86182763
TotalDays : 9.9748568287037E-05
TotalHours : 0.00239396563888889
TotalMinutes : 0.143637938333333
TotalSeconds : 8.6182763
TotalMilliseconds : 8618.2763

C:\PS>measure-command {get-childitem c:\windows -filter "*.txt" -recurse}

Days : 0
Hours : 0
Minutes : 0
Seconds : 1
Milliseconds : 140
Ticks : 11409189
TotalDays : 1.32050798611111E-05
TotalHours : 0.000316921916666667
TotalMinutes : 0.019015315
TotalSeconds : 1.1409189
TotalMilliseconds : 1140.9189



Description
-----------
These commands show the value of using a provider-specific filter in Windows PowerShell commands. The first command measures the time it takes to
process a recursive Get-ChildItem command that uses the Include parameter. The second command measures the time it takes to process a recursive
Get-ChildItem command that uses the provider-specific Filter parameter.