Dyota's blog

PowerShell: Stopwatch

Measure the amount of time your code takes to run by circumfixing it with this:

# Make a new stopwatch object
$sw = [System.Diagnostics.Stopwatch]::StartNew()

# Run your code here...

# Stop stopwatch
$sw.Stop()

# Print out time elapsed
$t = $sw.Elapsed
Write-Host "$($t.Minutes) minutes $($t.Seconds) seconds"

#powershell