@kadin
To find the minimum execution time in PowerShell, you can use the Measure-Command
cmdlet to measure the execution time of a scriptblock or command. Here's an example:
1 2 3 4 5 6 7 8 9 10 11 |
$times = @() 1..10 | ForEach-Object { $time = (Measure-Command { # Your scriptblock or command goes here Start-Sleep -Seconds 1 }).TotalMilliseconds $times += $time } $minTime = $times | Measure-Object -Minimum Write-Host "Minimum execution time: $($minTime.Minimum)" |
In this example, we are measuring the execution time of a Start-Sleep
command that sleeps for 1 second, but you can replace it with your own scriptblock or command. The script runs the command 10 times and stores the execution times in an array. Then, we use the Measure-Object
cmdlet to find the minimum execution time from the array and output it to the console.