Is there a way to determine the number of cores on desktop machines Xplatform? (well at least Mac and Windows)
I considering writing an app that would use helpers for the first time, and knowing how to determine the # of cores would help determine how many helpers to spawn.
Trying that out made me realize things are not as simple as I was was thinking.
I have a 4 core cpu in my 2013 iMac (Core i7) which supports hyper-threading… As such that command reports 8 cores…
On a PC it looks like you get both actual and virtual cores,
In terms of performance, should I really consider it to be 8 cores for determining the max number of helpers to spawn, or will having more than one helper per physical core likely to bog down the machine? (Before considering hyper threading i was thinking I should always make sure I leave at least one physical core unused by my app)
If it matters, is there a way to determine the actual number of physical cores on a Mac?
Thanks you both… your combined answer answers my questions…
I would rather use declares than shell out (less overhead and perhaps more stable long term) but this works!
[quote=458052:@Walter Purvis]On Windows:
WMIC CPU Get DeviceID,NumberOfCores,NumberOfLogicalProcessors[/quote]
The overhead of a shell command is very, very small, considering you only have to determine the number of cores one time, at application open. As for stability, I doubt shell commands change any more frequently than OS APIs; some shell commands haven’t changed since the 70s.