Ken*_*aul 5 powershell timespan
PowerShell Timespans非常适合快速显示持续时间,如:
$starttime = $(get-date)
{ do some processing here }
write-host "Duration: $((new-timespan $starttime $(get-date)).tostring())"
Run Code Online (Sandbox Code Playgroud)
但是,如果我$loopcount在该时间段内进行了迭代处理,我如何将持续时间除以$loopcount获得每次迭代的平均持续时间?
如果这样做(如果你不需要从脚本块输出)可能是一个稍微好一点的方法:
1..$loopcount | ForEach-Object {
Measure-Command {
# do some processing here
}
} | Measure-Object -Average TotalSeconds
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6947 次 |
| 最近记录: |