当前位置: 首页>>代码示例>>PHP>>正文


PHP CpuDevice::getCpuSpeed方法代码示例

本文整理汇总了PHP中CpuDevice::getCpuSpeed方法的典型用法代码示例。如果您正苦于以下问题:PHP CpuDevice::getCpuSpeed方法的具体用法?PHP CpuDevice::getCpuSpeed怎么用?PHP CpuDevice::getCpuSpeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CpuDevice的用法示例。


在下文中一共展示了CpuDevice::getCpuSpeed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cpuinfo

 /**
  * CPU information
  *
  * @return void
  */
 protected function cpuinfo()
 {
     $dev = new CpuDevice();
     if (PSI_OS == "NetBSD") {
         if ($model = $this->grabkey('machdep.cpu_brand')) {
             $dev->setModel($model);
         }
         if ($cpuspeed = $this->grabkey('machdep.tsc_freq')) {
             $dev->setCpuSpeed(round($cpuspeed / 1000000));
         }
     }
     if ($dev->getModel() === "") {
         $dev->setModel($this->grabkey('hw.model'));
     }
     $notwas = true;
     foreach ($this->readdmesg() as $line) {
         if ($notwas) {
             if (preg_match($this->_CPURegExp1, $line, $ar_buf)) {
                 if ($dev->getCpuSpeed() === 0) {
                     $dev->setCpuSpeed(round($ar_buf[2]));
                 }
                 $notwas = false;
             }
         } else {
             if (preg_match("/ Origin| Features/", $line, $ar_buf)) {
                 if (preg_match("/ Features2[ ]*=.*<(.*)>/", $line, $ar_buf)) {
                     $feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
                     foreach ($feats as $feat) {
                         if ($feat == "vmx" || $feat == "svm") {
                             $dev->setVirt($feat);
                             break 2;
                         }
                     }
                     break;
                 }
             } else {
                 break;
             }
         }
     }
     $ncpu = $this->grabkey('hw.ncpu');
     if (is_null($ncpu) || trim($ncpu) == "" || !($ncpu >= 1)) {
         $ncpu = 1;
     }
     for ($ncpu; $ncpu > 0; $ncpu--) {
         $this->sys->setCpus($dev);
     }
 }
开发者ID:arris69,项目名称:phpsysinfo,代码行数:53,代码来源:class.BSDCommon.inc.php

示例2: _cpuinfo


//.........这里部分代码省略.........
                             case 'i size':
                             case 'd size':
                                 if ($dev->getCache() === null) {
                                     $dev->setCache($arrBuff1 * 1024);
                                 } else {
                                     $dev->setCache($dev->getCache() + $arrBuff1 * 1024);
                                 }
                                 break;
                             case 'cpu architecture':
                                 $arch = $arrBuff1;
                                 break;
                             case 'cpu implementer':
                                 $impl = $arrBuff1;
                                 break;
                             case 'cpu part':
                                 $part = $arrBuff1;
                                 break;
                         }
                     }
                 }
                 if ($arch === null) {
                     $arch = $_arch;
                 }
                 if ($impl === null) {
                     $impl = $_impl;
                 }
                 if ($part === null) {
                     $part = $_part;
                 }
                 // sparc64 specific code follows
                 // This adds the ability to display the cache that a CPU has
                 // Originally made by Sven Blumenstein <bazik@gentoo.org> in 2004
                 // Modified by Tom Weustink <freshy98@gmx.net> in 2004
                 $sparclist = array('SUNW,UltraSPARC@0,0', 'SUNW,UltraSPARC-II@0,0', 'SUNW,UltraSPARC@1c,0', 'SUNW,UltraSPARC-IIi@1c,0', 'SUNW,UltraSPARC-II@1c,0', 'SUNW,UltraSPARC-IIe@0,0');
                 foreach ($sparclist as $name) {
                     if (CommonFunctions::rfts('/proc/openprom/' . $name . '/ecache-size', $buf, 1, 32, false)) {
                         $dev->setCache(base_convert($buf, 16, 10));
                     }
                 }
                 // sparc64 specific code ends
                 // XScale detection code
                 if ($arch === "5TE" && $dev->getBogomips() != null) {
                     $dev->setCpuSpeed($dev->getBogomips());
                     //BogoMIPS are not BogoMIPS on this CPU, it's the speed
                     $dev->setBogomips(null);
                     // no BogoMIPS available, unset previously set BogoMIPS
                 }
                 if ($dev->getBusSpeed() == 0 && $_buss !== null) {
                     $dev->setBusSpeed($_buss);
                 }
                 if ($dev->getCpuSpeed() == 0 && $_cpus !== null) {
                     $dev->setCpuSpeed($_cpus);
                 }
                 if ($proc != null) {
                     if (!is_numeric($proc)) {
                         $proc = 0;
                     }
                     // variable speed processors specific code follows
                     if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_cur_freq', $buf, 1, 4096, false)) {
                         $dev->setCpuSpeed($buf / 1000);
                     } elseif (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) {
                         $dev->setCpuSpeed($buf / 1000);
                     }
                     if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false)) {
                         $dev->setCpuSpeedMax($buf / 1000);
                     }
                     if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false)) {
                         $dev->setCpuSpeedMin($buf / 1000);
                     }
                     // variable speed processors specific code ends
                     if (PSI_LOAD_BAR) {
                         $dev->setLoad($this->_parseProcStat('cpu' . $proc));
                     }
                     if (CommonFunctions::rfts('/proc/acpi/thermal_zone/THRM/temperature', $buf, 1, 4096, false)) {
                         $dev->setTemp(substr($buf, 25, 2));
                     }
                     // Raspbery detection
                     if ($arch === '7' && $impl === '0x41' && ($_hard === 'BCM2708' || $_hard === 'BCM2709' || $_hard === 'BCM2710') && $_revi !== null) {
                         if (($cputype = $this->setRaspberry($_revi, $part)) !== "") {
                             if (($cpumodel = $dev->getModel()) !== "") {
                                 $dev->setModel($cpumodel . ' - ' . $cputype);
                             } else {
                                 $dev->setModel($cputype);
                             }
                         }
                     } else {
                         // other hardware
                         if ($_hard !== null && $this->sys->getMachine() === "") {
                             $this->sys->setMachine($_hard);
                         }
                     }
                     if ($dev->getModel() === "") {
                         $dev->setModel("unknown");
                     }
                     $this->sys->setCpus($dev);
                 }
             }
         }
     }
 }
开发者ID:phpsysinfo,项目名称:phpsysinfo,代码行数:101,代码来源:class.Linux.inc.php


注:本文中的CpuDevice::getCpuSpeed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。