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 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


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

Extra command for you to explore on your own

sysctl hw


Pictures from website

Inspiration to write this article from this source page

All the best,