Get cpu core number

@return int cpu core number
437571
public static int getNumCores() {
        class CpuFilter implements FileFilter {
            @Override
            public boolean accept(File pathname) {
                return Pattern.matches("cpu[0-9]", pathname.getName());
            }
        }

        if (sCoreNum == 0) {
            try {
                // Get directory containing CPU info
                File dir = new File("/sys/devices/system/cpu/");
                // Filter to only list the devices we care about
                File[] files = dir.listFiles(new CpuFilter());
                // Return the number of cores (virtual CPU devices)
                sCoreNum = files.length;
            } catch (Exception e) {
                Log.e(TAG, "getNumCores exception", e);
                sCoreNum = 1;
            }
        }
        return sCoreNum;
    }
634609
def __get_cpu(self):
        """"""
        # Never update more than 1 time per cached_time
        if self.timer_cpu.finished():
            self.cpu_percent = psutil.cpu_percent(interval=0.0)
            # Reset timer for cache
            self.timer_cpu = Timer(self.cached_time)
        return self.cpu_percent
1243885
public function scanCore()
    {
        $coreShells = $this->scanDir(
            dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Shell' . DIRECTORY_SEPARATOR,
            'Cake\Shell\\',
            '',
            ['command_list']
        );
        $coreCommands = $this->scanDir(
            dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Command' . DIRECTORY_SEPARATOR,
            'Cake\Command\\',
            '',
            ['command_list']
        );

        return array_merge($coreShells, $coreCommands);
    }
1114394
def get_cpu_info(self) -> str:
        ''''''
        output, _ = self._execute(
            '-s', self.device_sn, 'shell', 'cat', '/proc/cpuinfo')
        return output
852674
function cpuTemperature() {
  if (_windows) {
    return(NOT_SUPPORTED);
  }
  if (_linux) {
    return(NOT_SUPPORTED);
  }

  if (_darwin) {
    let result = {
      main: -1.0,
      cores: [],
      max: -1.0
    };
    let smc = require('../build/Release/smc');

    let cores = ['TC0P', 'TC1C', 'TC2C', 'TC3C', 'TC4C', 'TC5C', 'TC6C', 'TC7C', 'TC8C'];
    let sum = 0;
    let id = 0;
    cores.forEach(function(key) {
      let value = smc.get(key);
      if (id === 0) {
        if (value > 0) {
          result.main = value;
          result.max = value;
        }
        id = 1;
      } else {
        if (value > 0) {
          result.cores.push(value);
          sum = sum + value;
          if (value > result.max) result.max = value;
        }
      }
    });
    if (result.cores.length) {
      result.main = sum / result.cores.length;
    }

    return(result);
  }
}
882827
def physical_cores(self):
        """"""
        try:
            return self._physical_cores_base()
        except Exception as e:
            from rez.utils.logging_ import print_error
            print_error("Error detecting physical core count, defaulting to 1: %s"
                        % str(e))
        return 1
857396
public function start(): int
    {
        $cmd = $this->getStartCmd();

        exec($cmd, $output, $ret);
        if ($ret !== 0) {
            throw new Exception('Error staring build-in server.');
        }

        $this->pid = (int)$output[0];
        usleep(100000); // We need to allow some time for server to start.

        return $this->pid;
    }
1209043
public static Architecture getArchitecture() {
        if (Architecture.UNKNOWN == myArchitecture) {
            final Processor processor = getProcessor();

            if (Processor.UNKNOWN != processor) {
                final String name = System.getProperty(OS_NAME).toLowerCase(Locale.US);

                if (name.indexOf("nix") >= 0 || name.indexOf("nux") >= 0) {
                    if (Processor.INTEL_32 == processor) {
                        myArchitecture = Architecture.LINUX_32;
                    } else if (Processor.INTEL_64 == processor) {
                        myArchitecture = Architecture.LINUX_64;
                    } else if (Processor.ARM == processor) {
                        myArchitecture = Architecture.LINUX_ARM;
                    }
                } else if (name.indexOf("win") >= 0) {
                    if (Processor.INTEL_32 == processor) {
                        myArchitecture = Architecture.WINDOWS_32;
                    } else if (Processor.INTEL_64 == processor) {
                        myArchitecture = Architecture.WINDOWS_64;
                    }
                } else if (name.indexOf("mac") >= 0) {
                    if (Processor.INTEL_32 == processor) {
                        myArchitecture = Architecture.OSX_32;
                    } else if (Processor.INTEL_64 == processor) {
                        myArchitecture = Architecture.OSX_64;
                    } else if (Processor.PPC == processor) {
                        myArchitecture = Architecture.OSX_PPC;
                    }
                }
            }
        }

        LOGGER.debug(MessageCodes.UTIL_023, myArchitecture, System.getProperty(OS_NAME).toLowerCase(Locale.US));
        return myArchitecture;
    }
