How to use phodevi class

Best Phoronix-test-suite code snippet using phodevi

phodevi_cpu.php

Source:phodevi_cpu.php Github

copy

Full Screen

...3 Phoronix Test Suite4 URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/5 Copyright (C) 2008 - 2017, Phoronix Media6 Copyright (C) 2008 - 2017, Michael Larabel7 phodevi_cpu.php: The PTS Device Interface object for the CPU / processor8 This program is free software; you can redistribute it and/or modify9 it under the terms of the GNU General Public License as published by10 the Free Software Foundation; either version 3 of the License, or11 (at your option) any later version.12 This program is distributed in the hope that it will be useful,13 but WITHOUT ANY WARRANTY; without even the implied warranty of14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 GNU General Public License for more details.16 You should have received a copy of the GNU General Public License17 along with this program. If not, see <http://www.gnu.org/licenses/>.18*/19class phodevi_cpu extends phodevi_device_interface20{21 // TODO XXX: $cpuinfo is now useless and needs to be replaced by the VFS layer... update OpenBenchmarking.org accordingly22 public static $cpuinfo = false;23 private static $cpu_flags = -1;24 public static function read_property($identifier)25 {26 switch($identifier)27 {28 case 'identifier':29 $property = new phodevi_device_property('cpu_string', phodevi::smart_caching);30 break;31 case 'model':32 $property = new phodevi_device_property('cpu_model', phodevi::smart_caching);33 break;34 case 'mhz-default-frequency':35 $property = new phodevi_device_property('cpu_default_frequency_mhz', phodevi::smart_caching);36 break;37 case 'default-frequency':38 $property = new phodevi_device_property(array('cpu_default_frequency', 0), phodevi::smart_caching);39 break;40 case 'core-count':41 $property = new phodevi_device_property('cpu_core_count', phodevi::std_caching);42 break;43 case 'node-count':44 $property = new phodevi_device_property('cpu_node_count', phodevi::smart_caching);45 break;46 case 'scaling-governor':47 $property = new phodevi_device_property('cpu_scaling_governor', phodevi::std_caching);48 break;49 case 'microcode-version':50 $property = new phodevi_device_property('cpu_microcode_version', phodevi::smart_caching);51 break;52 case 'cache-size':53 $property = new phodevi_device_property('cpu_cache_size', phodevi::smart_caching);54 break;55 case 'cache-size-string':56 $property = new phodevi_device_property('cpu_cache_size_string', phodevi::smart_caching);57 break;58 }59 return $property;60 }61 public static function cpu_string()62 {63 $model = phodevi::read_property('cpu', 'model');64 // Append the processor frequency to string65 if(($freq = phodevi::read_property('cpu', 'default-frequency')) > 0)66 {67 $model = str_replace($freq . 'GHz', null, $model); // we'll replace it if it's already in the string68 $model .= ' @ ' . $freq . 'GHz';69 }70 $core_count = phodevi::read_property('cpu', 'core-count');71 return $model . ' (' . pts_strings::plural_handler($core_count, 'Core') . ')';72 }73 public static function cpu_core_count()74 {75 $info = null;76 if(getenv('PTS_NPROC') && is_numeric(getenv('PTS_NPROC')))77 {78 $info = getenv('PTS_NPROC');79 }80 else if(getenv('NUMBER_OF_PROCESSORS') && is_numeric(getenv('NUMBER_OF_PROCESSORS')))81 {82 // Should be used by Windows they have NUMBER_OF_PROCESSORS set and use this as an easy way to override CPUs exposed83 $info = getenv('NUMBER_OF_PROCESSORS');84 }85 else if(phodevi::is_linux())86 {87 if(is_file('/sys/devices/system/cpu/online'))88 {89 $present = pts_file_io::file_get_contents('/sys/devices/system/cpu/online');90 if(isset($present[2]) && substr($present, 0, 2) == '0-')91 {92 $present = substr($present, 2);93 if(is_numeric($present))94 {95 $info = $present + 1;96 }97 }98 }99 }100 else if(phodevi::is_solaris())101 {102 $info = count(explode(PHP_EOL, trim(shell_exec('psrinfo'))));103 }104 else if(phodevi::is_bsd())105 {106 $info = intval(phodevi_bsd_parser::read_sysctl(array('hw.ncpufound', 'hw.ncpu')));107 }108 else if(phodevi::is_macosx())109 {110 $info = intval(phodevi_bsd_parser::read_sysctl(array('hw.ncpu')));111 if(empty($info))112 {113 $info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'TotalNumberOfCores');114 }115 }116 else if(phodevi::is_windows())117 {118 // Should be hit by the first NUMBER_OF_PROCESSORS env check...119 //$info = getenv('NUMBER_OF_PROCESSORS');120 }121 if($info == null && isset(phodevi::$vfs->cpuinfo))122 {123 $info = self::cpuinfo_core_count();124 }125 return (is_numeric($info) && $info > 0 ? $info : 1);126 }127 public static function cpu_node_count()128 {129 $node_count = 1;130 if(isset(phodevi::$vfs->lscpu) && ($t = strpos(phodevi::$vfs->lscpu, 'NUMA node(s):')))131 {132 $lscpu = substr(phodevi::$vfs->lscpu, $t + strlen('NUMA node(s):') + 1);133 $lscpu = substr($lscpu, 0, strpos($lscpu, PHP_EOL));134 $node_count = trim($lscpu);135 }136 return (is_numeric($node_count) && $node_count > 0 ? $node_count : 1);137 }138 public static function cpu_cache_size()139 {140 $cache_size = 0; // in KB141 if(phodevi::is_linux())142 {143 $cache_size = self::cpuinfo_cache_size();144 }145 else if(phodevi::is_macosx())146 {147 $cache_size = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'L3Cache');148 if(strpos($cache_size, ' MB'))149 {150 $cache_size = substr($cache_size, 0, strpos($cache_size, ' ')) * 1024;151 }152 }153 return $cache_size;154 }155 public static function cpu_default_frequency_mhz()156 {157 return self::cpu_default_frequency() * 1000;158 }159 public static function cpu_scaling_governor()160 {161 $scaling_governor = false;162 if(is_file('/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver'))163 {164 $scaling_governor = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver') . ' ';165 }166 if(is_file('/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'))167 {168 $scaling_governor .= pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor');169 }170 return trim($scaling_governor);171 }172 public static function is_genuine($cpu)173 {174 /*175 Real/Genuine CPUs should have:176 1. Contain more than one word in string177 2. Check vendor (to avoid QEMU, Virtual CPU, etc): Intel, VIA, AMD, ARM, SPARC178 */179 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;180 }181 public static function cpu_microcode_version()182 {183 $ucode_version = null;184 if(is_readable('/sys/devices/system/cpu/cpu0/microcode/version'))185 {186 $ucode_version = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu0/microcode/version');187 }188 if(empty($ucode_version) && isset(phodevi::$vfs->cpuinfo))189 {190 $ucode_version = self::read_cpuinfo_line('microcode');191 }192 return $ucode_version;193 }194 public static function cpu_default_frequency($cpu_core = 0)195 {196 // Find out the processor frequency197 $info = null;198 // First, the ideal way, with modern CPUs using CnQ or EIST and cpuinfo reporting the current199 if(is_file('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_max_freq'))200 {201 $info = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_max_freq');202 $info = intval($info) / 1000000;203 if($info > 9)204 {205 // For some reason on Linux 3.10 the scaling_max_freq is reported as 25GHz...206 $info = null;207 }208 }209 if($info == null && isset(phodevi::$vfs->cpuinfo)) // fall back for those without cpufreq210 {211 $cpu_mhz = self::read_cpuinfo_line('cpu MHz');212 $info = $cpu_mhz / 1000;213 if(empty($info))214 {215 $cpu_mhz = self::read_cpuinfo_line('clock');216 $info = $cpu_mhz / 1000;217 }218 }219 else if($info == null && phodevi::is_bsd())220 {221 $info = phodevi_bsd_parser::read_sysctl(array('dev.cpu.0.freq_levels'));222 if($info != null)223 {224 // Popping the top speed off of dev.cpu.0.freq_levels should be the default/highest supported frequency225 $info = pts_arrays::first_element(explode(' ', str_replace('/', ' ', $info)));226 if(!is_numeric($info))227 {228 $info = null;229 }230 }231 if($info == null)232 {233 $info = phodevi_bsd_parser::read_sysctl(array('hw.acpi.cpu.px_global', 'machdep.est.frequency.target', 'hw.cpuspeed'));234 }235 if($info == null)236 {237 // dev.cpu.0.freq seems to be the real/current frequency, affected by power management, etc so only use as last fallback238 $info = phodevi_bsd_parser::read_sysctl(array('dev.cpu.0.freq'));239 }240 if(is_numeric($info))241 {242 $info = $info / 1000;243 }244 else245 {246 $info = null;247 }248 }249 else if($info == null && phodevi::is_windows())250 {251 $info = phodevi_windows_parser::read_cpuz('Processor 1', 'Stock frequency');252 if($info != null)253 {254 if(($e = strpos($info, ' MHz')) !== false)255 {256 $info = substr($info, 0, $e);257 }258 $info = $info / 1000;259 }260 }261 else if($info == null)262 {263 $freq_sensor = new cpu_freq(0, NULL);264 $info = phodevi::read_sensor($freq_sensor);265 unset($freq_sensor);266 if($info > 1000)267 {268 // Convert from MHz to GHz269 $info = $info / 1000;270 }271 }272 return pts_math::set_precision($info, 2);273 }274 public static function cpu_model()275 {276 // Returns the processor name / frequency information277 $info = null;278 if(isset(phodevi::$vfs->cpuinfo))279 {280 $physical_cpu_ids = phodevi_linux_parser::read_cpuinfo('physical id');281 $physical_cpu_count = count(array_unique($physical_cpu_ids));282 $cpu_strings = phodevi_linux_parser::read_cpuinfo(array('model name', 'Processor', 'cpu', 'cpu model'));283 $cpu_strings_unique = array_unique($cpu_strings);284 if($physical_cpu_count == 1 || empty($physical_cpu_count))285 {286 // Just one processor287 if(isset($cpu_strings[0]) && ($cut = strpos($cpu_strings[0], ' (')) !== false)288 {289 $cpu_strings[0] = substr($cpu_strings[0], 0, $cut);290 }291 $info = isset($cpu_strings[0]) ? $cpu_strings[0] : null;292 if(strpos($info, 'ARM') !== false)293 {294 if(is_dir('/sys/devices/system/exynos-core/') && stripos($info, 'Exynos') === false)295 {296 $info = 'Exynos ' . $info;297 }298 }299 }300 else if($physical_cpu_count > 1 && count($cpu_strings_unique) == 1)301 {302 // Multiple processors, same model303 $info = $physical_cpu_count . ' x ' . $cpu_strings[0];304 }305 else if($physical_cpu_count > 1 && count($cpu_strings_unique) > 1)306 {307 // Multiple processors, different models308 $current_id = -1;309 $current_string = $cpu_strings[0];310 $current_count = 0;311 $cpus = array();312 for($i = 0; $i < count($physical_cpu_ids); $i++)313 {314 if($current_string != $cpu_strings[$i] || $i == (count($physical_cpu_ids) - 1))315 {316 array_push($cpus, $current_count . ' x ' . $current_string);317 $current_string = $cpu_strings[$i];318 $current_count = 0;319 }320 if($physical_cpu_ids[$i] != $current_id)321 {322 $current_count++;323 $current_id = $physical_cpu_ids[$i];324 }325 }326 $info = implode(', ', $cpus);327 }328 }329 else if(phodevi::is_solaris())330 {331 $dmi_cpu = phodevi_solaris_parser::read_sun_ddu_dmi_info('CPUType', '-C');332 if(count($dmi_cpu) == 0)333 {334 $dmi_cpu = phodevi_solaris_parser::read_sun_ddu_dmi_info('ProcessorName');335 }336 if(count($dmi_cpu) > 0)337 {338 $info = $dmi_cpu[0];339 }340 else341 {342 $info = trim(shell_exec('dmesg 2>&1 | grep cpu0'));343 $info = trim(substr($info, strrpos($info, 'cpu0:') + 6));344 if(empty($info))345 {346 $info = array_pop(phodevi_solaris_parser::read_sun_ddu_dmi_info('ProcessorManufacturer'));347 }348 }349 //TODO: Add in proper support for reading multiple CPUs, similar to the code from above350 $physical_cpu_count = count(phodevi_solaris_parser::read_sun_ddu_dmi_info('ProcessorSocketType'));351 if($physical_cpu_count > 1 && !empty($info))352 {353 // TODO: For now assuming when multiple CPUs are installed, that they are of the same type354 $info = $physical_cpu_count . ' x ' . $info;355 }356 }357 else if(phodevi::is_bsd())358 {359 $info = phodevi_bsd_parser::read_sysctl('hw.model');360 }361 else if(phodevi::is_macosx())362 {363 $info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'ProcessorName');364 }365 else if(phodevi::is_windows())366 {367 $info = phodevi_windows_parser::read_cpuz('Processor 1', 'Name');368 if(!$info)369 {370 $info = getenv('PROCESSOR_IDENTIFIER');371 }372 }373 if(empty($info))374 {375 $info = 'Unknown';376 }377 else378 {379 if(($strip_point = strpos($info, '@')) > 0)380 {381 $info = trim(substr($info, 0, $strip_point)); // stripping out the reported freq, since the CPU could be overclocked, etc382 }383 $info = pts_strings::strip_string($info);384 // It seems Intel doesn't report its name when reporting Pentium hardware385 if(strpos($info, 'Pentium') !== false && strpos($info, 'Intel') === false)386 {387 $info = 'Intel ' . $info;388 }389 if(substr($info, 0, 5) == 'Intel')390 {391 $cpu_words = explode(' ', $info);392 $cpu_words_count = count($cpu_words);393 // 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 names394 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)395 {396 $cpu_words[($cpu_words_count - 1)] .= $cpu_words[($cpu_words_count - 2)];397 unset($cpu_words[($cpu_words_count - 2)]);398 $info = implode(' ', $cpu_words);399 }400 }401 }402 return $info;403 }404 public static function get_cpu_feature_constants()405 {406 return array(407 'sse2' => (1 << 1), // SSE 2408 'sse3' => (1 << 2), // SSE 3409 'sse4a' => (1 << 3), // SSE 4a410 'sse4_1' => (1 << 4), // SSE 4.1411 'sse4_2' => (1 << 5), // SSE 4.2412 'sse5' => (1 << 6), // SSE 5413 'avx' => (1 << 7), // AVX414 'avx2' => (1 << 8), // AVX2415 'aes' => (1 << 9), // AES416 'epb' => (1 << 10), // EPB417 'svm' => (1 << 11), // AMD SVM (Virtualization)418 'vmx' => (1 << 12), // Intel Virtualization419 'xop' => (1 << 13), // AMD XOP Instruction Set420 'fma3' => (1 << 14), // FMA3 Instruction Set421 'fma4' => (1 << 15), // FMA4 Instruction Set422 'rdrand' => (1 << 16), // Intel Bull Mountain RDRAND - Ivy Bridge423 'fsgsbase' => (1 << 17), // FSGSBASE - Ivy Bridge AVX424 'bmi2' => (1 << 18) // Intel Haswell has BMI2425 );426 }427 public static function get_cpu_feature_constant($constant)428 {429 $features = self::get_cpu_feature_constants();430 return isset($features[$constant]) ? $features[$constant] : -1;431 }432 public static function read_cpuinfo_line($key, $from_start = true)433 {434 $line = false;435 $key .= "\t";436 if(isset(phodevi::$vfs->cpuinfo) && ($from_start && ($key_pos = strpos(phodevi::$vfs->cpuinfo, PHP_EOL . $key)) !== false) || ($key_pos = strrpos(phodevi::$vfs->cpuinfo, PHP_EOL . $key)) !== false)437 {438 $line = substr(phodevi::$vfs->cpuinfo, $key_pos);439 $line = substr($line, strpos($line, ':') + 1);440 $line = trim(substr($line, 0, strpos($line, PHP_EOL)));441 }442 return $line;443 }444 public static function set_cpu_feature_flags()445 {446 $flags = explode(' ', self::read_cpuinfo_line('flags'));447 self::$cpu_flags = 0;448 foreach(self::get_cpu_feature_constants() as $feature => $value)449 {450 if(in_array($feature, $flags))451 {452 // The feature is supported on the CPU453 self::$cpu_flags |= $value;454 }455 }456 }457 public static function get_cpu_flags()458 {459 if(self::$cpu_flags === -1)460 {461 self::set_cpu_feature_flags();462 }463 return self::$cpu_flags;464 }465 public static function instruction_set_extensions()466 {467 $constants = self::get_cpu_feature_constants();468 self::set_cpu_feature_flags();469 $cpu_flags = self::get_cpu_flags();470 $extension_string = null;471 foreach($constants as $feature => $value)472 {473 // find maximum SSE version474 if(substr($feature, 0, 3) == 'sse' && ($cpu_flags & $value))475 {476 $extension_string = 'SSE ' . str_replace('_', '.', substr($feature, 3));477 }478 }479 // Check for other instruction sets480 foreach(array('avx2', 'avx', 'xop', 'fma3', 'fma4', 'rdrand', 'fsgsbase') as $instruction_set)481 {482 if(($cpu_flags & self::get_cpu_feature_constant($instruction_set)))483 {484 $extension_string .= ($extension_string != null ? ' + ' : null) . strtoupper($instruction_set);485 }486 }487 return $extension_string;488 }489 public static function virtualization_technology()490 {491 $constants = self::get_cpu_feature_constants();492 $cpu_flags = self::get_cpu_flags();493 $virtualitzation_technology = false;494 if(($cpu_flags & self::get_cpu_feature_constant('vmx')))495 {496 $virtualitzation_technology = 'VT-x';497 }498 else if(($cpu_flags & self::get_cpu_feature_constant('svm')))499 {500 $virtualitzation_technology = 'AMD-V';501 }502 return $virtualitzation_technology;503 }504 public static function lscpu_l2_cache()505 {506 $l2_cache = false;507 if(isset(phodevi::$vfs->lscpu) && ($t = strpos(phodevi::$vfs->lscpu, 'L2 cache:')))508 {509 $lscpu = substr(phodevi::$vfs->lscpu, $t + strlen('L2 cache:') + 1);510 $lscpu = substr($lscpu, 0, strpos($lscpu, PHP_EOL));511 $l2_cache = trim($lscpu);512 }513 return $l2_cache;514 }515 public static function cpuinfo_core_count()516 {517 $core_count = self::read_cpuinfo_line('cpu cores');518 if($core_count == false || !is_numeric($core_count))519 {520 $core_count = self::read_cpuinfo_line('core id', false);521 if(is_numeric($core_count))522 {523 // cpuinfo 'core id' begins counting at 0524 $core_count += 1;525 }526 }527 if($core_count == false || !is_numeric($core_count))528 {529 $core_count = self::cpuinfo_thread_count();530 }531 return $core_count;532 }533 public static function cpuinfo_thread_count()534 {535 $thread_count = self::read_cpuinfo_line('processor', false);536 if(is_numeric($thread_count))537 {538 // cpuinfo 'processor' begins counting at 0539 $thread_count += 1;540 }541 return $thread_count;542 }543 public static function cpuinfo_cache_size()544 {545 // CPU cache size in KB546 $cache_size = self::read_cpuinfo_line('cache size');547 if(substr($cache_size, -3) == ' KB')548 {549 $cache_size = substr($cache_size, 0, -3);550 }551 else552 {553 $cache_size = null;554 }555 return $cache_size;556 }557 public static function cpu_cache_size_string()558 {559 $cache_size = phodevi::read_property('cpu', 'cache-size');560 if($cache_size > 1)561 {562 $cache_size .= ' KB';563 }564 return $cache_size;565 }566}567?>...

