Skip to content

Instantly share code, notes, and snippets.

@kdorff
Created March 12, 2024 20:30
Show Gist options
  • Save kdorff/692e61b34020af5ebe4992cc18911a35 to your computer and use it in GitHub Desktop.
Save kdorff/692e61b34020af5ebe4992cc18911a35 to your computer and use it in GitHub Desktop.
Function to time an execution using powershell
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