From 37ec79012e0155da34eb8b3bbb1d9f195945c415 Mon Sep 17 00:00:00 2001 From: Michael Larabel Date: Wed, 31 Dec 2008 10:28:44 -0500 Subject: pts-core: Cache reading of hw_cpu_core_count() since that shouldn't change while pts-core is running --- CHANGE-LOG | 1 + pts-core/functions/pts-functions_system_cpu.php | 55 ++++++++++++++----------- pts-core/objects/pts_module.php | 6 +++ 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/CHANGE-LOG b/CHANGE-LOG index cdce0fc..75feb63 100644 --- a/CHANGE-LOG +++ b/CHANGE-LOG @@ -15,6 +15,7 @@ Phoronix Test Suite (Git) - pts-core: When installing or running a test, only print to standard output if under 10KB - pts-core: Rewrite pts_remove() function - pts-core: Allow reading CPU usage percent from individual cores +- pts-core: Cache reading of hw_cpu_core_count() since that shouldn't change while pts-core is running - pts: Add UXA acceleration check to GtkPerf test note reporting - pts: Add 2d-test base profile that reports 2D acceleration mode using Cascading Test Profiles - pts: Add build-mysql test profile for timed build of MySQL 5.1 diff --git a/pts-core/functions/pts-functions_system_cpu.php b/pts-core/functions/pts-functions_system_cpu.php index e099a34..494d781 100644 --- a/pts-core/functions/pts-functions_system_cpu.php +++ b/pts-core/functions/pts-functions_system_cpu.php @@ -24,34 +24,43 @@ function hw_cpu_core_count() { // Returns number of cores present on the system - $info = null; + static $core_count = 0; - if(IS_LINUX) + if($core_count == 0) { - $processors = read_cpuinfo("processor"); - $info = count($processors); - } - else if(IS_SOLARIS) - { - $info = trim(shell_exec("psrinfo")); - $info = explode("\n", $info); - $info = count($info); - } - else if(IS_BSD) - { - $info = read_sysctl("hw.ncpu"); - } - else if(IS_MACOSX) - { - $info = read_osx_system_profiler("SPHardwareDataType", "TotalNumberOfCores"); - } + $info = 0; - if(empty($info)) - { - $info = 1; + if(IS_LINUX) + { + $processors = read_cpuinfo("processor"); + $info = count($processors); + } + else if(IS_SOLARIS) + { + $info = trim(shell_exec("psrinfo")); + $info = explode("\n", $info); + $info = count($info); + } + else if(IS_BSD) + { + $info = read_sysctl("hw.ncpu"); + } + else if(IS_MACOSX) + { + $info = read_osx_system_profiler("SPHardwareDataType", "TotalNumberOfCores"); + } + + if(is_int($info) && $info > 0) + { + $core_count = $info; + } + else + { + $core_count = 1; + } } - return $info; + return $core_count; } function hw_cpu_job_count() { diff --git a/pts-core/objects/pts_module.php b/pts-core/objects/pts_module.php index 084332e..c93aa4d 100644 --- a/pts-core/objects/pts_module.php +++ b/pts-core/objects/pts_module.php @@ -123,6 +123,12 @@ class pts_module return $file; } + public static function is_file($file) + { + $file = self::save_dir() . $file; + + return is_file($file); + } public static function remove_file($file) { $file = self::save_dir() . $file; -- cgit