Full Screen

Full Screen

phodevi_memory.php

Source:phodevi_memory.php Github

copy

Full Screen

...3 Phoronix Test Suite4 URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/5 Copyright (C) 2008 - 2016, Phoronix Media6 Copyright (C) 2008 - 2016, Michael Larabel7 phodevi_memory.php: The PTS Device Interface object for system memory8 This program is free software; you can redistribute it and/or modify9 it under the terms of the GNU General Public License as published by10 the Free Software Foundation; either version 3 of the License, or11 (at your option) any later version.12 This program is distributed in the hope that it will be useful,13 but WITHOUT ANY WARRANTY; without even the implied warranty of14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 GNU General Public License for more details.16 You should have received a copy of the GNU General Public License17 along with this program. If not, see <http://www.gnu.org/licenses/>.18*/19class phodevi_memory extends phodevi_device_interface20{21 public static function read_property($identifier)22 {23 switch($identifier)24 {25 case 'identifier':26 $property = new phodevi_device_property('memory_string', phodevi::smart_caching);27 break;28 case 'capacity':29 $property = new phodevi_device_property('memory_capacity', phodevi::smart_caching);30 break;31 }32 return $property;33 }34 public static function memory_string()35 {36 $mem_string = null;37 $mem_prefix = null;38 $mem_size = false;39 $mem_speed = false;40 $mem_type = false;41 $mem_manufacturer = false;42 $mem_part = false;43 if(phodevi::is_macosx())44 {45 $mem_size = phodevi_osx_parser::read_osx_system_profiler('SPMemoryDataType', 'Size', true, array('Empty'));46 $mem_speed = phodevi_osx_parser::read_osx_system_profiler('SPMemoryDataType', 'Speed');47 $mem_type = phodevi_osx_parser::read_osx_system_profiler('SPMemoryDataType', 'Type');48 }49 else if(phodevi::is_solaris())50 {51 $mem_size = phodevi_solaris_parser::read_sun_ddu_dmi_info('MemoryDevice*,InstalledSize');52 $mem_speed = phodevi_solaris_parser::read_sun_ddu_dmi_info('MemoryDevice*,Speed');53 $mem_type = phodevi_solaris_parser::read_sun_ddu_dmi_info('MemoryDevice*,MemoryDeviceType');54 if(is_array($mem_speed) && count($mem_speed) > 0)55 {56 $mem_speed = array_shift($mem_speed);57 }58 $mem_speed = str_replace('MHZ', 'MHz', $mem_speed);59 }60 else if(phodevi::is_windows())61 {62 $mem_size = phodevi_windows_parser::read_cpuz('DIMM #', 'Size', true);63 foreach($mem_size as $key => &$individual_size)64 {65 $individual_size = pts_arrays::first_element(explode(' ', $individual_size));66 if(!is_numeric($individual_size))67 {68 unset($mem_size[$key]);69 } 70 }71 $mem_type = phodevi_windows_parser::read_cpuz('Memory Type', null);72 $mem_speed = intval(phodevi_windows_parser::read_cpuz('Memory Frequency', null)) . 'MHz';73 }74 else if(phodevi::is_linux())75 {76 $mem_size = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Size', false, array('Not Installed', 'No Module Installed', 'Undefined'));77 $mem_speed = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Configured Clock Speed', true, array('Unknown', 'Undefined'));78 if($mem_speed == false)79 {80 // "Speed" only reports stock frequency where "Configured Clock Speed" should report the over/underclocked memory81 $mem_speed = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Speed', true, array('Unknown', 'Undefined'));82 }83 $mem_type = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Type', true, array('Unknown', 'Other', 'Flash', 'Undefined'));84 $mem_manufacturer = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Manufacturer', true, array('Unknown', 'Undefined'));85 $mem_part = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Part Number', true, array('Unknown', 'Undefined'));86 }87 if(is_array($mem_type))88 {89 $mem_type = array_pop($mem_type);90 }91 if($mem_size != false && (!is_array($mem_size) || count($mem_size) != 0))92 {93 for($i = 0; $i < count($mem_size); $i++)94 {95 switch(substr($mem_size[$i], -1))96 {97 case 'K':98 // looks like sometimes Solaris now reports flash chip as memory. its string ends with K99 unset($mem_size[$i]);100 unset($mem_speed[$i]);101 unset($mem_type[$i]);102 break;103 case 'M':104 // report megabytes as MB, just not M, as on Solaris105 $mem_size[$i] .= 'B';106 break;107 case 'B':108 if(strtolower(substr($mem_size[$i], -2, 1)) == 'k')109 {110 // some hardware on Linux via dmidecode reports flash chips111 unset($mem_size[$i]);112 //unset($mem_speed[$i]);113 //unset($mem_type[$i]);114 }115 break;116 }117 }118 foreach($mem_size as $i => $mem_stick)119 {120 if(!is_numeric(substr($mem_stick, 0, 3)) && stripos($mem_stick, 'GB') == false)121 {122 // 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.123 unset($mem_size[$i]);124 }125 }126 $mem_count = count($mem_size);127 if(!empty($mem_type))128 {129 if(($cut = strpos($mem_type, ' ')) > 0)130 {131 $mem_type = substr($mem_type, 0, $cut);132 }133 if(!in_array($mem_type, array('Other')) && (pts_strings::keep_in_string($mem_type, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_LETTER) == $mem_type || phodevi::is_windows()))134 {135 $mem_prefix = $mem_type;136 }137 }138 else139 {140 $mem_prefix = null;141 }142 if(!empty($mem_speed))143 {144 if(($cut = strpos($mem_speed, ' (')) > 0)145 {146 $mem_speed = substr($mem_speed, 0, $cut);147 }148 if(!empty($mem_prefix))149 {150 $mem_prefix .= '-';151 }152 $mem_prefix .= str_replace(' ', null, $mem_speed);153 }154 // TODO: Allow a combination of both functions below, so like 2 x 2GB + 3 x 1GB DDR2-800155 if($mem_count > 1 && count(array_unique($mem_size)) > 1)156 {157 $mem_string = implode(' + ', $mem_size) . ' ' . $mem_prefix;158 }159 else160 {161 if(($mem_count * $mem_size[0]) != phodevi::read_property('memory', 'capacity') && phodevi::read_property('memory', 'capacity') % $mem_size[0] == 0)162 {163 // This makes sure the correct number of RAM modules is reported...164 // On at least Linux with dmidecode on an AMD Opteron multi-socket setup it's only showing the data for one socket165 if($mem_size[0] < 1024)166 {167 $mem_size[0] *= 1024;168 }169 $mem_count = phodevi::read_property('memory', 'capacity') / $mem_size[0];170 }171 $product_string = null;172 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))173 {174 $product_string .= ' ' . $mem_manufacturer;175 }176 if(($x = strpos($mem_part, '/')) !== false)177 {178 // Cleanup/shorten strings like KHX2133C13S4/4G179 $mem_part = substr($mem_part, 0, $x);180 }181 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($mem_part))182 {183 $product_string .= ' ' . $mem_part;184 }185 if(is_numeric($mem_size[0]) && stripos($mem_size[0], 'b') === false)186 {187 if($mem_size >= 1024)188 {189 $mem_size[0] .= ' MB';190 }191 else192 {193 $mem_size[0] .= ' GB';194 }195 }196 $mem_string = $mem_count . ' x ' . $mem_size[0] . ' ' . $mem_prefix . $product_string;197 }198 }199 if(empty($mem_string))200 {201 $mem_string = phodevi::read_property('memory', 'capacity');202 if($mem_string != null)203 {204 $mem_string .= 'MB';205 }206 }207 return trim($mem_string);208 }209 public static function memory_capacity()210 {211 // Returns physical memory capacity212 if(isset(phodevi::$vfs->meminfo))213 {214 $info = phodevi::$vfs->meminfo;215 $info = substr($info, strpos($info, 'MemTotal:') + 9);216 $info = intval(trim(substr($info, 0, strpos($info, 'kB'))));217 $info = floor($info / 1024);218 if(is_numeric($info) && $info > 950)219 {220 if($info > 4608)221 {222 $info = ceil($info / 1024) * 1024;223 }224 else if($info > 1536)225 {226 $info = ceil($info / 512) * 512;227 }228 else229 {230 $info = ceil($info / 256) * 256;231 }232 }233 }234 else if(phodevi::is_solaris())235 {236 $info = shell_exec('prtconf 2>&1 | grep Memory');237 $info = substr($info, strpos($info, ':') + 2);238 $info = substr($info, 0, strpos($info, 'Megabytes'));239 }240 else if(phodevi::is_bsd())241 {242 $mem_size = phodevi_bsd_parser::read_sysctl('hw.physmem');243 if($mem_size == false)244 {245 $mem_size = phodevi_bsd_parser::read_sysctl('hw.realmem');246 }247 $info = ceil(floor($mem_size / 1048576) / 256) * 256;248 }249 else if(phodevi::is_macosx())250 {251 $info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'Memory');252 $info = explode(' ', $info);253 $info = (isset($info[1]) && $info[1] == 'GB' ? $info[0] * 1024 : $info[0]);254 }255 else if(phodevi::is_windows())256 {257 $info = phodevi_windows_parser::read_cpuz('Memory Size', null);258 if($info != null)259 {260 if(($e = strpos($info, ' MBytes')) !== false)261 {262 $info = substr($info, 0, $e);263 }264 $info = trim($info);265 }266 }267 else268 {269 $info = null;270 }271 return $info;...

Full Screen

Full Screen

pts_webui_component.php

Source:pts_webui_component.php Github

copy

Full Screen

...34 $COMPONENT = trim(str_replace('%20', ' ', $PATH[0]));35 switch($COMPONENT)36 {37 case 'CPU':38 $model = phodevi::read_property('cpu', 'model');39 $ob_type = 'Processor';40 $sensor_flag = 'all.cpu';41 $cpu_flags = phodevi_cpu::get_cpu_flags();42 $features = array(array('Frequency', phodevi::read_property('cpu', 'mhz-default-frequency') . ' MHz'),43 array('Core Count', phodevi_cpu::cpuinfo_core_count()),44 array('Thread Count', phodevi_cpu::cpuinfo_thread_count()),45 array('Cache Size', phodevi_cpu::cpuinfo_cache_size() . ' KB'),46 array('Instruction Set Extensions', phodevi_cpu::instruction_set_extensions()),47 array('AES Encryption', ($cpu_flags & phodevi_cpu::get_cpu_feature_constant('aes') ? 'YES' : 'NO')),48 array('Energy Performance Bias', ($cpu_flags & phodevi_cpu::get_cpu_feature_constant('epb') ? 'YES' : 'NO')),49 array('Virtualization', (phodevi_cpu::virtualization_technology() ? phodevi_cpu::virtualization_technology() : 'NO')),50 array('Scaling Governor', phodevi::read_property('cpu', 'scaling-governor'))51 );52 $software_features = array();53 break;54 case 'GPU':55 $model = phodevi::read_property('gpu', 'model');56 $ob_type = 'Graphics';57 $sensor_flag = 'all.gpu';58 $features = array(array('Frequency', implode(' / ', phodevi::read_property('gpu', 'stock-frequency')) . ' MHz'),59 array('vRAM Capacity', phodevi::read_property('gpu', 'memory-capacity') . ' MB'),60 array('Compute Cores', phodevi::read_property('gpu', 'compute-cores')),61 array('Screen Resolution', phodevi::read_property('gpu', 'screen-resolution-string')),62 array('2D Acceleration', phodevi::read_property('gpu', '2d-acceleration'))63 );64 $software_features = array(65 array('Video Driver', phodevi::read_property('system', 'display-driver-string')),66 array('OpenGL Driver', phodevi::read_property('system', 'opengl-driver')),67 array('Kernel', phodevi::read_property('system', 'kernel')),68 array('Video Drivers', phodevi::read_property('system', 'display-driver-string')),69 array('Display Server', phodevi::read_property('system', 'display-server'))70 );71 break;72 case 'Motherboard':73 $model = phodevi::read_property('motherboard', 'identifier');74 $ob_type = 'System';75 $sensor_flag = 'all.sys';76 $features = array(array('Chipset', phodevi::read_property('chipset', 'identifier')),77 array('Serial Number', phodevi::read_property('motherboard', 'serial-number')),78 array('Network', phodevi::read_property('network', 'identifier')),79 array('Audio', phodevi::read_property('audio', 'identifier'))80 );81 $software_features = array();82 break;83 case 'Disk':84 $model = phodevi::read_property('disk', 'identifier');85 $ob_type = 'Disk';86 $sensor_flag = 'all.hdd';87 $mo = phodevi::read_property('disk', 'mount-options');88 $mo = isset($mo['mount-options']) ? $mo['mount-options'] : null;89 $features = array(array('I/O Scheduler', phodevi::read_property('disk', 'scheduler')),90 array('Mount Options', $mo),91 array('File-System', phodevi::read_property('system', 'filesystem'))92 );93 $software_features = array();94 break;95 case 'Memory':96 $model = phodevi::read_property('memory', 'identifier');97 $ob_type = 'Memory';98 $sensor_flag = 'all.memory';99 $features = array();100 $software_features = array();101 break;102 case 'Software':103 $model = phodevi::read_property('system', 'operating-system');104 $ob_type = '';105 $sensor_flag = 'all.sys';106 $features = array(array('Kernel', phodevi::read_property('system', 'kernel-string')),107 array('Compiler', phodevi::read_property('system', 'compiler')),108 array('Desktop', phodevi::read_property('system', 'desktop-environment')),109 array('Display Server', phodevi::read_property('system', 'display-server')),110 array('Display Driver', phodevi::read_property('system', 'display-driver-string')),111 array('OpenGL Driver', phodevi::read_property('system', 'opengl-driver')),112 array('File-System', phodevi::read_property('system', 'filesystem')),113 array('System Layer', phodevi::read_property('system', 'system-layer')),114 );115 $software_features = array(array('Kernel Parameters', phodevi::read_property('system', 'kernel-parameters')),116 array('Hostname', phodevi::read_property('system', 'hostname')),117 array('Local IP Address', $_SERVER['HTTP_HOST'])118 );119 break;120 }121 echo '<h1>' . $model . '</h1>';122 echo '<div id="pts_side_pane" style="max-width: 30%;">';123 if(!empty($features))124 {125 echo '<h2>' . $COMPONENT . ' Features</h2>';126 echo '<ul>';127 foreach($features as $feature)128 {129 if(isset($feature[1]))130 {...

Full Screen

Full Screen

phodevi

Using AI Code Generation

copy

Full Screen

1require_once('/usr/share/phoronix-test-suite/pts-core/objects/phodevi.php');2require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_output.php');3require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_test_profile.php');4require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_analyzer.php');5require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_parser.php');6require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_analyzer.php');7require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_analyzer.php');8require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_analyzer.php');9require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_analyzer.php');10require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_analyzer.php');11require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_analyzer.php');12require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_analyzer.php');13require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_analyzer.php');

Full Screen

Full Screen

phodevi

Using AI Code Generation

copy

Full Screen

1require_once(__DIR__ . '/../../pts-core/pts-core.php');2$phodevi = new phodevi();3$cpu_model = $phodevi->read_property('cpu', 'model');4$cpu_arch = $phodevi->read_property('cpu', 'architecture');5$cpu_freq = $phodevi->read_property('cpu', 'frequency');6$cpu_cores = $phodevi->read_property('cpu', 'core-count');7$cpu_threads = $phodevi->read_property('cpu', 'thread-count');8$cpu_cache = $phodevi->read_property('cpu', 'cache');9$cpu_voltage = $phodevi->read_property('cpu', 'voltage');10$cpu_temp = $phodevi->read_property('cpu', 'temperature');11$cpu_load = $phodevi->read_property('cpu', 'load');12$cpu_freq_max = $phodevi->read_property('cpu', 'frequency-max');13$cpu_freq_min = $phodevi->read_property('cpu', 'frequency-min');14$cpu_freq_gov = $phodevi->read_property('cpu', 'frequency-governor');15$cpu_freq_scaling = $phodevi->read_property('cpu', 'frequency-scaling');16$cpu_freq_scaling_available = $phodevi->read_property('cpu', 'frequency-scaling-available');17$cpu_freq_scaling_available = $phodevi->read_property('cpu', 'frequency-scaling-available');18$cpu_scaling_driver = $phodevi->read_property('cpu', 'scaling-driver');19$cpu_scaling_driver_available = $phodevi->read_property('cpu', 'scaling-driver-available');20$cpu_max_performance = $phodevi->read_property('cpu', 'max-performance');

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