Skip to content

Instantly share code, notes, and snippets.

@PsCustomObject
Created December 26, 2018 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PsCustomObject/6c22b6cb040d195f05ebb9df1a772bff to your computer and use it in GitHub Desktop.
Save PsCustomObject/6c22b6cb040d195f05ebb9df1a772bff to your computer and use it in GitHub Desktop.
PowerShell Measure Script Exeuction time via StopWatch
# Full post https://pscustomobject.github.io/powershell/how%20to/PowerShell-Measure-Execution-Time/
# Full Type Name would be System.Diagnostics.Stopwatch
# Start the stopwatch
$stopWatch = [Diagnostics.Stopwatch]::StartNew()
# Define search path
[string]$userFolder = 'Users/PsCustomObject/Desktop/'
# Get all files and recurse in subfolders
Get-ChildItem -Path $userFolder -Recurse
# Alt the stopwatch
$stopWatch.Stop()
# Print elapsed time
$stopWatch.'Elapsed'
@PsCustomObject
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment