diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-04-28 22:34:54 -0400 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-04-28 22:34:54 -0400 |
commit | 0f4c63763f2151b25b17b688fed762fd09ae1530 (patch) | |
tree | 68d26d958a03af2587090eceec2a6b2ae7841b19 /pts-core | |
parent | 09b5cc5c44b6b57c8e38b6f5a8197e1923282292 (diff) | |
download | phoronix-test-suite-upstream-0f4c63763f2151b25b17b688fed762fd09ae1530.tar.gz phoronix-test-suite-upstream-0f4c63763f2151b25b17b688fed762fd09ae1530.tar.xz phoronix-test-suite-upstream-0f4c63763f2151b25b17b688fed762fd09ae1530.zip |
Add battery.power option to MONITOR= and a few other fixes in this
commit too
Diffstat (limited to 'pts-core')
-rw-r--r-- | pts-core/functions/pts-functions.php | 8 | ||||
-rw-r--r-- | pts-core/functions/pts-functions_monitor.php | 61 | ||||
-rw-r--r-- | pts-core/functions/pts-functions_system.php | 12 | ||||
-rw-r--r-- | pts-core/objects/pts_Graph.php | 9 |
4 files changed, 65 insertions, 25 deletions
diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php index f6f74ce..93e56f8 100644 --- a/pts-core/functions/pts-functions.php +++ b/pts-core/functions/pts-functions.php @@ -86,7 +86,6 @@ if(($to_show = getenv("MONITOR"))) if(in_array("gpu.temp", $to_show)) { - define("MONITOR_GPU_TEMP", 1); $GPU_TEMPERATURE = array(); } @@ -103,6 +102,13 @@ if(($to_show = getenv("MONITOR"))) $SYS_TEMPERATURE = array(); } + if(in_array("battery.power", $to_show)) + { + + define("MONITOR_BATTERY_POWER", 1); + $BATTERY_POWER = array(); + } + register_shutdown_function("pts_monitor_statistics"); } diff --git a/pts-core/functions/pts-functions_monitor.php b/pts-core/functions/pts-functions_monitor.php index ce6d9e7..68abcf5 100644 --- a/pts-core/functions/pts-functions_monitor.php +++ b/pts-core/functions/pts-functions_monitor.php @@ -8,6 +8,8 @@ function pts_monitor_update() pts_record_cpu_temperature(); if(defined("MONITOR_SYS_TEMP")) pts_record_sys_temperature(); + if(defined("MONITOR_BATTERY_POWER")) + pts_record_battery_power(); } function pts_monitor_statistics() { @@ -17,6 +19,7 @@ function pts_monitor_statistics() $m_array = array(); $type_index = array(); $type_index["THERMAL"] = array(); + $type_index["POWER"] = array(); if(isset($GLOBALS["GPU_TEMPERATURE"])) { @@ -57,6 +60,19 @@ function pts_monitor_statistics() array_push($type_index["THERMAL"], count($m_array) - 1); } } + if(isset($GLOBALS["BATTERY_POWER"])) + { + $this_array = $GLOBALS["BATTERY_POWER"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "Battery"); + array_push($type, "Power"); + array_push($unit, "Milliwatts"); + array_push($m_array, $this_array); + array_push($type_index["POWER"], count($m_array) - 1); + } + } $info_report = ""; for($i = 0; $i < count($m_array); $i++) @@ -81,7 +97,7 @@ function pts_monitor_statistics() } $avg = $total / count($m_array[$i]); - $info_report .= $device[$i] . " " . $type[$i] . " Statistics:\n\nLow: " . pts_trim_double($low) . $unit[$i] . "\nHigh: " . pts_trim_double($high) . $unit[$i] . "\nAverage: " . pts_trim_double($avg) . $unit[$i]; + $info_report .= $device[$i] . " " . $type[$i] . " Statistics:\n\nLow: " . pts_trim_double($low) . ' ' . $unit[$i] . "\nHigh: " . pts_trim_double($high) . ' ' . $unit[$i] . "\nAverage: " . pts_trim_double($avg) . ' ' . $unit[$i]; } if(trim($info_report) != "") @@ -98,31 +114,34 @@ function pts_monitor_statistics() $image_count = 0; foreach($type_index as $key => $sub_array) { - $graph_title = $type[$sub_array[0]] . " Monitor"; - $graph_unit = $unit[$sub_array[0]]; - $graph_unit = str_replace("°C", "Degrees Celsius", $graph_unit); - $sub_title = date("F j, Y - g:i A"); - - $t = new pts_LineGraph($graph_title, $sub_title, $graph_unit); - - $first_run = true; - foreach($sub_array as $id_point) + if(count($sub_array) > 0) { - $t->loadGraphValues($m_array[$id_point], $device[$id_point]); + $graph_title = $type[$sub_array[0]] . " Monitor"; + $graph_unit = $unit[$sub_array[0]]; + $graph_unit = str_replace("°C", "Degrees Celsius", $graph_unit); + $sub_title = date("F j, Y - g:i A"); - if($first_run) + $t = new pts_LineGraph($graph_title, $sub_title, $graph_unit); + + $first_run = true; + foreach($sub_array as $id_point) { - $t->loadGraphIdentifiers($m_array[$id_point]); - $t->hideGraphIdentifiers(); - $first_run = false; + $t->loadGraphValues($m_array[$id_point], $device[$id_point]); + + if($first_run) + { + $t->loadGraphIdentifiers($m_array[$id_point]); + $t->hideGraphIdentifiers(); + $first_run = false; + } } - } - $t->loadGraphVersion(PTS_VERSION); - $t->save_graph(PTS_MONITOR_DIR . THIS_RUN_TIME . '-' . $image_count . ".png"); - $t->renderGraph(); - $url .= THIS_RUN_TIME . '-' . $image_count . ".png,"; - $image_count++; + $t->loadGraphVersion(PTS_VERSION); + $t->save_graph(PTS_MONITOR_DIR . THIS_RUN_TIME . '-' . $image_count . ".png"); + $t->renderGraph(); + $url .= THIS_RUN_TIME . '-' . $image_count . ".png,"; + $image_count++; + } } } diff --git a/pts-core/functions/pts-functions_system.php b/pts-core/functions/pts-functions_system.php index 49fa2bb..7a4d463 100644 --- a/pts-core/functions/pts-functions_system.php +++ b/pts-core/functions/pts-functions_system.php @@ -247,6 +247,18 @@ function pts_record_sys_temperature() if($temp != -1) array_push($SYS_TEMPERATURE, $temp); } +function pts_record_battery_power() +{ + global $BATTERY_POWER; + $state = read_acpi_value("/battery/BAT0/state", "charging state"); + $power = read_acpi_value("/battery/BAT0/state", "present rate"); + + if(($end = strpos($power, ' ')) > 0 && $state == "discharging") + $power = substr($power, 0, $end); + + if(!empty($power)) + array_push($BATTERY_POWER, $power); +} function read_acpi_value($point, $match) { $value = ""; diff --git a/pts-core/objects/pts_Graph.php b/pts-core/objects/pts_Graph.php index 3ef86c5..f1c9d8a 100644 --- a/pts-core/objects/pts_Graph.php +++ b/pts-core/objects/pts_Graph.php @@ -87,15 +87,18 @@ class pts_Graph $this->graph_left_end = $this->graph_attr_width - $this->graph_left_end_opp; // Directory for TTF Fonts - if(!defined("FONT_DIRECTORY")) + if(!defined("FONT_DIRECTORY") && defined("RESULTS_VIEWER_DIR")) { putenv("GDFONTPATH=" . RESULTS_VIEWER_DIR); - //putenv("GDFONTPATH=" . getcwd()); // The directory where the TTF font files should be. getcwd() will look in the same directory as this file } - else + else if(defined("FONT_DIRECTORY")) { putenv("GDFONTPATH=" . FONT_DIRECTORY); } + else + { + putenv("GDFONTPATH=" . getcwd()); + } } // |