cpuCount

fnuint cpuCount(bool logical = true) @safe

Gets the number of CPU cores.

Parameters

logicalIf true, returns logical CPU count (including hyperthreading). If false, returns physical CPU count.

Returns

The number of CPU cores.

Example:

auto logicalCores = cpuCount(true);
auto physicalCores = cpuCount(false);