projects / phoronix-test-suite.git / commitdiff
Build Results
 
Summary

Description: Phoronix Test Suite open-source benchmarking development
Last Change: Fri 5/17/13 22:52

Recent Commits
Time
Signed-Off By
Description
Commit Diff
Fri 5/17/13 22:52
Michael Larabel  
phodevi: Report CPU... 
Wed 5/15/13 21:50
Michael Larabel  
Phoronix Test Suite... 
Wed 5/15/13 21:39
Michael Larabel  
pts-core: DragonFlyBSD... 
Wed 5/15/13 15:47
Michael Larabel  
pts-core: Updates from... 
Wed 5/15/13 15:43
Michael Larabel  
 
Sat 5/11/13 13:55
Michael Larabel  
pts-core: Fix for... 
 
> --git a/CHANGE-LOG b/CHANGE-LOG
index 843da4b
..a752a37 100644
--- a/CHANGE-LOG
+++ b/CHANGE-LOG
@@ -44,+44,@@ Phoronix Test Suite (Git)
 - 
phodeviImprove NVIDIA GPU detection on BSD systems when glxinfo is not installed
 
phodeviImprove BSD hard drive detection
 
phodeviSupport monitoring the system's battery power consumption rate on BSD
+- phodevi: CPU usage monitoring support for BSD
 - phoromatic: Use a locking system to prevent multiple copies of the Phoromatic module from running simultaneously
 - embedded: Add a PTS module named "embedded" that is a collection of options to help those running PTS on embedded/mobile devices
 - system_monitor: Append sensor monitoring graphs to end of result file during testing
diff --git a/pts-core/objects/phodevi/components/phodevi_cpu.php b/pts-core/objects/phodevi/components/phodevi_cpu.php
index ebcce44..293c6e7 100644
--- a/pts-core/objects/phodevi/components/phodevi_cpu.php
+++ b/pts-core/objects/phodevi/components/phodevi_cpu.php
@@ -397,12 +397,12 @@ class phodevi_cpu extends pts_device_interface
             $info = shell_exec("psrinfo -v | grep MHz");
             $info = substr($info, strrpos($info, "at") + 3);
             $info = substr($info, 0, strpos($info, "MHz"));
-            $info = pts_trim_double(intval($info) / 1000, 2);
+            $info = pts_trim_double($info, 2);
         }
         else if(IS_BSD)
         {
             $info = phodevi_bsd_parser::read_sysctl("dev.cpu.0.freq");
-            $info = pts_trim_double(intval($info) / 1000, 2);
+            $info = pts_trim_double($info, 2);
         }
         else if(IS_MACOSX)
         {
@@ -421,32 +421,41 @@ class phodevi_cpu extends pts_device_interface
     public static function cpu_load_array($read_core = -1)
     {
         // CPU load array
-        $stat = @file_get_contents("/proc/stat");
+        $load = array();

-        if($read_core > -1 && ($l = strpos($stat, "cpu" . $read_core)) !== false)
-        {
-            $start_line = $l;
-        }
-        else
+        if(IS_LINUX && is_file("/proc/stat"))
         {
-            $start_line = 0;
-        }
+            $stat = file_get_contents("/proc/stat");
+
+            if($read_core > -1 && ($l = strpos($stat, "cpu" . $read_core)) !== false)
+            {
+                $start_line = $l;
+            }
+            else
+            {
+                $start_line = 0;
+            }

-        $stat = substr($stat, $start_line, strpos($stat, "\n"));
-        $stat_break = explode(" ", $stat);
+            $stat = substr($stat, $start_line, strpos($stat, "\n"));
+            $stat_break = explode(" ", $stat);

-        $load = array();
-        for($i = 1; $i < 6; $i++)
+            for($i = 1; $i < 6; $i++)
+            {
+                array_push($load, $stat_break[$i]);
+            }
+        }
+        else if(IS_BSD)
         {
-            array_push($load, $stat_break[$i]);
+            $load = explode(" ", phodevi_bsd_parser::read_sysctl("kern.cp_time"));
         }
+

         return $load;
     }
     public static function cpu_usage($core = -1)
     {
         // Determine current percentage for processor usage
-        if(IS_LINUX)
+        if(IS_LINUX || IS_BSD)
         {
             $start_load = phodevi_cpu::cpu_load_array($core);
             sleep(1);
diff --git a/pts-core/objects/phodevi/parsers/phodevi_bsd_parser.php b/pts-core/objects/phodevi/parsers/phodevi_bsd_parser.php
index 9178a6b..f5f8736 100644
--- a/pts-core/objects/phodevi/parsers/phodevi_bsd_parser.php
+++ b/pts-core/objects/phodevi/parsers/phodevi_bsd_parser.php
@@ -56,7 +56,7 @@ class phodevi_bsd_parser
             if(($point = strpos($output, $desc . ":")) !== false)
             {
                 $info = substr($output, $point + strlen($desc) + 1);
-                $info = substr($info, 0, strpos("\n"));
+                $info = substr($info, 0, strpos($info, "\n"));
                 $info = trim($info);
             }
      
 
Phoronix.com
Linux Driver Forums
Copyright © 2013 by Phoronix Media