Created
March 12, 2024 20:30
-
-
Save kdorff/692e61b34020af5ebe4992cc18911a35 to your computer and use it in GitHub Desktop.
Function to time an execution using powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function time { | |
Param( | |
[Parameter(Mandatory=$true)] | |
[string]$command, | |
[switch]$quiet = $false | |
) | |
$start = Get-Date | |
try { | |
if ( -not $quiet ) { | |
iex $command | Write-Host | |
} else { | |
iex $command > $null | |
} | |
} finally { | |
$(Get-Date) - $start | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment