summaryrefslogtreecommitdiffstats
path: root/pts-core
diff options
context:
space:
mode:
authorMichael Larabel <michael@phx-laptop.(none)>2008-12-31 10:28:44 -0500
committerMichael Larabel <michael@phx-laptop.(none)>2008-12-31 10:28:44 -0500
commit37ec79012e0155da34eb8b3bbb1d9f195945c415 (patch)
tree13bbce5722b93da113113e1d331d22ebfecaced0 /pts-core
parent78bcc0e749fc357625ca09cdebcfd288d874bf84 (diff)
downloadphoronix-test-suite-upstream-37ec79012e0155da34eb8b3bbb1d9f195945c415.tar.gz
phoronix-test-suite-upstream-37ec79012e0155da34eb8b3bbb1d9f195945c415.tar.xz
phoronix-test-suite-upstream-37ec79012e0155da34eb8b3bbb1d9f195945c415.zip
pts-core: Cache reading of hw_cpu_core_count() since that shouldn't
change while pts-core is running
Diffstat (limited to 'pts-core')
-rw-r--r--pts-core/functions/pts-functions_system_cpu.php55
-rw-r--r--pts-core/objects/pts_module.php6
2 files changed, 38 insertions, 23 deletions
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;