问题描述
这里的代码占用了我大约 20% 的 CPU 使用率(AMD FX 6300):
$test1 = "Test 1"
$test2 = "Test 2"
$test3 = "Test 3"
$test4 = "Test 4"
do {
if ($test1 -eq "Test 1"){Get-Date -Format "HH:mm:ss"; Write-Host ""; Write-Host "OK."}
if ($test2 -eq "Test 2"){Get-Date -Format "HH:mm:ss"; Write-Host ""; Write-Host "OK."}
if ($test3 -eq "Test 3"){Get-Date -Format "HH:mm:ss"; Write-Host ""; Write-Host "OK."}
if ($test4 -eq "Test 4"){Get-Date -Format "HH:mm:ss"; Write-Host ""; Write-Host "OK."}
} While($true)
... 我试图在运行时减少程序的 CPU 使用率。我还注意到在 Start-Sleep -Milliseconds 50
语句的开头添加 Do - While
可以将其减少约 100%...有人知道为什么会这样吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)