Check below to find the answer


macOS:~$ sysctl hw.ncpu
hw.ncpu: 4   

Note that the number here might not match the number of cores with the command below

macOS:~$ system_profiler SPHardwareDataType

Hardware:
    Hardware Overview:
      Model Name: MacBook Pro
      Model Identifier: MacBookPro12,1
      Processor Name: Intel Core i7
      Processor Speed: 3.1 GHz
      Number of Processors: 1
      Total Number of Cores: 2  
      L2 Cache (per Core): x KB
      L3 Cache: x MB
      Memory: x GB
      Boot ROM Version: xxx
      SMC Version (system): xxx
      Serial Number (system): xxx
      Hardware UUID: xxx-xxx-xxx-xxx-xxx

 

You can confirm even further with the below commands


macOS:~$ sysctl hw.physicalcpu

hw.physicalcpu: 2


macOS:~$ sysctl hw.logicalcpu

hw.logicalcpu: 4

Conclusion on this example, 2 physical cores and each core has 2 virtual CPU (CPU Thread)

The picture below gives a brief idea of how 1 CPU with 2 Cores ( CPU Thread ) works

chapter2-2

If you want to know more details about CPUs, follow the intel website links below

http://www.intel.co.uk/content/www/uk/en/processors/core/core-i5-processor.html

http://www.intel.co.uk/content/www/uk/en/processors/core/core-i7-processor.html

Extra command for you to explore on your own


sysctl hw

 

Pictures from www.intel.com website

Inspiration to write this article from this source page http://stackoverflow.com/questions/1715580/how-to-discover-number-of-logical-cores-on-mac-os-x

All the best,

#Feijaouk