How to use is_macos method of phodevi class

Best Phoronix-test-suite code snippet using phodevi.is_macos

phodevi_cpu.php

Source:phodevi_cpu.php Github

copy

Full Screen

...117 else if(phodevi::is_bsd())118 {119 $info = intval(phodevi_bsd_parser::read_sysctl(array('hw.ncpufound', 'hw.ncpu')));120 }121 else if(phodevi::is_macos())122 {123 $info = intval(phodevi_bsd_parser::read_sysctl(array('hw.ncpu')));124 if(empty($info))125 {126 $info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'TotalNumberOfCores');127 }128 }129 if(phodevi::is_windows())130 {131 // Should be hit by the first NUMBER_OF_PROCESSORS env check...132 $logical_cores = array_sum(phodevi_windows_parser::get_wmi_object('Win32_Processor', 'NumberOfLogicalProcessors', true));133 if($logical_cores > $info || !is_numeric($info))134 {135 $info = $logical_cores;136 }137 }138 if($info == null && isset(phodevi::$vfs->cpuinfo))139 {140 $info = self::cpuinfo_thread_count();141 }142 return (is_numeric($info) && $info > 0 ? $info : 1);143 }144 public static function cpu_physical_core_count()145 {146 $physical_cores = null;147 if(phodevi::is_linux())148 {149 $physical_cores = phodevi_cpu::cpuinfo_core_count();150 if(empty($physical_cores) || $physical_cores == phodevi::read_property('cpu', 'thread-count'))151 {152 // Needed for POWER9 at least153 if(isset(phodevi::$vfs->lscpu) && ($t = strpos(phodevi::$vfs->lscpu, 'Core(s) per socket:')))154 {155 $lscpu = substr(phodevi::$vfs->lscpu, $t + strlen('Core(s) per socket:') + 1);156 $lscpu = substr($lscpu, 0, strpos($lscpu, PHP_EOL));157 $cores_per_socket = trim($lscpu);158 if($cores_per_socket > 1 && ($t = strpos(phodevi::$vfs->lscpu, 'Socket(s):')))159 {160 $lscpu = substr(phodevi::$vfs->lscpu, $t + strlen('Socket(s):') + 1);161 $lscpu = substr($lscpu, 0, strpos($lscpu, PHP_EOL));162 $sockets = trim($lscpu);163 if(is_numeric($sockets) && $sockets >= 1)164 {165 $physical_cores = $cores_per_socket * $sockets;166 }167 }168 }169 }170 }171 else if(phodevi::is_bsd())172 {173 // hw.cpu_topology_core_ids works at least on DragonFly BSD174 $ht_ids = intval(phodevi_bsd_parser::read_sysctl(array('hw.cpu_topology_ht_ids')));175 if($ht_ids == 2)176 {177 $info = intval(phodevi_bsd_parser::read_sysctl(array('hw.ncpu')));178 if($info > 1)179 {180 $physical_cores = $info / 2;181 }182 }183 else184 {185 $phys_ids = intval(phodevi_bsd_parser::read_sysctl(array('hw.cpu_topology_phys_ids')));186 $physical_cores = intval(phodevi_bsd_parser::read_sysctl(array('hw.cpu_topology_core_ids')));187 if($phys_ids > 0 && ($phys_ids * $physical_cores) <= phodevi::read_property('cpu', 'thread-count') && $physical_cores % 2 == 0)188 {189 $physical_cores = $phys_ids * $physical_cores;190 }191 }192 }193 else if(phodevi::is_macos())194 {195 $physical_cores = intval(phodevi_bsd_parser::read_sysctl(array('hw.physicalcpu')));196 }197 else if(phodevi::is_windows())198 {199 $physical_cores = array_sum(phodevi_windows_parser::get_wmi_object('Win32_Processor', 'NumberOfCores', true));200 }201 if(empty($physical_cores) || !is_numeric($physical_cores))202 {203 $physical_cores = phodevi::read_property('cpu', 'core-count');204 }205 return $physical_cores;206 }207 public static function cpu_thread_count()208 {209 $threads = null;210 if(phodevi::is_linux())211 {212 $threads = phodevi_cpu::cpuinfo_thread_count();213 }214 else215 {216 $threads = phodevi::read_property('cpu', 'core-count');217 }218 return $threads;219 }220 public static function cpu_node_count()221 {222 $node_count = 1;223 if(isset(phodevi::$vfs->lscpu) && ($t = strpos(phodevi::$vfs->lscpu, 'NUMA node(s):')))224 {225 $lscpu = substr(phodevi::$vfs->lscpu, $t + strlen('NUMA node(s):') + 1);226 $lscpu = substr($lscpu, 0, strpos($lscpu, PHP_EOL));227 $node_count = trim($lscpu);228 }229 return (is_numeric($node_count) && $node_count > 0 ? $node_count : 1);230 }231 public static function cpu_cache_size()232 {233 $cache_size = 0; // in KB234 if(phodevi::is_linux())235 {236 if(isset(phodevi::$vfs->lscpu) && ($t = strpos(phodevi::$vfs->lscpu, 'L3 cache:')))237 {238 $lscpu = substr(phodevi::$vfs->lscpu, $t + strlen('L3 cache:') + 1);239 $lscpu = substr($lscpu, 0, strpos($lscpu, PHP_EOL));240 $lscpu = trim($lscpu);241 $cache_size = pts_math::number_with_unit_to_mb($lscpu);242 }243 if(empty($cache_size) || !is_numeric($cache_size))244 {245 $cache_size = self::cpuinfo_cache_size();246 }247 }248 else if(phodevi::is_macos())249 {250 $cache_size = pts_math::number_with_unit_to_mb(phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'L3Cache'));251 }252 else if(phodevi::is_windows())253 {254 $cache_size = phodevi_windows_parser::get_wmi_object('Win32_Processor', 'L2CacheSize');255 }256 return $cache_size;257 }258 public static function cpu_default_frequency_mhz()259 {260 return self::cpu_default_frequency() * 1000;261 }262 public static function cpu_scaling_governor()263 {264 $scaling_governor = false;265 if(is_file('/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver'))266 {267 $scaling_governor = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver') . ' ';268 }269 if(is_file('/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'))270 {271 $scaling_governor .= pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor');272 }273 if(!empty($scaling_governor))274 {275 $append_notes = array();276 if(is_file('/sys/devices/system/cpu/cpufreq/boost'))277 {278 $boost = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpufreq/boost');279 $boosted = null;280 if($boost === '0')281 {282 $boosted = 'Disabled';283 }284 else if($boost === '1')285 {286 $boosted = 'Enabled';287 }288 if($boosted != null)289 {290 $append_notes[] = 'Boost: ' . $boosted;291 }292 }293 if(is_file('/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference'))294 {295 $epp = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference');296 if($epp != null)297 {298 $append_notes[] = 'EPP: ' . $epp;299 }300 }301 if(!empty($append_notes))302 {303 $scaling_governor = trim($scaling_governor) . ' (' . implode(', ', $append_notes) . ')';304 }305 }306 return trim($scaling_governor);307 }308 public static function cpu_power_management()309 {310 $pm = array();311 if(is_file('/sys/firmware/acpi/platform_profile'))312 {313 $platform_profile = pts_file_io::file_get_contents('/sys/firmware/acpi/platform_profile');314 if(!empty($platform_profile))315 {316 $pm[] = 'ACPI Platform Profile: ' . $platform_profile;317 }318 }319 if(is_file('/sys/bus/pci/devices/0000:00:04.0/workload_request/workload_type'))320 {321 // Intel INT340x Workload Type322 $workload_type = pts_file_io::file_get_contents('/sys/bus/pci/devices/0000:00:04.0/workload_request/workload_type');323 if(!empty($workload_type) && $workload_type != 'none')324 {325 $pm[] = 'INT340x Workload Type: ' . $workload_type;326 }327 }328 return implode(' - ', $pm);329 }330 public static function cpu_smt()331 {332 $smt = false;333 if(pts_client::executable_in_path('ppc64_cpu')) {334 $ppc64 = trim(shell_exec('ppc64_cpu --smt -n | grep SMT= | cut -d= -f2'));335 if(is_numeric($ppc64) && $ppc64 >= 1)336 $smt = $ppc64;337 }338 return trim($smt);339 }340 public static function is_genuine($cpu)341 {342 /*343 Real/Genuine CPUs should have:344 1. Contain more than one word in string345 2. Check vendor (to avoid QEMU, Virtual CPU, etc): Intel, VIA, AMD, ARM, SPARC346 */347 return strpos($cpu, ' ') !== false && strpos($cpu, ' ') != strrpos($cpu, ' ') && pts_strings::has_in_istring($cpu, array('Intel', 'VIA', 'AMD', 'ARM', 'SPARC', 'Transmeta')) && stripos($cpu, 'unknown') === false;348 }349 public static function cpu_microcode_version()350 {351 $ucode_version = null;352 if(is_readable('/sys/devices/system/cpu/cpu0/microcode/version'))353 {354 $ucode_version = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu0/microcode/version');355 }356 if(empty($ucode_version) && isset(phodevi::$vfs->cpuinfo))357 {358 $ucode_version = self::read_cpuinfo_line('microcode');359 }360 else if(phodevi::is_windows())361 {362 $reg = shell_exec('reg query HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0');363 if(($x = strpos($reg, 'Update Revision')) !== false)364 {365 $reg = substr($reg, $x);366 $reg = substr($reg, 0, strpos($reg, "\n"));367 $ucode = substr($reg, strrpos($reg, ' '));368 if(is_numeric($ucode))369 {370 $ucode_version = $ucode;371 }372 }373 }374 if(empty($ucode_version) && phodevi::is_macos())375 {376 $ucode_version = phodevi_bsd_parser::read_sysctl(array('machdep.cpu.microcode_version'));377 }378 return $ucode_version;379 }380 public static function cpu_default_frequency($cpu_core = 0)381 {382 // Find out the processor frequency383 $info = null;384 // First, the ideal way, with modern CPUs using CnQ or EIST and cpuinfo reporting the current385 if(phodevi::is_linux())386 {387 if(is_file('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_max_freq'))388 {389 $info = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_max_freq');390 $info = intval($info) / 1000000;391 if($info > 9)392 {393 // For some reason on Linux 3.10 the scaling_max_freq is reported as 25GHz...394 $info = null;395 }396 }397 if($info == null && isset(phodevi::$vfs->cpuinfo) && phodevi::read_property('system', 'kernel-architecture') != 'x86_64') // fall back for those without cpufreq398 {399 // Don't use this code path for x86_64 since for those systems the /sys reporting should work400 // and when that isn't the case, CPUFreq not loaded and thus reported here is usually dynamic frequency401 $cpu_mhz = self::read_cpuinfo_line('cpu MHz');402 $info = $cpu_mhz / 1000;403 if(empty($info))404 {405 $cpu_mhz = str_replace('MHz', '', self::read_cpuinfo_line('clock'));406 if(is_numeric($cpu_mhz))407 {408 $info = $cpu_mhz / 1000;409 }410 }411 }412 }413 else if($info == null && phodevi::is_bsd())414 {415 $info = phodevi_bsd_parser::read_sysctl(array('dev.cpu.0.freq_levels'));416 if($info != null)417 {418 // Popping the top speed off of dev.cpu.0.freq_levels should be the default/highest supported frequency419 $info = pts_arrays::first_element(explode(' ', str_replace('/', ' ', $info)));420 if(!is_numeric($info))421 {422 $info = null;423 }424 }425 if($info == null)426 {427 $info = phodevi_bsd_parser::read_sysctl(array('hw.acpi.cpu.px_global', 'machdep.est.frequency.target', 'hw.cpuspeed'));428 }429 if($info == null)430 {431 // dev.cpu.0.freq seems to be the real/current frequency, affected by power management, etc so only use as last fallback432 $info = phodevi_bsd_parser::read_sysctl(array('dev.cpu.0.freq'));433 }434 if(is_numeric($info))435 {436 $info = $info / 1000;437 }438 else439 {440 $info = null;441 }442 }443 else if($info == null && phodevi::is_windows())444 {445 $info = phodevi_windows_parser::get_wmi_object('win32_processor', 'MaxClockSpeed');446 if($info != null && is_numeric($info))447 {448 $info = $info / 1000;449 }450 else451 {452 $info = null;453 }454 }455 else if($info == null)456 {457 $freq_sensor = new cpu_freq(0, NULL);458 $info = phodevi::read_sensor($freq_sensor);459 unset($freq_sensor);460 if($info > 1000)461 {462 // Convert from MHz to GHz463 $info = $info / 1000;464 }465 }466 return pts_math::set_precision($info, 2);467 }468 public static function cpu_model()469 {470 // Returns the processor name / frequency information471 $info = null;472 if(isset(phodevi::$vfs->cpuinfo))473 {474 $physical_cpu_ids = phodevi_linux_parser::read_cpuinfo('physical id');475 $physical_cpu_count = count(array_unique($physical_cpu_ids));476 $cpu_strings = phodevi_linux_parser::read_cpuinfo(array('model name', 'Processor', 'cpu', 'cpu model'));477 $cpu_strings_unique = array_unique($cpu_strings);478 if($physical_cpu_count == 1 || empty($physical_cpu_count))479 {480 // Just one processor481 if(isset($cpu_strings[0]) && ($cut = strpos($cpu_strings[0], ' (')) !== false)482 {483 $cpu_strings[0] = substr($cpu_strings[0], 0, $cut);484 }485 $info = isset($cpu_strings[0]) ? $cpu_strings[0] : null;486 // Fallback CPU detection487 switch($info)488 {489 case 'AMD Eng Sample: 100-000000163_43/29_Y':490 if(count($physical_cpu_ids) == 128)491 {492 $info = 'AMD Ryzen Threadripper 3990X 64-Core';493 }494 break;495 default:496 $info = str_replace(': ', ' ', $info);497 break;498 }499 if(strpos($info, 'ARM') !== false)500 {501 if(is_dir('/sys/devices/system/exynos-core/') && stripos($info, 'Exynos') === false)502 {503 $info = 'Exynos ' . $info;504 }505 }506 }507 else if($physical_cpu_count > 1 && count($cpu_strings_unique) == 1)508 {509 // Multiple processors, same model510 $info = $physical_cpu_count . ' x ' . $cpu_strings[0];511 }512 else if($physical_cpu_count > 1 && count($cpu_strings_unique) > 1)513 {514 // Multiple processors, different models515 $current_id = -1;516 $current_string = $cpu_strings[0];517 $current_count = 0;518 $cpus = array();519 for($i = 0; $i < count($physical_cpu_ids); $i++)520 {521 if($current_string != $cpu_strings[$i] || $i == (count($physical_cpu_ids) - 1))522 {523 array_push($cpus, $current_count . ' x ' . $current_string);524 $current_string = $cpu_strings[$i];525 $current_count = 0;526 }527 if($physical_cpu_ids[$i] != $current_id)528 {529 $current_count++;530 $current_id = $physical_cpu_ids[$i];531 }532 }533 $info = implode(', ', $cpus);534 }535 }536 else if(phodevi::is_solaris())537 {538 $dmi_cpu = phodevi_solaris_parser::read_sun_ddu_dmi_info('CPUType', '-C');539 if(count($dmi_cpu) == 0)540 {541 $dmi_cpu = phodevi_solaris_parser::read_sun_ddu_dmi_info('ProcessorName');542 }543 if(count($dmi_cpu) > 0)544 {545 $info = $dmi_cpu[0];546 }547 else548 {549 $info = trim(shell_exec('dmesg 2>&1 | grep cpu0'));550 $info = trim(substr($info, strrpos($info, 'cpu0:') + 6));551 if(empty($info))552 {553 $info = array_pop(phodevi_solaris_parser::read_sun_ddu_dmi_info('ProcessorManufacturer'));554 }555 }556 //TODO: Add in proper support for reading multiple CPUs, similar to the code from above557 $physical_cpu_count = count(phodevi_solaris_parser::read_sun_ddu_dmi_info('ProcessorSocketType'));558 if($physical_cpu_count > 1 && !empty($info))559 {560 // TODO: For now assuming when multiple CPUs are installed, that they are of the same type561 $info = $physical_cpu_count . ' x ' . $info;562 }563 }564 else if(phodevi::is_bsd())565 {566 $info = phodevi_bsd_parser::read_sysctl('hw.model');567 }568 else if(phodevi::is_macos())569 {570 $info = phodevi_bsd_parser::read_sysctl('machdep.cpu.brand_string');571 if(empty($info) || strtolower($info) == 'apple processor')572 {573 $info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'Chip');574 }575 if(empty($info))576 {577 $info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'ProcessorName');578 }579 }580 else if(phodevi::is_windows())581 {582 $info = phodevi_windows_parser::get_wmi_object('win32_processor', 'Name');583 $cpu_count = count(phodevi_windows_parser::get_wmi_object('Win32_Processor', 'DeviceID', true));584 if($cpu_count > 1)585 {586 $info = $cpu_count . ' x ' . $info;587 }588 if(!$info)589 {590 $info = getenv('PROCESSOR_IDENTIFIER');591 }592 }593 if(empty($info) || strpos($info, 'rev ') !== false)594 {595 if(phodevi::is_linux())596 {597 $new_info = null;598 $implementer = phodevi_linux_parser::read_cpuinfo_single('CPU implementer');599 if($implementer == '0x41' || $implementer == '0x50')600 {601 $architecture = phodevi_linux_parser::read_cpuinfo_single('CPU architecture');602 switch($architecture)603 {604 case '7':605 $new_info = 'ARMv7';606 break;607 case '8':608 case 'AArch64':609 $new_info = 'ARMv8';610 break;611 }612 $part = phodevi_linux_parser::read_cpuinfo_single('CPU part');613 // parts listed @ https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/arm/arm-cpus.in614 switch($part)615 {616 case '0xc07':617 $new_info .= ' Cortex-A7';618 break;619 case '0xc20':620 $new_info .= ' Cortex-M7';621 break;622 case '0xc09':623 $new_info .= ' Cortex-A9';624 break;625 case '0xc0f':626 $new_info .= ' Cortex-A15';627 break;628 case '0xc0e':629 $new_info .= ' Cortex-A12';630 break;631 case '0xd01':632 $new_info .= ' Cortex-A32';633 break;634 case '0xd03':635 $new_info .= ' Cortex-A53';636 break;637 case '0xd05':638 $new_info .= ' Cortex-A55';639 break;640 case '0xd07':641 $new_info .= ' Cortex-A57';642 break;643 case '0xd06':644 $new_info .= ' Cortex-A65';645 break;646 case '0xd43':647 $new_info .= ' Cortex-A65AE';648 break;649 case '0xd08':650 $new_info .= ' Cortex-A72';651 break;652 case '0xd09':653 $new_info .= ' Cortex-A73';654 break;655 case '0xd0a':656 $new_info .= ' Cortex-A75';657 break;658 case '0xd0b':659 $new_info .= ' Cortex-A76';660 break;661 case '0xd0e':662 $new_info .= ' Cortex-A76AE';663 break;664 case '0xd0d':665 $new_info .= ' Cortex-A77';666 break;667 case '0xd0c':668 $new_info .= ' Neoverse-N1';669 break;670 case '0xd40':671 $new_info .= ' Neoverse-V1';672 break;673 case '0xd44':674 $new_info .= ' Cortex-X1';675 break;676 case '0xd47':677 $new_info .= ' Cortex-A710';678 break;679 case '0xd48':680 $new_info .= ' Cortex-X2';681 break;682 case '0xd49':683 $new_info .= ' Neoverse-N2';684 break;685 case '0xd4a':686 $new_info .= ' Neoverse-E1';687 break;688 case '0xd13':689 $new_info .= ' Cortex-R52';690 break;691 case '0xd20':692 $new_info .= ' Cortex-M23';693 break;694 case '0xd21':695 $new_info .= ' Cortex-M33';696 break;697 }698 }699 if(strpos(phodevi::$vfs->dmesg, 'Ampere eMAG') !== false || stripos(pts_file_io::file_get_contents_if_exists('/sys/devices/virtual/dmi/id/sys_vendor'), 'Ampere') !== false || stripos(pts_file_io::file_get_contents_if_exists('/sys/devices/virtual/dmi/id/bios_vendor'), 'Ampere') !== false)700 {701 $product_family = pts_file_io::file_get_contents_if_exists('/sys/devices/virtual/dmi/id/product_family');702 $sys_vendor = pts_file_io::file_get_contents_if_exists('/sys/devices/virtual/dmi/id/sys_vendor');703 if(stripos($product_family, 'Quicksilver') !== false)704 {705 $new_info = 'Ampere Altra ' . $new_info;706 }707 else if(stripos($sys_vendor, 'Lenovo') !== false || stripos($product_family, 'eMAG') !== false)708 {709 $new_info = 'Ampere eMAG ' . $new_info;710 }711 else712 {713 $new_info = 'Ampere ' . $new_info;714 }715 }716 else if(strpos(phodevi::$vfs->dmesg, 'thunderx') !== false || strpos(phodevi::$vfs->dmesg, 'Cavium erratum') !== false)717 {718 // Haven't found a better way to detect ThunderX as not exposed via cpuinfo, etc719 $new_info = 'Cavium ThunderX ' . $new_info;720 }721 else if(strpos(phodevi::$vfs->dmesg, 'rockchip-cpuinfo') !== false)722 {723 // Haven't found a better way to detect Rockchip as not exposed via cpuinfo, etc724 $new_info = 'Rockchip ' . $new_info;725 }726 else if(is_file('/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver'))727 {728 $scaling_driver = file_get_contents('/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver');729 if(strpos($scaling_driver, 'meson_') !== false)730 {731 $new_info = 'Amlogic ' . $new_info;732 }733 }734 if(!empty($new_info))735 {736 $info = trim($new_info);737 }738 if(empty($info))739 {740 $isa = phodevi_linux_parser::read_cpuinfo_single('isa');741 $uarch = phodevi_linux_parser::read_cpuinfo_single('uarch');742 if(!empty($uarch) && stripos($isa, 'rv') !== false && strpos($uarch, 'sifive') !== false)743 {744 $info = 'SiFive RISC-V';745 }746 else if(!empty($isa))747 {748 $info = $isa;749 }750 }751 }752 if(empty($info))753 {754 $info = 'Unknown';755 }756 }757 else758 {759 if(($strip_point = strpos($info, '@')) > 0)760 {761 $info = trim(substr($info, 0, $strip_point)); // stripping out the reported freq, since the CPU could be overclocked, etc762 }763 $info = pts_strings::strip_string($info);764 // It seems Intel doesn't report its name when reporting Pentium hardware765 if(strpos($info, 'Pentium') !== false && strpos($info, 'Intel') === false)766 {767 $info = 'Intel ' . $info;768 }769 if(substr($info, 0, 5) == 'Intel')770 {771 $cpu_words = explode(' ', $info);772 $cpu_words_count = count($cpu_words);773 // Convert strings like 'Intel Core i7 M 620' -> 'Intel Core i7 620M' and 'Intel Core i7 X 990' -> 'Intel Core i7 990X' to better reflect Intel product marketing names774 if($cpu_words_count > 4 && is_numeric($cpu_words[($cpu_words_count - 1)]) && strlen($cpu_words[($cpu_words_count - 2)]) == 1 && strlen($cpu_words[($cpu_words_count - 3)]) == 2)775 {776 $cpu_words[($cpu_words_count - 1)] .= $cpu_words[($cpu_words_count - 2)];777 unset($cpu_words[($cpu_words_count - 2)]);778 $info = implode(' ', $cpu_words);779 }780 }781 else if(($gen = strpos($info, ' Gen')) !== false && ($intel = strpos($info, 'Intel ')) !== false && $gen < $intel)782 {783 // Tiger Lake reports "11th Gen Intel" as CPU string784 $info = substr($info, $intel);785 }786 }787 if(($c = strpos($info, '-Core ')) !== false && $c < strpos($info, ' '))788 {789 // At least on newer macOS, they append strings like 6-Core prior to Intel790 $info = substr($info, ($c + 6));791 }792 return $info;793 }794 public static function get_cpu_feature_constants()795 {796 return array(797 'sse2' => (1 << 1), // SSE 2798 'sse3' => (1 << 2), // SSE 3799 'sse4a' => (1 << 3), // SSE 4a800 'sse4_1' => (1 << 4), // SSE 4.1801 'sse4_2' => (1 << 5), // SSE 4.2802 //'sse5' => (1 << 6), // SSE 5803 'avx' => (1 << 7), // AVX804 'avx2' => (1 << 8), // AVX2805 'aes' => (1 << 9), // AES806 'epb' => (1 << 10), // EPB807 'svm' => (1 << 11), // AMD SVM (Virtualization)808 'vmx' => (1 << 12), // Intel Virtualization809 'xop' => (1 << 13), // AMD XOP Instruction Set810 'fma3' => (1 << 14), // FMA3 Instruction Set811 'fma4' => (1 << 15), // FMA4 Instruction Set812 'fma' => (1 << 16), // FMA4 Instruction Set813 'rdrand' => (1 << 17), // Intel Bull Mountain RDRAND - Ivy Bridge814 'fsgsbase' => (1 << 18), // FSGSBASE - Ivy Bridge AVX815 'bmi2' => (1 << 19), // Intel Haswell has BMI2816 'avx512cd' => (1 << 20), // AVX-512817 'avx512_vnni' => (1 << 21), // AVX-512 VNNI (DL BOOST)818 'avx512_bf16' => (1 << 22), // AVX-512 BFloat16819 'amx_tile' => (1 << 23), // AMX820 'vaes' => (1 << 24),821 );822 }823 public static function prominent_cpu_features()824 {825 return array(826 'sse4_2' => 'SSE 4.2', // SSE 4.2827 'avx' => 'AVX', // AVX828 'avx2' => 'AVX2', // AVX2829 'aes' => 'AES', // AES830 'vaes' => 'VAES', // AES831 'svm' => 'AMD SVM', // AMD SVM (Virtualization)832 'vmx' => 'Intel VT-d', // Intel Virtualization833 'fma' => 'FMA', // FMA Instruction Set834 'fma3' => 'FMA3', // FMA3 Instruction Set835 'fma4' => 'FMA4', // FMA4 Instruction Set836 'rdrand' => 'RdRand', // Intel Bull Mountain RDRAND - Ivy Bridge837 'fsgsbase' => 'FSGSBASE', // FSGSBASE - Ivy Bridge AVX838 'bmi2' => 'BMI2', // Intel Haswell has BMI2839 'avx512cd' => 'AVX-512', // AVX-512840 'avx512_vnni' => 'AVX-512 VNNI / DL-BOOST', // AVX-512 VNNI (DL BOOST)841 'avx512_bf16' => 'AVX-512 BFloat16', // AVX-512 BFloat16842 'amx_tile' => 'AMX', // Advanced Matrix Extensions843 );844 }845 public static function interesting_instructions()846 {847 return array(848 'MMX' => array('emms', 'maskmovq', 'movq', 'movntq', 'packssdw', 'packsswb', 'packuswb', 'paddb', 'paddd', 'paddsb', 'paddsw', 'paddusb', 'paddusw', 'paddw', 'pand', 'pandn', 'pavgusb', 'pavgb', 'pavgw', 'pcmpeqb', 'pcmpeqd', 'pcmpeqw', 'pcmpgtb', 'pcmpgtd', 'pcmpgtw', 'pextrw', 'pinsrw', 'pmaddwd', 'pmaxsw', 'pmaxub', 'pminsw', 'pminub', 'pmovmskb', 'pmulhw', 'pmullw', 'pmulhuw', 'por', 'psadbw', 'pshufw', 'pslld', 'psllq', 'psllw', 'psrad', 'psraw', 'psrld', 'psrlq', 'psrlw', 'psubb', 'psubd', 'psubsb', 'psubsw', 'psubusb', 'psubusw', 'psubw', 'punpckhbw', 'punpckhdq', 'punpckhwd', 'punpcklbw', 'punpckldq', 'punpcklwd', 'pxor'),849 'SSE' => array('addps', 'addss', 'andnps', 'andps', 'cmpeqps', 'cmpeqss', 'cmpleps', 'cmpless', 'cmpltps', 'cmpltss', 'cmpneqps', 'cmpneqss', 'cmpnleps', 'cmpnless', 'cmpnltps', 'cmpnltss', 'cmpordps', 'cmpordss', 'cmpps', 'cmpss', 'cmpunordps', 'cmpunordss', 'comiss', 'cvtpi2ps', 'cvtps2pi', 'cvtsi2ss', 'cvtss2si', 'cvttps2pi', 'cvttss2si', 'divps', 'divss', 'ldmxcsr', 'maxps', 'maxss', 'minps', 'minss', 'movaps', 'movhlps', 'movhps', 'movlhps', 'movlps', 'movmskps', 'movntps', 'movss', 'movups', 'mulps', 'mulss', 'orps', 'rcpps', 'rcpss', 'rsqrtps', 'rsqrtss', 'shufps', 'sqrtps', 'sqrtss', 'stmxcsr', 'subps', 'subss', 'ucomiss', 'unpckhps', 'unpcklps', 'xorps'),850 'SSE2' => array('addpd', 'addsd', 'andnpd', 'andpd', 'clflush', 'cmpeqpd', 'cmpeqsd', 'cmplepd', 'cmplesd', 'cmpltpd', 'cmpltsd', 'cmpneqpd', 'cmpneqsd', 'cmpnlepd', 'cmpnlesd', 'cmpnltpd', 'cmpnltsd', 'cmpordpd', 'cmpordsd', 'cmppd', 'cmpunordpd', 'cmpunordsd', 'comisd', 'cvtdq2pd', 'cvtdq2ps', 'cvtpd2dq', 'cvtpd2pi', 'cvtpd2ps', 'cvtpi2pd', 'cvtps2dq', 'cvtps2pd', 'cvtsd2si', 'cvtsd2ss', 'cvtsi2sd', 'cvtss2sd', 'cvttpd2dq', 'cvttpd2pi', 'cvttps2dq', 'cvttsd2si', 'divpd', 'divsd', 'maskmovdqu', 'maxpd', 'maxsd', 'minpd', 'minsd', 'movapd', 'movdq2q', 'movdqa', 'movdqu', 'movhpd', 'movlpd', 'movmskpd', 'movntdq', 'movnti', 'movntpd', 'movq2dq', 'movupd', 'mulpd', 'mulsd', 'orpd', 'paddq', 'pmuludq', 'pshufd', 'pshufhw', 'pshuflw', 'pslldq', 'psrldq', 'psubq', 'punpckhqdq', 'punpcklqdq', 'shufpd', 'sqrtpd', 'sqrtsd', 'subpd', 'subsd', 'ucomisd', 'unpckhpd', 'unpcklpd', 'xorpd', 'movd'),851 'SSE3' => array('addsubpd', 'addsubps', 'fisttp', 'haddpd', 'haddps', 'hsubpd', 'hsubps', 'lddqu', 'monitor', 'movddup', 'movshdup', 'movsldup', 'mwait'),852 'SSSE3' => array('pabsb', 'pabsd', 'pabsw', 'palignr', 'phaddd', 'phaddsw', 'phaddw', 'phsubd', 'phsubsw', 'phsubw', 'pmaddubsw', 'pmulhrsw', 'pshufb', 'psignb', 'psignd', 'psignw'),853 'SSE4_1' => array('blendpd', 'blendps', 'blendvpd', 'blendvps', 'dppd', 'dpps', 'extractps', 'insertps', 'movntdqa', 'mpsadbw', 'packusdw', 'pblendvb', 'pblendw', 'pcmpeqq', 'pextrb', 'pextrd', 'pextrq', 'phminposuw', 'pinsrb', 'pinsrd', 'pinsrq', 'pmaxsb', 'pmaxsd', 'pmaxud', 'pmaxuw', 'pminsb', 'pminsd', 'pminud', 'pminuw', 'pmovsxbd', 'pmovsxbq', 'pmovsxbw', 'pmovsxdq', 'pmovsxwd', 'pmovsxwq', 'pmovzxbd', 'pmovzxbq', 'pmovzxbw', 'pmovzxdq', 'pmovzxwd', 'pmovzxwq', 'pmuldq', 'pmulld', 'ptest', 'roundpd', 'roundps', 'roundsd', 'roundss'),854 'SSE4_2' => array('crc32', 'pcmpestri', 'pcmpestrm', 'pcmpgtq', 'pcmpistri', 'pcmpistrm', 'popcnt'),855 'SSE4A' => array('extrq', 'insertq', 'movntsd', 'movntss'),856 'AVX' => 'VBROADCASTSS VBROADCASTSD VBROADCASTF128 VINSERTF128 VEXTRACTF128 VMASKMOVPS VPERMILPS VPERMILPD VPERM2F128 VZEROALL VZEROUPPER',857 'AVX2' => 'VPBROADCASTB VPBROADCASTW VPBROADCASTD VPBROADCASTQ VINSERTI128 VEXTRACTI128 VGATHERDPD VGATHERQPD VGATHERDPS VGATHERQPS VPGATHERDD VPGATHERDQ VPGATHERQD VPGATHERQQ VPMASKMOVD VPMASKMOVQ VPERMPS VPERMD VPERMPD VPERMQ VPERM2I128 VPBLENDD VPSLLVD VPSLLVQ VPSRLVD VPSRLVQ VPSRAVD',858 'AES' => 'AESENC AESENCLAST AESDEC AESDECLAST AESKEYGENASSIST AESIMC',859 'AVX512' => 'AVX512F AVX512CD AVX512DQ AVX512PF AVX512ER AVX512VL AVX512BW AVX512IFMA AVX512VBMI AVX512VBMI2 AVX512VAES AVX512BITALG AVX5124FMAPS AVX512VPCLMULQDQ AVX512GFNI AVX512_VNNI AVX5124VNNIW AVX512VPOPCNTDQ AVX512_BF16 avx512vp2intersect',860 'VAES' => 'VAESDEC VAESDECLAST VAESENC VAESENCLAST VPCLMULQDQ',861 'AVX-VNNI' => 'vpdpbusd vpdpwssd vpdpbusds vpdpwssds',862 'SERIALIZE' => 'serialize',863 'WAITPKG' => 'umwait tpause umonitor',864 'ENQCMD' => 'enqcmd enqcmds',865 'MOVDIRI' => 'movdiri movdir64b',866 'CLWB' => 'clwb',867 'RDPRU' => 'rdpru',868 'FSGSBASE' => 'RDFSBASE RDGSBASE WRFSBASE WRGSBASE',869 'AMX' => 'LDTILECFG STTILECFG TILELOADD TILELOADDT1 TILESTORED TILERELEASE TILEZERO TDPBF16PS',870 'FMA' => array('vfmadd123pd', 'vfmadd123ps', 'vfmadd123sd', 'vfmadd123ss', 'vfmadd132pd', 'vfmadd132ps', 'vfmadd132sd', 'vfmadd132ss', 'vfmadd213pd', 'vfmadd213ps', 'vfmadd213sd', 'vfmadd213ss', 'vfmadd231pd', 'vfmadd231ps', 'vfmadd231sd', 'vfmadd231ss', 'vfmadd312pd', 'vfmadd312ps', 'vfmadd312sd', 'vfmadd312ss', 'vfmadd321pd', 'vfmadd321ps', 'vfmadd321sd', 'vfmadd321ss', 'vfmaddsub123pd', 'vfmaddsub123ps', 'vfmaddsub132pd', 'vfmaddsub132ps', 'vfmaddsub213pd', 'vfmaddsub213ps', 'vfmaddsub231pd', 'vfmaddsub231ps', 'vfmaddsub312pd', 'vfmaddsub312ps', 'vfmaddsub321pd', 'vfmaddsub321ps', 'vfmsub123pd', 'vfmsub123ps', 'vfmsub123sd', 'vfmsub123ss', 'vfmsub132pd', 'vfmsub132ps', 'vfmsub132sd', 'vfmsub132ss', 'vfmsub213pd', 'vfmsub213ps', 'vfmsub213sd', 'vfmsub213ss', 'vfmsub231pd', 'vfmsub231ps', 'vfmsub231sd', 'vfmsub231ss', 'vfmsub312pd', 'vfmsub312ps', 'vfmsub312sd', 'vfmsub312ss', 'vfmsub321pd', 'vfmsub321ps', 'vfmsub321sd', 'vfmsub321ss', 'vfmsubadd123pd', 'vfmsubadd123ps', 'vfmsubadd132pd', 'vfmsubadd132ps', 'vfmsubadd213pd', 'vfmsubadd213ps', 'vfmsubadd231pd', 'vfmsubadd231ps', 'vfmsubadd312pd', 'vfmsubadd312ps', 'vfmsubadd321pd', 'vfmsubadd321ps', 'vfnmadd123pd', 'vfnmadd123ps', 'vfnmadd123sd', 'vfnmadd123ss', 'vfnmadd132pd', 'vfnmadd132ps', 'vfnmadd132sd', 'vfnmadd132ss', 'vfnmadd213pd', 'vfnmadd213ps', 'vfnmadd213sd', 'vfnmadd213ss', 'vfnmadd231pd', 'vfnmadd231ps', 'vfnmadd231sd', 'vfnmadd231ss', 'vfnmadd312pd', 'vfnmadd312ps', 'vfnmadd312sd', 'vfnmadd312ss', 'vfnmadd321pd', 'vfnmadd321ps', 'vfnmadd321sd', 'vfnmadd321ss', 'vfnmsub123pd', 'vfnmsub123ps', 'vfnmsub123sd', 'vfnmsub123ss', 'vfnmsub132pd', 'vfnmsub132ps', 'vfnmsub132sd', 'vfnmsub132ss', 'vfnmsub213pd', 'vfnmsub213ps', 'vfnmsub213sd', 'vfnmsub213ss', 'vfnmsub231pd', 'vfnmsub231ps', 'vfnmsub231sd', 'vfnmsub231ss', 'vfnmsub312pd', 'vfnmsub312ps', 'vfnmsub312sd', 'vfnmsub312ss', 'vfnmsub321pd', 'vfnmsub321ps', 'vfnmsub321sd', 'vfnmsub321ss'),871 'BMI2' => 'BZHI MULX PDEP PEXT RORX SARX SHRX SHLX',872 );873 }874 public static function interesting_instructions_names()875 {876 return array(877 //'MMX' => 'MMX',878 'SSE2' => 'SSE2',879 'SSE3' => 'SSE3',880 'SSSE3' => 'SSSE3',881 'SSE4_2' => 'SSE 4.2',882 'SSE4A' => 'SSE4A',883 'AVX' => 'Advanced Vector Extensions',884 'AVX2' => 'Advanced Vector Extensions 2',885 'AVX512' => 'Advanced Vector Extensions 512',886 'AMX' => 'Advanced Matrix Extensions',887 'AES' => 'Advanced Encryption Standard',888 'VAES' => 'Vector AES',889 'AVX-VNNI' => 'AVX Vector Neural Network Instructions',890 'SERIALIZE' => 'SERIALIZE',891 'WAITPKG' => 'WAITPKG / UMWAIT / TPAUSE',892 'ENQCMD' => 'Data Streaming Accelerator',893 'FSGSBASE' => 'FSGSBASE',894 'MOVDIRI' => 'MOVDIRx',895 'CLWB' => 'Cache Line Write Back',896 'RDPRU' => 'Read Processor Register',897 'FMA' => 'FMA',898 'BMI2' => 'Bit Manipulation Instruction Set 2',899 );900 }901 public static function prominent_cpu_bugs()902 {903 return array(904 'cpu_meltdown' => 'Meltdown',905 'spectre_v1' => 'Spectre V1',906 'spectre_v2' => 'Spectre V2',907 'spec_store_bypass' => 'Spectre V4 / SSBD',908 'l1tf' => 'L1 Terminal Fault / Foreshadow',909 'mds' => 'Microarchitectural Data Sampling',910 'swapgs' => 'SWAPGS',911 'itlb_multihit' => 'iTLB Multihit',912 'taa' => 'TSX Asynchronous Abort',913 );914 }915 public static function get_cpu_family()916 {917 $family = null;918 if(phodevi::is_linux())919 {920 $cpuinfo = phodevi_linux_parser::cpuinfo_to_array();921 $family = isset($cpuinfo['cpu family']) ? $cpuinfo['cpu family'] : $family;922 }923 else if(phodevi::is_windows())924 {925 $processor_identifier = explode(' ', getenv('PROCESSOR_IDENTIFIER'));926 if(($x = array_search('Family', $processor_identifier)) !== false)927 {928 $family = $processor_identifier[($x + 1)];929 }930 }931 else if(phodevi::is_macos())932 {933 $family = phodevi_bsd_parser::read_sysctl(array('machdep.cpu.family'));934 }935 return $family;936 }937 public static function get_cpu_model()938 {939 $model = null;940 if(phodevi::is_linux())941 {942 $cpuinfo = phodevi_linux_parser::cpuinfo_to_array();943 $model = isset($cpuinfo['model']) ? $cpuinfo['model'] : $model;944 }945 else if(phodevi::is_windows())946 {947 $processor_identifier = explode(' ', getenv('PROCESSOR_IDENTIFIER'));948 if(($x = array_search('Model', $processor_identifier)) !== false)949 {950 $model = $processor_identifier[($x + 1)];951 }952 }953 else if(phodevi::is_macos())954 {955 $model = phodevi_bsd_parser::read_sysctl(array('machdep.cpu.model'));956 }957 return $model;958 }959 public static function get_core_name($family = false, $model = false, $cpu_string = null)960 {961 if($family === false && $model === false && PTS_IS_CLIENT)962 {963 $family = phodevi::read_property('cpu', 'cpu-family');964 $model = phodevi::read_property('cpu', 'cpu-model');965 $cpu_string = phodevi::read_property('cpu', 'model');966 }967 // Useful: https://en.wikichip.org/wiki/amd/cpuid / https://en.wikichip.org/wiki/intel/cpuid...

Full Screen

Full Screen

phodevi_memory.php

Source:phodevi_memory.php Github

copy

Full Screen

...33 $mem_speed = false;34 $mem_type = false;35 $mem_manufacturer = false;36 $mem_part = false;37 if(phodevi::is_macos())38 {39 $mem_size = phodevi_osx_parser::read_osx_system_profiler('SPMemoryDataType', 'Size', true, array('Empty'));40 $mem_speed = phodevi_osx_parser::read_osx_system_profiler('SPMemoryDataType', 'Speed');41 $mem_type = phodevi_osx_parser::read_osx_system_profiler('SPMemoryDataType', 'Type');42 }43 else if(phodevi::is_solaris())44 {45 $mem_size = phodevi_solaris_parser::read_sun_ddu_dmi_info('MemoryDevice*,InstalledSize');46 $mem_speed = phodevi_solaris_parser::read_sun_ddu_dmi_info('MemoryDevice*,Speed');47 $mem_type = phodevi_solaris_parser::read_sun_ddu_dmi_info('MemoryDevice*,MemoryDeviceType');48 if(is_array($mem_speed) && count($mem_speed) > 0)49 {50 $mem_speed = array_shift($mem_speed);51 }52 $mem_speed = str_replace('MHZ', 'MHz', $mem_speed);53 }54 else if(phodevi::is_windows())55 {56 $mem_size = phodevi_windows_parser::get_wmi_object_multi('CIM_PhysicalMemory', 'Capacity');57 $clock_speed = phodevi_windows_parser::get_wmi_object_multi('CIM_PhysicalMemory', 'ConfiguredClockSpeed');58 $mem_manufacturer = phodevi_windows_parser::get_wmi_object_multi('CIM_PhysicalMemory', 'Manufacturer');59 $mem_part = phodevi_windows_parser::get_wmi_object_multi('CIM_PhysicalMemory', 'PartNumber');60 if(isset($clock_speed[0]) && is_numeric($clock_speed[0]))61 {62 $clock_speed = array_shift($clock_speed);63 }64 $mem_type = null;65 $mem_speed = is_numeric($clock_speed) ? $clock_speed . 'MHz' : null;66 }67 else if(phodevi::is_linux())68 {69 $mem_size = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Size', false, array('Not Installed', 'No Module Installed', 'Undefined'));70 $mem_speed = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Configured Clock Speed', true, array('Unknown', 'Undefined'));71 if($mem_speed == false)72 {73 // "Speed" only reports stock frequency where "Configured Clock Speed" should report the over/underclocked memory74 $mem_speed = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Speed', true, array('Unknown', 'Undefined'));75 }76 $mem_type = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Type', true, array('Unknown', 'Other', 'Flash', 'Undefined'));77 $mem_manufacturer = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Manufacturer', true, array('Unknown', 'Undefined'));78 $mem_part = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Part Number', true, array('Unknown', 'Undefined'));79 }80 if(is_array($mem_type))81 {82 $mem_type = array_pop($mem_type);83 }84 if(is_array($mem_part))85 {86 $mem_part = array_pop($mem_part);87 }88 if(is_array($mem_manufacturer))89 {90 $mem_manufacturer = array_pop($mem_manufacturer);91 }92 if($mem_size != false && (!is_array($mem_size) || count($mem_size) != 0))93 {94 for($i = 0; $i < count($mem_size); $i++)95 {96 switch(substr($mem_size[$i], -1))97 {98 case 'K':99 // looks like sometimes Solaris now reports flash chip as memory. its string ends with K100 unset($mem_size[$i]);101 unset($mem_speed[$i]);102 unset($mem_type[$i]);103 break;104 case 'M':105 // report megabytes as MB, just not M, as on Solaris106 $mem_size[$i] .= 'B';107 break;108 case 'B':109 if(strtolower(substr($mem_size[$i], -2, 1)) == 'k')110 {111 // some hardware on Linux via dmidecode reports flash chips112 unset($mem_size[$i]);113 //unset($mem_speed[$i]);114 //unset($mem_type[$i]);115 }116 break;117 default:118 if(phodevi::is_windows() && $mem_size[$i] > 1000000)119 {120 $mem_size[$i] = round($mem_size[$i] / 1048576);121 }122 }123 }124 foreach($mem_size as $i => $mem_stick)125 {126 if(!is_numeric(substr($mem_stick, 0, 3)) && stripos($mem_stick, 'GB') == false)127 {128 // If the memory size isn't at least three digits (basically 128MB+), chances are something is wrong, i.e. reporting flash chip from dmidecode, so get rid of it.129 unset($mem_size[$i]);130 }131 }132 $mem_count = count($mem_size);133 if(!empty($mem_type))134 {135 if(($cut = strpos($mem_type, ' ')) > 0)136 {137 $mem_type = substr($mem_type, 0, $cut);138 }139 if(!in_array($mem_type, array('Other')) && (pts_strings::keep_in_string($mem_type, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_LETTER) == $mem_type))140 {141 $mem_prefix = $mem_type;142 }143 }144 else145 {146 $mem_prefix = null;147 }148 if(!empty($mem_speed))149 {150 if(($cut = strpos($mem_speed, ' (')) > 0)151 {152 $mem_speed = substr($mem_speed, 0, $cut);153 }154 if(!empty($mem_prefix))155 {156 $mem_prefix .= '-';157 }158 $mem_prefix .= str_replace(' ', '', $mem_speed);159 }160 // TODO: Allow a combination of both functions below, so like 2 x 2GB + 3 x 1GB DDR2-800161 if($mem_count > 1 && count(array_unique($mem_size)) > 1)162 {163 $mem_string = implode(' + ', $mem_size) . ' ' . $mem_prefix;164 }165 else166 {167 $t = str_replace(array(' MB', ' GB'), '', $mem_size[0]);168 if(($mem_count * $t) != phodevi::read_property('memory', 'capacity') && phodevi::read_property('memory', 'capacity') % $t == 0)169 {170 // This makes sure the correct number of RAM modules is reported...171 // On at least Linux with dmidecode on an AMD Opteron multi-socket setup it's only showing the data for one socket172 if(is_numeric($mem_size[0]))173 {174 if($mem_size[0] < 1024)175 {176 $mem_size[0] *= 1024;177 }178 $mem_count = phodevi::read_property('memory', 'capacity') / $mem_size[0];179 }180 }181 $product_string = null;182 if(isset($mem_manufacturer[2]) && pts_strings::is_alpha($mem_manufacturer[0]) && stripos($mem_manufacturer, 'manufacturer') === false && stripos($mem_manufacturer, 'part') === false && stripos($mem_manufacturer, 'module') === false && stripos($mem_manufacturer, 'dimm') === false && isset($mem_manufacturer[2]) && pts_strings::is_alpha($mem_manufacturer))183 {184 $product_string .= ' ' . $mem_manufacturer;185 }186 if(($x = strpos($mem_part, '/')) !== false)187 {188 // Cleanup/shorten strings like KHX2133C13S4/4G189 $mem_part = substr($mem_part, 0, $x);190 }191 if(isset($mem_part[2]) && stripos($mem_part, 'part') === false && stripos($mem_part, 'module') === false && stripos($mem_part, 'dimm') === false && substr($mem_part, 0, 2) != '0x' && !isset($mem_part[24]) && pts_strings::is_alnum(str_replace(array('-'), '', $mem_part)))192 {193 $product_string .= ' ' . $mem_part;194 }195 if(is_numeric($mem_size[0]) && stripos($mem_size[0], 'b') === false)196 {197 if($mem_size >= 1024)198 {199 $mem_size[0] .= ' MB';200 }201 else202 {203 $mem_size[0] .= ' GB';204 }205 }206 $mem_string = $mem_count . ' x ' . $mem_size[0] . ' ' . $mem_prefix . $product_string;207 }208 }209 if(empty($mem_string))210 {211 $ram_in_mb = phodevi::read_property('memory', 'capacity');212 if($ram_in_mb != null)213 {214 $mem_string = $ram_in_mb . 'MB';215 if($ram_in_mb > 5000)216 {217 $ram_in_gb = ceil($ram_in_mb / 1024);218 if($ram_in_gb % 2 == 1)219 {220 $ram_in_gb++;221 }222 if($ram_in_gb > 100 && $ram_in_gb % 16 !== 0)223 {224 $ram_in_gb += 16 - ($ram_in_gb % 16);225 }226 if($ram_in_gb >= 6)227 {228 $mem_string = $ram_in_gb . 'GB';229 }230 }231 }232 }233 return trim(str_replace(array('Unknown ', 'Undefined'), '', $mem_string));234 }235 public static function memory_capacity()236 {237 // Returns physical memory capacity238 if(isset(phodevi::$vfs->meminfo))239 {240 $info = phodevi::$vfs->meminfo;241 $info = substr($info, strpos($info, 'MemTotal:') + 9);242 $info = intval(trim(substr($info, 0, strpos($info, 'kB'))));243 $info = floor($info / 1024);244 if(is_numeric($info) && $info > 950)245 {246 if($info > 4608)247 {248 $info = ceil($info / 1024) * 1024;249 }250 else if($info > 1536)251 {252 $info = ceil($info / 512) * 512;253 }254 else255 {256 $info = ceil($info / 256) * 256;257 }258 }259 }260 else if(phodevi::is_solaris())261 {262 $info = shell_exec('prtconf 2>&1 | grep Memory');263 $info = substr($info, strpos($info, ':') + 2);264 $info = substr($info, 0, strpos($info, 'Megabytes'));265 }266 else if(phodevi::is_bsd())267 {268 $mem_size = phodevi_bsd_parser::read_sysctl('hw.physmem');269 if($mem_size == false)270 {271 $mem_size = phodevi_bsd_parser::read_sysctl('hw.realmem');272 }273 $info = ceil(floor($mem_size / 1048576) / 256) * 256;274 }275 else if(phodevi::is_macos())276 {277 $info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'Memory');278 $info = explode(' ', $info);279 $info = (isset($info[1]) && $info[1] == 'GB' ? $info[0] * 1024 : $info[0]);280 }281 else if(phodevi::is_windows())282 {283 $info = phodevi_windows_parser::get_wmi_object('win32_operatingsystem', 'TotalVisibleMemorySize');284 if(is_numeric($info))285 {286 $info = ceil($info / 1000);287 }288 else289 {...

Full Screen

Full Screen

is_macos

Using AI Code Generation

copy

Full Screen

1$phodevi = new phodevi();2$phodevi->is_macos();3$phodevi = new phodevi();4$phodevi->is_linux();5$phodevi = new phodevi();6$phodevi->is_windows();7$phodevi = new phodevi();8$phodevi->is_bsd();9$phodevi = new phodevi();10$phodevi->is_solaris();11$phodevi = new phodevi();12$phodevi->is_android();13$phodevi = new phodevi();14$phodevi->is_ios();15$phodevi = new phodevi();16$phodevi->is_windowsnt();17$phodevi = new phodevi();18$phodevi->is_windowsce();19$phodevi = new phodevi();20$phodevi->is_haiku();21$phodevi = new phodevi();22$phodevi->is_freebsd();23$phodevi = new phodevi();24$phodevi->is_openbsd();25$phodevi = new phodevi();26$phodevi->is_netbsd();

Full Screen

Full Screen

is_macos

Using AI Code Generation

copy

Full Screen

1include_once 'phodevi.php';2if(phodevi::is_macos())3{4echo 'this is mac os';5}6{7echo 'this is not mac os';8}9include_once 'phodevi.php';10if(phodevi::is_macos())11{12echo 'this is mac os';13}14{15echo 'this is not mac os';16}17include_once 'phodevi.php';18if(phodevi::is_macos())19{20echo 'this is mac os';21}22{23echo 'this is not mac os';24}25include_once 'phodevi.php';26if(phodevi::is_macos())27{28echo 'this is mac os';29}30{31echo 'this is not mac os';32}33include_once 'phodevi.php';34if(phodevi::is_macos())35{36echo 'this is mac os';37}38{39echo 'this is not mac os';40}41include_once 'phodevi.php';42if(phodevi::is_macos())43{44echo 'this is mac os';45}46{47echo 'this is not mac os';48}49include_once 'phodevi.php';50if(phodevi::is_macos())51{52echo 'this is mac os';53}54{55echo 'this is not mac os';56}57include_once 'phodevi.php';58if(phodevi::is_macos())59{60echo 'this is mac os';61}62{63echo 'this is not mac os';64}65include_once 'phodevi.php';66if(phodevi::is_macos())67{68echo 'this is mac os';69}

Full Screen

Full Screen

is_macos

Using AI Code Generation

copy

Full Screen

1require_once 'phodevi.php';2if(phodevi::is_macos())3{4echo "Mac OS";5}6{7echo "Not Mac OS";8}9require_once 'phodevi.php';10echo phodevi::is_macos();11require_once 'phodevi.php';12echo phodevi::is_macos();13require_once 'phodevi.php';14echo phodevi::is_macos();15require_once 'phodevi.php';16echo phodevi::is_macos();17require_once 'phodevi.php';18echo phodevi::is_macos();19require_once 'phodevi.php';20echo phodevi::is_macos();21require_once 'phodevi.php';22echo phodevi::is_macos();23require_once 'phodevi.php';24echo phodevi::is_macos();25require_once 'phodevi.php';26echo phodevi::is_macos();27require_once 'phodevi.php';28echo phodevi::is_macos();29require_once 'phodevi.php';30echo phodevi::is_macos();31require_once 'phodevi.php';32echo phodevi::is_macos();33require_once 'phodevi.php';34echo phodevi::is_macos();35require_once 'phodevi.php';36echo phodevi::is_macos();37require_once 'phodevi.php';38echo phodevi::is_macos();39require_once 'phodevi.php';40echo phodevi::is_macos();41require_once 'phodevi.php';42echo phodevi::is_macos();

Full Screen

Full Screen

is_macos

Using AI Code Generation

copy

Full Screen

1require_once('phodevi.php');2if(phodevi::is_macos()) {3 echo "This is a macos";4} else {5 echo "This is not a macos";6}7require_once('phodevi.php');8if(phodevi::is_windows()) {9 echo "This is a windows";10} else {11 echo "This is not a windows";12}13require_once('phodevi.php');14if(phodevi::is_linux()) {15 echo "This is a linux";16} else {17 echo "This is not a linux";18}19require_once('phodevi.php');20if(phodevi::is_unix()) {21 echo "This is a unix";22} else {23 echo "This is not a unix";24}25require_once('phodevi.php');26if(phodevi::is_android()) {27 echo "This is a android";28} else {29 echo "This is not a android";30}31require_once('phodevi.php');32if(phodevi::is_ios()) {33 echo "This is a ios";34} else {35 echo "This is not a ios";36}37require_once('phodevi.php');38if(phodevi::is_freebsd()) {39 echo "This is a freebsd";40} else {41 echo "This is not a freebsd";42}

Full Screen

Full Screen

is_macos

Using AI Code Generation

copy

Full Screen

1if(phodevi::is_macos())2{3 echo "This is a mac system";4}5{6 echo "This is not a mac system";7}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful