How do I simulate 100% CPU usage?

十年热恋 提交于 2019-12-06 11:34:22

CPU usage is a percentage of all CPU cores.
If your code is only running a single thread, it cannot occupy more than one core.

You need to make a separate thread for each core. (Environment.ProcessorCount)

Dual core cpu, 2 hyperthreads per core. So you might expect 1 thread at 100% usage to take 25% of the total. The other 5% is everything else that the system is doing.

Even with 4 threads, you may not get 100% usage, due to scheduling.

The real question is, why do you want 100% usage...are you trying to cook a steak on the CPU?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!