Jan
Jan

Reputation: 128

Get total count of actual processor cores without Hyperthreading

I'm looking for a way to get the total number of actual processor cores, as everything I found (e.g. this) returns the number of cores plus Intel's Hyperthreading technology, i.e. I'm shown 8 cores for my i7 6700K, while the processor only has 4 actual cores. As far as I know, this only applies to Intel processors featuring the Hyperthreading Technology.

Upvotes: 2

Views: 1288

Answers (1)

Jan
Jan

Reputation: 128

I figured it out myself (using Linq). Alas, the code is not the fastest in speed terms. Reference System.Management and you're good to go:

var processorCoreCount = new ManagementObjectSearcher("Select * from Win32_Processor").Get().Cast<ManagementBaseObject>().Sum(item => int.Parse(item["NumberOfCores"].ToString()));

Upvotes: 3

Related Questions