218978
public CPUEnum getCpu() {
    if (isReference()) {
      final TargetDef refPlatform = (TargetDef) getCheckedRef(TargetDef.class, "TargetDef");
      return refPlatform.getCpu();
    }
    return this.cpu;
  }
72433
protected function getCPUString($cpus = [])
    {
        if (empty($cpus)) {
            return  '';
        }

        $cpuStrings = [];

        foreach ($cpus as $cpu) {
            $model = $cpu['Model'];
            $model = str_replace('(R)', '®', $model);
            $model = str_replace('(TM)', '™', $model);
            array_push($cpuStrings, $model);
        }

        $cpuStrings = array_unique($cpuStrings);

        return trim(implode(' / ', $cpuStrings));
    }
1289356
def cpuinfo():
    ''' 

    '''

    cpuinfo=OrderedDict()
    procinfo=OrderedDict()

    nprocs = 0
    with open('/proc/cpuinfo') as f:
        for line in f:
            if not line.strip():
                # end of one processor
                cpuinfo['proc%s' % nprocs] = procinfo
                nprocs=nprocs+1
                # Reset
                procinfo=OrderedDict()
            else:
                if len(line.split(':')) == 2:
                    procinfo[line.split(':')[0].strip()] = line.split(':')[1].strip()
                else:
                    procinfo[line.split(':')[0].strip()] = ''
            
    return cpuinfo
85857
protected function _cpuinfo()
    {
        if (CommonFunctions::executeProgram('pidin', 'info', $buf)
           && preg_match('/^Processor\d+: (.*)/m', $buf)) {
            $lines = preg_split("/\n/", $buf, -1, PREG_SPLIT_NO_EMPTY);
            foreach ($lines as $line) {
                if (preg_match('/^Processor\d+: (.+)/', $line, $proc)) {
                    $dev = new CpuDevice();
                    $dev->SetModel(trim($proc[1]));
                    if (preg_match('/(\d+)MHz/', $proc[1], $mhz)) {
                        $dev->setCpuSpeed($mhz[1]);
                    }
                    $this->sys->setCpus($dev);
                }
            }
        }
    }
161442
public function arch()
    {
        if ($this->host_os === 'WINDOWS') {
            $wmi = new \COM("winmgmts:\\\\.\\root\\cimv2");
            $cpu=  $wmi->ExecQuery("Select * from Win32_Processor");

            foreach ($cpu as $c) {
                $arch = '32-bit';
                $cpu_arch = $c->AddressWidth;

                if ($cpu_arch != 32) {
                    $os = $wmi->ExecQuery("Select * from Win32_OperatingSystem");

                    foreach ($os as $o) {
                        if ($o->Version >= 6.0) {
                            $arch = objItem.OSArchitecture;
                        }
                    }
                }
            }
        } else {
            $arch = shell_exec('arch');
        }
        return trim($arch);
    }
969478
protected function prepareProcessors()
    {
        usort($this->processors, function (ProcessorInterface $one, ProcessorInterface $two) {
            if ($one->getPriority() == $two->getPriority()) {
                return 0;
            }

            return $one->getPriority() < $two->getPriority() ? 1 : -1;
        });
    }
299801
public function getScore()
    {
        $ipLkup = $this->get('ipLkup', ['ip' => $this->ip]);

        $score = $ipLkup['response'][$this->ip];

        if ($score) {
            return (string) $score;
        } else {
            return 'unknown';
        }
    }
95417
public function getShopNumber()
    {
        $shopNumber = $this->request->getParam('shop_number');
        $item       = $this->sgCoreConfig->getShopNumberCollection($shopNumber)->getFirstItem();

        return $item->getData('value') ? $shopNumber : '';
    }
118583
def physical_cpus():
    
    if platform.system() == 'Darwin':
        ncores = subprocess.check_output(
            ['/usr/sbin/sysctl', '-n', 'hw.ncpu'], shell=False
        )
        return int(ncores.strip())

    sockets = set()
    with open('/proc/cpuinfo') as istr:
        for line in istr:
            if line.startswith('physical id'):
                sockets.add(line.split(':')[-1].strip())
    return len(sockets)