开发者

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

开发者 https://www.devze.com 2022-12-13 06:42 出处:网络
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-t

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 mul开发者_StackOverflowti-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.)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号