我可以通过使用 chrome.processes(仅适用于 Chrome Dev)获取 CPU 使用率,此 API 检索使用率而不是百分比。
我得到很长的数字,例如:1.5612728395 & 121.5613212 & 24.215326622 作为 CPU 使用率。
它们是什么意思?它们不是百分比。如何将它们转换为使用百分比?
最佳答案
它们是百分比,但该数字是按每个 CPU 核心计算的,因此超过 100%(在您的情况下为 121.56%)意味着它使用了多个核心(多线程进程)。
来自docs :
The most recent measurement of the process’s CPU usage, expressed as the percentage of a single CPU core used in total, by all of the process’s threads. This gives a value from zero to CpuInfo.numOfProcessors*100, which can exceed 100% in multi-threaded processes. Only available when receiving the object as part of a callback from onUpdated or onUpdatedWithMemory.
所以如果你有例如。 4 核(或 2 核超线程),最大为 400。
关于javascript - 如何以百分比形式获取 Chrome 扩展程序的 CPU 使用率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50945812/