如何以编程方式确定是在多核、超线程还是多处理器上?
我知道如何获取处理器类型,也许这是唯一的方法,但我实际上正在寻找一种方法来确定应用程序是在多核处理器上还是在超线程上运行单核处理器。
(背景:我的一些客户的托管提供商对于他们通过 VMWare 映像提供哪些资源非常模糊。该应用程序应该在多核上运行,但自上次“移动”以来已经看到了不利的性能。通常,在在多核中,一个核心在一个线程上出现峰值,而另一个核心则不会出现峰值,即使在单线程应用程序上也是如此。)
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.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
System.Environment.ProcessorCount 其中还将包括超线程处理器。 Vmware 可能会或可能不会公开哪些内容。如果处理器启用了 VT 并且您使用的是支持裸机的虚拟机管理程序技术,则该漏洞暴露的可能性会更高。
如果您有 XP-SP3/WIN2k3 或更高版本 您可以使用 WMI 来拉出:
如果值相同,则很可能您的系统没有 HT 或未启用 HT。
您可以从本教程开始探索如何在 .NET 中提取 WMI 信息。
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:
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.