Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>System.Environment.ProcessorCount </code></pre> <p>returns the number of logical processors</p> <blockquote> <p><a href="http://msdn.microsoft.com/en-us/library/system.environment.processorcount.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.environment.processorcount.aspx</a></p> </blockquote> <p>For physical processor count you'd probably need to use WMI - the following metadata is supported in XP/Win2k3 upwards (Functionality enabled in SP's prior to Vista/Win2k8).</p> <blockquote> <p><b>Win32_ComputerSystem.NumberOfProcessors</b> returns physical count</p> <p><b>Win32_ComputerSystem.NumberOfLogicalProcessors</b> returns logical (duh!)</p> </blockquote> <p>Be cautious that HyperThreaded CPUs appear identical to multicore'd CPU's yet the performance characteristics are <em>very</em> different. </p> <p>To check for HT-enabled CPUs examine each instance of Win32_Processor and compare these two properties.</p> <blockquote> <p><b>Win32_Processor.NumberOfLogicalProcessors</b></p> <p><b>Win32_Processor.NumberOfCores</b></p> </blockquote> <p>On multicore systems these are typically the same the value.</p> <p>Also, be aware of systems that may have multiple <strong>Processor Groups</strong>, which is often seen on computers with a large number of processors. By default <a href="https://stackoverflow.com/questions/27965962/c-sharp-environment-processorcount-does-not-always-return-the-full-number-of-log">.Net will only using the first processor group</a> - which means that by default, threads will utilize only CPUs from the first processor group, and <code>Environment.ProcessorCount</code> will return only the number of CPUs in this group. According to <a href="https://stackoverflow.com/questions/27965962/c-sharp-environment-processorcount-does-not-always-return-the-full-number-of-log/30456753#30456753">Alastair Maw's answer</a>, this behavior can be changed by altering the app.config as follows:</p> <pre><code>&lt;configuration&gt; &lt;runtime&gt; &lt;Thread_UseAllCpuGroups enabled="true"/&gt; &lt;GCCpuGroup enabled="true"/&gt; &lt;gcServer enabled="true"/&gt; &lt;/runtime&gt; &lt;/configuration&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload