我一直在 PowerShell 中使用 Measure-Command
来计时 Python 脚本的执行时间:
Measure-Command{C:\Python27\python.exe script.py}
这会以多种形式显示执行时间,包括TotalSeconds
。
为了最大限度地减少开销的影响,我想运行脚本 10 次,并找到 10 次运行中的最小 TotalSeconds
值。有没有一种简单的方法可以在 PowerShell 中执行此操作?
最佳答案
使用Measure-Object命令,如this SO answer :
C:\PS> 1..10 | % { Measure-Command { C:\Python27\python.exe script.py } } | Measure-Object -Minimum
Count : 3
Average :
Sum :
Maximum :
Minimum : 00:00:00.0095165
Property :
关于powershell - 如何找到 PowerShell 中的最短执行时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38113055/