本文整理汇总了PHP中CpuDevice::SetModel方法的典型用法代码示例。如果您正苦于以下问题:PHP CpuDevice::SetModel方法的具体用法?PHP CpuDevice::SetModel怎么用?PHP CpuDevice::SetModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CpuDevice
的用法示例。
在下文中一共展示了CpuDevice::SetModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _cpuinfo
/**
* get the cpu information
*
* @return array
*/
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);
}
}
}
}
示例2: _cpuinfo
/**
* get the cpu information
*
* @return array
*/
protected function _cpuinfo()
{
if (CommonFunctions::rfts('/proc/cpuinfo', $bufr, 0, 4096, false)) {
$processors = preg_split('/\\s?\\n\\s?\\n/', trim($bufr));
foreach ($processors as $processor) {
$_n = "";
$_f = "";
$_m = "";
$_s = "";
$dev = new CpuDevice();
$details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
foreach ($details as $detail) {
$arrBuff = preg_split('/\\s+:\\s+/', trim($detail));
if (count($arrBuff) == 2) {
switch (strtolower($arrBuff[0])) {
case 'model name':
$_n = $arrBuff[1];
break;
case 'cpu mhz':
$dev->setCpuSpeed($arrBuff[1]);
break;
case 'cpu family':
$_f = $arrBuff[1];
break;
case 'model':
$_m = $arrBuff[1];
break;
case 'stepping':
$_s = $arrBuff[1];
break;
case 'flags':
if (preg_match("/ vmx/", $arrBuff[1])) {
$dev->setVirt("vmx");
} else {
if (preg_match("/ svm/", $arrBuff[1])) {
$dev->setVirt("svm");
}
}
break;
}
}
}
if ($_n == "") {
$_n = "CPU";
}
if ($_f != "") {
$_n .= " Family " . $_f;
}
if ($_m != "") {
$_n .= " Model " . $_m;
}
if ($_s != "") {
$_n .= " Stepping " . $_s;
}
$dev->SetModel($_n);
$this->sys->setCpus($dev);
}
} else {
foreach ($this->readdmesg() as $line) {
if (preg_match('/kernel: (CPU .*) freq (.*) MHz/', $line, $ar_buf)) {
$dev = new CpuDevice();
$dev->setModel($ar_buf[1]);
$dev->setCpuSpeed($ar_buf[2]);
$this->sys->setCpus($dev);
}
}
}
}