private function detectarNucleosCPU()
    {
        $cantidad_cpu = 1;
        if (is_file('/proc/cpuinfo')) {
            $cpu_info = file_get_contents('/proc/cpuinfo');
            preg_match_all('/^processor/m', $cpu_info, $matches);
            $cantidad_cpu = count($matches[0]);
        } else if ('WIN' == strtoupper(substr(PHP_OS, 0, 3))) {
            $process = @popen('wmic cpu get NumberOfCores', 'rb');
            if (false !== $process) {
                fgets($process);
                $cantidad_cpu = intval(fgets($process));
                pclose($process);
            }
        } else {
            $process = @popen('sysctl -a', 'rb');
            if (false !== $process) {
                $output = stream_get_contents($process);
                preg_match('/hw.ncpu: (\d+)/', $output, $matches);
                if ($matches) {
                    $cantidad_cpu = intval($matches[1][0]);
                }
                pclose($process);
            }
        }

        return $cantidad_cpu;
    }
private function detectarNucleosCPU()
    {
        $cantidad_cpu = 1;
        if (is_file('/proc/cpuinfo')) {
            $cpu_info = file_get_contents('/proc/cpuinfo');
            preg_match_all('/^processor/m', $cpu_info, $matches);
            $cantidad_cpu = count($matches[0]);
        } else if ('WIN' == strtoupper(substr(PHP_OS, 0, 3))) {
            $process = @popen('wmic cpu get NumberOfCores', 'rb');
            if (false !== $process) {
                fgets($process);
                $cantidad_cpu = intval(fgets($process));
                pclose($process);
            }
        } else {
            $process = @popen('sysctl -a', 'rb');
            if (false !== $process) {
                $output = stream_get_contents($process);
                preg_match('/hw.ncpu: (\d+)/', $output, $matches);
                if ($matches) {
                    $cantidad_cpu = intval($matches[1][0]);
                }
                pclose($process);
            }
        }

        return $cantidad_cpu;
    }
private function detectarNucleosCPU ( ) { $ cantidad_cpu = 1 ; if ( is_file ( '/proc/cpuinfo' ) ) { $ cpu_info = file_get_contents ( '/proc/cpuinfo' ) ; preg_match_all ( '/^processor/m' , $ cpu_info , $ matches ) ; $ cantidad_cpu = count ( $ matches [ 0 ] ) ; } else if ( 'WIN' == strtoupper ( substr ( PHP_OS , 0 , 3 ) ) ) { $ process = @ popen ( 'wmic cpu get NumberOfCores' , 'rb' ) ; if ( false !== $ process ) { fgets ( $ process ) ; $ cantidad_cpu = intval ( fgets ( $ process ) ) ; pclose ( $ process ) ; } } else { $ process = @ popen ( 'sysctl -a' , 'rb' ) ; if ( false !== $ process ) { $ output = stream_get_contents ( $ process ) ; preg_match ( '/hw.ncpu: (\d+)/' , $ output , $ matches ) ; if ( $ matches ) { $ cantidad_cpu = intval ( $ matches [ 1 ] [ 0 ] ) ; } pclose ( $ process ) ; } } return $ cantidad_cpu ; }
Devuelve la cantidad de nucleos del CPU

@return int
Devuelve la cantidad de nucleos del CPU