diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-11-17 14:38:52 -0500 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-11-17 14:38:52 -0500 |
commit | 5fc0dfda5f28d34d276af5659618f6248a401277 (patch) | |
tree | 0aa9660460f93497f97ce8cc7356eca68541bb2d | |
parent | a3e4b31b492c593cbf063e3d6ba2ebe63b3bdb5b (diff) | |
download | phoronix-test-suite-upstream-5fc0dfda5f28d34d276af5659618f6248a401277.tar.gz phoronix-test-suite-upstream-5fc0dfda5f28d34d276af5659618f6248a401277.tar.xz phoronix-test-suite-upstream-5fc0dfda5f28d34d276af5659618f6248a401277.zip |
pts-core: Standardize CPU function names
-rw-r--r-- | pts-core/functions/pts-functions-run.php | 6 | ||||
-rw-r--r-- | pts-core/functions/pts-functions.php | 6 | ||||
-rw-r--r-- | pts-core/functions/pts-functions_system.php | 4 | ||||
-rw-r--r-- | pts-core/functions/pts-functions_system_cpu.php | 70 | ||||
-rw-r--r-- | pts-core/functions/pts-functions_system_software.php | 2 | ||||
-rw-r--r-- | pts-core/modules/system_monitor.php | 8 |
6 files changed, 47 insertions, 49 deletions
diff --git a/pts-core/functions/pts-functions-run.php b/pts-core/functions/pts-functions-run.php index dcf360b..d64e0d2 100644 --- a/pts-core/functions/pts-functions-run.php +++ b/pts-core/functions/pts-functions-run.php @@ -225,7 +225,7 @@ function pts_generate_test_notes($test_type) } // Power Saving Technologies? - pts_add_test_note(pts_processor_power_savings_enabled()); + pts_add_test_note(hw_cpu_power_savings_enabled()); pts_add_test_note(system_power_mode()); pts_add_test_note(system_virtualized_mode()); @@ -665,7 +665,7 @@ function pts_global_auto_tags($extra_attr = null) } } - switch(cpu_core_count()) + switch(hw_cpu_core_count()) { case 1: array_push($tags_array, "Single Core"); @@ -681,7 +681,7 @@ function pts_global_auto_tags($extra_attr = null) break; } - $cpu_type = processor_string(); + $cpu_type = hw_cpu_string(); if(strpos($cpu_type, "Intel") !== false) { array_push($tags_array, "Intel"); diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php index 2a5eeb2..991307c 100644 --- a/pts-core/functions/pts-functions.php +++ b/pts-core/functions/pts-functions.php @@ -172,8 +172,8 @@ function pts_env_variables() "PTS_DIR" => PTS_DIR, "FONT_DIR" => FONT_DIR, "PHP_BIN" => PHP_BIN, - "NUM_CPU_CORES" => cpu_core_count(), - "NUM_CPU_JOBS" => cpu_job_count(), + "NUM_CPU_CORES" => hw_cpu_core_count(), + "NUM_CPU_JOBS" => hw_cpu_job_count(), "SYS_MEMORY" => memory_mb_capacity(), "VIDEO_MEMORY" => graphics_memory_capacity(), "VIDEO_WIDTH" => current_screen_width(), @@ -202,7 +202,7 @@ function pts_user_runtime_variables() "VIDEO_CARD" => graphics_processor_string(), "VIDEO_DRIVER" => opengl_version(), "OPERATING_SYSTEM" => operating_system_release(), - "PROCESSOR" => processor_string(), + "PROCESSOR" => hw_cpu_string(), "MOTHERBOARD" => main_system_hardware_string(), "CHIPSET" => motherboard_chipset_string(), "KERNEL_VERSION" => kernel_string(), diff --git a/pts-core/functions/pts-functions_system.php b/pts-core/functions/pts-functions_system.php index 4249e48..5396450 100644 --- a/pts-core/functions/pts-functions_system.php +++ b/pts-core/functions/pts-functions_system.php @@ -32,7 +32,7 @@ function pts_hw_string() // Returns string of hardware information $hardware = array(); - array_push($hardware, "Processor: " . processor_string() . " (Total Cores: " . cpu_core_count() . ")"); + array_push($hardware, "Processor: " . hw_cpu_string() . " (Total Cores: " . hw_cpu_core_count() . ")"); array_push($hardware, "Motherboard: " . main_system_hardware_string()); array_push($hardware, "Chipset: " . motherboard_chipset_string()); array_push($hardware, "System Memory: " . system_memory_string()); @@ -64,7 +64,7 @@ function pts_sw_string() } function pts_system_identifier_string() { - $components = array(processor_string(), main_system_hardware_string(), operating_system_release(), compiler_version()); + $components = array(hw_cpu_string(), main_system_hardware_string(), operating_system_release(), compiler_version()); return base64_encode(implode("__", $components)); } diff --git a/pts-core/functions/pts-functions_system_cpu.php b/pts-core/functions/pts-functions_system_cpu.php index 7a6f44b..1244155 100644 --- a/pts-core/functions/pts-functions_system_cpu.php +++ b/pts-core/functions/pts-functions_system_cpu.php @@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -function cpu_core_count() +function hw_cpu_core_count() { // Returns number of cores present on the system if(IS_LINUX) @@ -50,12 +50,12 @@ function cpu_core_count() return $info; } -function cpu_job_count() +function hw_cpu_job_count() { // Number of CPU jobs to tell the tests to use - return cpu_core_count() * 2; + return hw_cpu_core_count() * 2; } -function processor_string() +function hw_cpu_string() { // Returns the processor name / frequency information $info = ""; @@ -71,12 +71,12 @@ function processor_string() if($physical_cpu_count == 1 || empty($physical_cpu_count)) { // Just one processor - $info = append_processor_frequency(pts_clean_information_string($cpu_strings[0])); + $info = $cpu_strings[0]; } else if($physical_cpu_count > 1 && count($cpu_strings_unique) == 1) { // Multiple processors, same model - $info = $physical_cpu_count . " x " . append_processor_frequency(pts_clean_information_string($cpu_strings[0])); + $info = $physical_cpu_count . " x " . $cpu_strings[0]; } else if($physical_cpu_count > 1 && count($cpu_strings_unique) > 1) { @@ -90,7 +90,7 @@ function processor_string() { if($current_string != $cpu_strings[$i] || $i == (count($physical_cpu_ids) - 1)) { - array_push($cpus, $current_count . " x " . append_processor_frequency(pts_clean_information_string($current_string), $i)); + array_push($cpus, $current_count . " x " . $current_string); $current_string = $cpu_strings[$i]; $current_count = 0; @@ -121,44 +121,42 @@ function processor_string() $info = trim(shell_exec("dmesg 2>&1 | grep cpu0")); $info = substr($info, strrpos($info, "cpu0:") + 6); } - - $info = append_processor_frequency(pts_clean_information_string($info), 0); } else if(IS_BSD) { $info = read_sysctl("hw.model"); - $info = append_processor_frequency(pts_clean_information_string($info), 0); } else if(IS_MACOSX) { $info = read_osx_system_profiler("SPHardwareDataType", "ProcessorName"); - $info = append_processor_frequency(pts_clean_information_string($info), 0); } - else - { - $info = "Unknown"; - } } - return $info; -} -function append_processor_frequency($cpu_string, $cpu_core = 0) -{ - // Append the processor frequency to a string - if(($freq = processor_frequency($cpu_core)) > 0) + if(!empty($info)) { - if(($strip_point = strpos($cpu_string, '@')) > 0) + $info = pts_clean_information_string($info); + $cpu_core_read = 0; // for now default to the first core frequency to read + + // Append the processor frequency to string + if(($freq = hw_cpu_default_frequency($cpu_core_read)) > 0) { - $cpu_string = trim(substr($cpu_string, 0, $strip_point)); // stripping out the reported freq, since the CPU could be overclocked, etc - } + if(($strip_point = strpos($info, "@")) > 0) + { + $info = trim(substr($info, 0, $strip_point)); // stripping out the reported freq, since the CPU could be overclocked, etc + } - $cpu_string .= " @ " . $freq . "GHz"; + $info .= " @ " . $freq . "GHz"; + } + } + else + { + $info = "Unknown"; } - return $cpu_string; + return $info; } -function processor_frequency($cpu_core = 0) +function hw_cpu_default_frequency($cpu_core = 0) { // Find out the processor frequency if(is_file("/sys/devices/system/cpu/cpu" . $cpu_core . "/cpufreq/scaling_max_freq")) // The ideal way, with modern CPUs using CnQ or EIST and cpuinfo reporting the current @@ -183,12 +181,12 @@ function processor_frequency($cpu_core = 0) } else { - $info = current_processor_frequency($cpu_core); + $info = hw_cpu_current_frequency($cpu_core); } return $info; } -function processor_temperature() +function hw_cpu_temperature() { // Read the processor temperature $temp_c = read_sensors(array("CPU Temp", "Core 0")); @@ -210,7 +208,7 @@ function processor_temperature() return $temp_c; } -function pts_processor_power_savings_enabled() +function hw_cpu_power_savings_enabled() { // Report string if CPU power savings feature is enabled $return_string = ""; @@ -223,7 +221,7 @@ function pts_processor_power_savings_enabled() if($min < $max) { - $cpu = processor_string(); + $cpu = hw_cpu_string(); if(strpos($cpu, "AMD") !== false) { @@ -241,7 +239,7 @@ function pts_processor_power_savings_enabled() } return $return_string; } -function current_processor_frequency($cpu_core = 0) +function hw_cpu_current_frequency($cpu_core = 0) { // Determine the current processor frequency if(is_file("/sys/devices/system/cpu/cpu" . $cpu_core . "/cpufreq/scaling_cur_freq")) // The ideal way, with modern CPUs using CnQ or EIST and cpuinfo reporting the current @@ -294,7 +292,7 @@ function current_processor_frequency($cpu_core = 0) return $info; } -function cpu_load_array() +function hw_cpu_load_array() { // CPU load array $stat = @file_get_contents("/proc/stat"); @@ -309,12 +307,12 @@ function cpu_load_array() return $load; } -function current_processor_usage() +function hw_cpu_usage() { // Determine current percentage for processor usage - $start_load = cpu_load_array(); + $start_load = hw_cpu_load_array(); sleep(1); - $end_load = cpu_load_array(); + $end_load = hw_cpu_load_array(); for($i = 0; $i < count($end_load); $i++) { diff --git a/pts-core/functions/pts-functions_system_software.php b/pts-core/functions/pts-functions_system_software.php index 806e8d0..337ea0b 100644 --- a/pts-core/functions/pts-functions_system_software.php +++ b/pts-core/functions/pts-functions_system_software.php @@ -27,7 +27,7 @@ function system_virtualized_mode() $virtualized = ""; $gpu = graphics_processor_string(); - if(strpos(processor_string(), "QEMU") !== false) + if(strpos(hw_cpu_string(), "QEMU") !== false) { $virtualized = "QEMU"; } diff --git a/pts-core/modules/system_monitor.php b/pts-core/modules/system_monitor.php index 236fe34..8b893df 100644 --- a/pts-core/modules/system_monitor.php +++ b/pts-core/modules/system_monitor.php @@ -24,7 +24,7 @@ class system_monitor extends pts_module_interface { const module_name = "System Monitor"; - const module_version = "1.2.2"; + const module_version = "1.3.0"; const module_description = "This module contains sensor monitoring support."; const module_author = "Michael Larabel"; @@ -502,7 +502,7 @@ class system_monitor extends pts_module_interface } if(pts_is_assignment("MONITOR_CPU_TEMP")) { - $temp = processor_temperature(); + $temp = hw_cpu_temperature(); if($temp != -1) pts_module::save_file(".s/CPU_TEMPERATURE", $temp, true); @@ -565,7 +565,7 @@ class system_monitor extends pts_module_interface } if(pts_is_assignment("MONITOR_CPU_FREQ")) { - $speed = current_processor_frequency(); + $speed = hw_cpu_current_frequency(); if($speed > 0) pts_module::save_file(".s/CPU_FREQ", $speed, true); @@ -586,7 +586,7 @@ class system_monitor extends pts_module_interface } if(pts_is_assignment("MONITOR_CPU_USAGE")) { - $usage = current_processor_usage(); + $usage = hw_cpu_usage(); if($usage != -1) pts_module::save_file(".s/CPU_USAGE", $usage, true); |