问题
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