How can I determine programmatically whether on multi-core, hyperthreading or multi-processor?

瘦欲@ 提交于 2019-12-08 10:40:08

问题


I know how to get the processor type, perhaps that's the only way, but I'm actually looking for a way to determine from an application whether it's running on a multi-core processor or on a hyper-threading single-core processor.

(background: the hosting providers of some of my clients are very vague about what resources they make available through VMWare images. This application is supposed to run on multi-core, but has seen detrimental performance since its last "move". Normally, on multi-core, one core spikes on one thread, and not the other. On this "multi-core", both processors spike, even on single-threaded applications.)


回答1:


System.Environment.ProcessorCount Which will also include hyperthreaded processors. Which Vmware may or may not expose. Chances are higher that it will be exposed if the the processor is VT enabled AND you are using a baremetal enabled hypervisor technology.

If you have XP-SP3/WIN2k3 or above You can use WMI to pull out:

Win32_ComputerSystem.NumberOfProcessors returns physical count

Win32_ComputerSystem.NumberOfLogicalProcessors returns logical count

If the values are the same then chances are your system does not have HT or does not have it enabled.

You can start exploring how to pull out WMI info in .NET from this tutorial.



来源:https://stackoverflow.com/questions/1817268/how-can-i-determine-programmatically-whether-on-multi-core-hyperthreading-or-mu

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