pts-core: Rework the sensor code
This commit is contained in:
@@ -104,6 +104,10 @@ class dummy_module extends pts_module_interface
|
||||
{
|
||||
echo PHP_EOL . 'We\'re about to run a test! Any pre-run processing?' . PHP_EOL . 'Called: __pre_test_run()' . PHP_EOL;
|
||||
}
|
||||
public static function __calling_test_script()
|
||||
{
|
||||
echo PHP_EOL . 'We\'re about to call the test script! Any pre-execution processing or bits to set?' . PHP_EOL . 'Called: __calling_test_script()' . PHP_EOL;
|
||||
}
|
||||
public static function __test_running()
|
||||
{
|
||||
echo PHP_EOL . 'We just started running a test! Want to tap the PID or anything?' . PHP_EOL . 'Called: __test_running()' . PHP_EOL;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/*
|
||||
Phoronix Test Suite
|
||||
URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
|
||||
Copyright (C) 2008 - 2020, Phoronix Media
|
||||
Copyright (C) 2008 - 2020, Michael Larabel
|
||||
Copyright (C) 2008 - 2024, Phoronix Media
|
||||
Copyright (C) 2008 - 2024, Michael Larabel
|
||||
system_monitor.php: System sensor monitoring module for PTS
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -25,7 +25,7 @@
|
||||
class system_monitor extends pts_module_interface
|
||||
{
|
||||
const module_name = 'System Monitor';
|
||||
const module_version = '3.4.0';
|
||||
const module_version = '4.0.0';
|
||||
const module_description = 'This module contains sensor monitoring support.';
|
||||
const module_author = 'Michael Larabel';
|
||||
|
||||
@@ -33,29 +33,19 @@ class system_monitor extends pts_module_interface
|
||||
private static $to_monitor = array();
|
||||
private static $monitor_pids = array();
|
||||
private static $monitor_test_count = 0;
|
||||
|
||||
private static $individual_test_run_request = null;
|
||||
private static $successful_test_run_request = null;
|
||||
private static $individual_test_run_offsets = null;
|
||||
private static $test_run_tries_offsets = null;
|
||||
|
||||
private static $individual_monitoring = null;
|
||||
private static $per_test_try_monitoring = null;
|
||||
|
||||
private static $cgroup_name = 'pts_monitor'; // default name for monitoring cgroup
|
||||
private static $cgroup_enabled_controllers = array();
|
||||
|
||||
private static $test_run_try_number = null;
|
||||
private static $sensor_monitoring_frequency = 1;
|
||||
private static $test_run_timer = 0;
|
||||
private static $perf_per_sensor_collection;
|
||||
private static $perf_per_sensor = false;
|
||||
public static $module_store_vars = array('MONITOR', 'PERFORMANCE_PER_WATT');
|
||||
|
||||
public static function module_environment_variables()
|
||||
{
|
||||
return array('MONITOR', 'PERFORMANCE_PER_WATT', 'PERFORMANCE_PER_SENSOR', 'MONITOR_INTERVAL', 'MONITOR_PER_RUN' );
|
||||
return array('MONITOR', 'PERFORMANCE_PER_WATT', 'PERFORMANCE_PER_SENSOR', 'MONITOR_INTERVAL');
|
||||
}
|
||||
|
||||
public static function module_info()
|
||||
{
|
||||
$info = null;
|
||||
@@ -86,8 +76,6 @@ class system_monitor extends pts_module_interface
|
||||
public static function __pre_run_process(&$test_run_manager)
|
||||
{
|
||||
self::$result_identifier = $test_run_manager->get_results_identifier();
|
||||
self::$individual_monitoring = pts_env::read('MONITOR_INDIVIDUAL') !== '0';
|
||||
self::$per_test_try_monitoring = pts_env::read('MONITOR_PER_RUN') === '1';
|
||||
self::$to_monitor = array();
|
||||
|
||||
try
|
||||
@@ -100,9 +88,9 @@ class system_monitor extends pts_module_interface
|
||||
self::set_monitoring_interval();
|
||||
|
||||
// Pad some idling sensor results at the start
|
||||
sleep((self::$sensor_monitoring_frequency * 8));
|
||||
//sleep((self::$sensor_monitoring_frequency * 8));
|
||||
|
||||
self::pts_start_monitoring();
|
||||
//self::pts_start_monitoring();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
@@ -116,15 +104,37 @@ class system_monitor extends pts_module_interface
|
||||
public static function __pre_test_run($test_run_request)
|
||||
{
|
||||
self::$individual_test_run_request = clone $test_run_request;
|
||||
|
||||
// Just to pad in some idling into the run process
|
||||
sleep(self::$sensor_monitoring_frequency);
|
||||
|
||||
// We're going to run the test for the first time (but will probably repeat it several times).
|
||||
self::$test_run_try_number = 0;
|
||||
self::save_log_offsets('run');
|
||||
|
||||
self::$test_run_timer = time();
|
||||
self::pts_start_monitoring();
|
||||
self::pause_monitoring();
|
||||
}
|
||||
public static function __calling_test_script($test_run_request)
|
||||
{
|
||||
self::chop_paused_monitoring_data();
|
||||
}
|
||||
public static function __interim_test_run()
|
||||
{
|
||||
self::pause_monitoring();
|
||||
}
|
||||
protected static function pause_monitoring()
|
||||
{
|
||||
$module_dir = pts_module::save_dir();
|
||||
foreach(self::$to_monitor as $sensor)
|
||||
{
|
||||
pts_module::save_file('logs/' . phodevi::sensor_object_identifier($sensor), 'pause', true);
|
||||
}
|
||||
}
|
||||
protected static function chop_paused_monitoring_data()
|
||||
{
|
||||
// Unpause (chop of excess) monitoring
|
||||
foreach(pts_file_io::glob(pts_module::save_dir() . 'logs/*') as $log_file)
|
||||
{
|
||||
$log_contents = file_get_contents($log_file);
|
||||
if(($x = strpos($log_file, 'pause')) !== false)
|
||||
{
|
||||
$log_contents = substr($log_contents, 0, $x);
|
||||
file_put_contents($log_file, $log_contents);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static function __test_running($test_process)
|
||||
{
|
||||
@@ -135,44 +145,24 @@ class system_monitor extends pts_module_interface
|
||||
$parent_pid = $proc_status['pid'];
|
||||
file_put_contents('/sys/fs/cgroup/' . $controller . '/' . self::$cgroup_name .'/tasks', $parent_pid);
|
||||
}
|
||||
|
||||
if(self::$per_test_try_monitoring)
|
||||
{
|
||||
self::save_log_offsets('try');
|
||||
}
|
||||
}
|
||||
public static function __interim_test_run()
|
||||
{
|
||||
if(self::$per_test_try_monitoring)
|
||||
{
|
||||
self::$test_run_try_number++;
|
||||
self::save_log_offsets('try');
|
||||
}
|
||||
}
|
||||
public static function __post_test_run_success($test_run_request)
|
||||
{
|
||||
if(self::$per_test_try_monitoring)
|
||||
{
|
||||
self::$test_run_try_number++;
|
||||
self::save_log_offsets('try');
|
||||
}
|
||||
|
||||
self::$successful_test_run_request = clone $test_run_request;
|
||||
}
|
||||
public static function __post_test_run()
|
||||
{
|
||||
self::pts_stop_monitoring();
|
||||
self::chop_paused_monitoring_data();
|
||||
}
|
||||
public static function __post_test_run_process(&$result_file)
|
||||
{
|
||||
// The self::$test_run_timer to contain how long each individual test run lasted, should anything else past this point want to use the info...
|
||||
self::$test_run_timer = time() - self::$test_run_timer;
|
||||
|
||||
// Let the system return to brief idling..
|
||||
//sleep(self::$sensor_monitoring_frequency * 8);
|
||||
|
||||
if(!empty(self::$perf_per_sensor))
|
||||
{
|
||||
self::process_perf_per_sensor($result_file);
|
||||
}
|
||||
|
||||
if(self::$individual_monitoring != false && self::$successful_test_run_request)
|
||||
if(self::$successful_test_run_request)
|
||||
{
|
||||
foreach(self::$to_monitor as $sensor)
|
||||
{
|
||||
@@ -180,7 +170,6 @@ class system_monitor extends pts_module_interface
|
||||
}
|
||||
}
|
||||
|
||||
self::$test_run_tries_offsets = array();
|
||||
self::$successful_test_run_request = null;
|
||||
self::$individual_test_run_request = null;
|
||||
self::$monitor_test_count++;
|
||||
@@ -190,15 +179,46 @@ class system_monitor extends pts_module_interface
|
||||
}
|
||||
public static function __event_results_process(&$test_run_manager)
|
||||
{
|
||||
self::process_perf_per_sensor_collection($test_run_manager);
|
||||
|
||||
//self::process_perf_per_sensor_collection($test_run_manager, true);
|
||||
echo PHP_EOL . 'Finishing System Sensor Monitoring Process' . PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
//self::pts_stop_monitoring();
|
||||
}
|
||||
public static function __post_run_process()
|
||||
{
|
||||
foreach(self::$cgroup_enabled_controllers as $controller)
|
||||
{
|
||||
self::cgroup_remove(self::$cgroup_name, $controller);
|
||||
}
|
||||
}
|
||||
private static function pts_start_monitoring()
|
||||
{
|
||||
$instant_sensors = array();
|
||||
|
||||
foreach(self::$to_monitor as $sensor)
|
||||
{
|
||||
self::process_summary_results($sensor, $test_run_manager);
|
||||
pts_module::save_file('logs/' . phodevi::sensor_object_identifier($sensor));
|
||||
$is_instant = $sensor->is_instant();
|
||||
|
||||
if($is_instant === false)
|
||||
{
|
||||
$pid = pts_module::pts_timed_function('pts_monitor_update', self::$sensor_monitoring_frequency, array(array($sensor)));
|
||||
self::$monitor_pids[] = $pid;
|
||||
}
|
||||
else
|
||||
{
|
||||
$instant_sensors[] = $sensor;
|
||||
}
|
||||
}
|
||||
echo PHP_EOL;
|
||||
|
||||
if(!empty($instant_sensors))
|
||||
{
|
||||
$pid = pts_module::pts_timed_function('pts_monitor_update', self::$sensor_monitoring_frequency, array($instant_sensors));
|
||||
self::$monitor_pids[] = $pid;
|
||||
}
|
||||
}
|
||||
private static function pts_stop_monitoring()
|
||||
{
|
||||
foreach(self::$monitor_pids as $pid)
|
||||
{
|
||||
if(function_exists('posix_kill') && defined('SIGTERM'))
|
||||
@@ -220,41 +240,8 @@ class system_monitor extends pts_module_interface
|
||||
pcntl_waitpid($pid, $status);
|
||||
}
|
||||
}
|
||||
|
||||
self::$monitor_pids = array();
|
||||
}
|
||||
public static function __post_run_process()
|
||||
{
|
||||
foreach(self::$cgroup_enabled_controllers as $controller)
|
||||
{
|
||||
self::cgroup_remove(self::$cgroup_name, $controller);
|
||||
}
|
||||
}
|
||||
private static function pts_start_monitoring()
|
||||
{
|
||||
$instant_sensors = array();
|
||||
|
||||
foreach(self::$to_monitor as $sensor)
|
||||
{
|
||||
$is_instant = $sensor->is_instant();
|
||||
|
||||
if($is_instant === false)
|
||||
{
|
||||
$pid = pts_module::pts_timed_function('pts_monitor_update', self::$sensor_monitoring_frequency, array(array($sensor)));
|
||||
self::$monitor_pids[] = $pid;
|
||||
}
|
||||
else
|
||||
{
|
||||
$instant_sensors[] = $sensor;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($instant_sensors))
|
||||
{
|
||||
$pid = pts_module::pts_timed_function('pts_monitor_update', self::$sensor_monitoring_frequency, array($instant_sensors));
|
||||
self::$monitor_pids[] = $pid;
|
||||
}
|
||||
}
|
||||
|
||||
// Reads value of a single sensor, checks its correctness and saves it to the monitor log.
|
||||
public static function pts_monitor_update($sensor_list)
|
||||
@@ -263,7 +250,7 @@ class system_monitor extends pts_module_interface
|
||||
{
|
||||
$sensor_value = phodevi::read_sensor($sensor);
|
||||
|
||||
if($sensor_value != -1 && pts_module::is_file('logs/' . phodevi::sensor_object_identifier($sensor)))
|
||||
if($sensor_value != -1) // && pts_module::is_file('logs/' . phodevi::sensor_object_identifier($sensor))
|
||||
{
|
||||
pts_module::save_file('logs/' . phodevi::sensor_object_identifier($sensor), $sensor_value, true);
|
||||
}
|
||||
@@ -290,7 +277,7 @@ class system_monitor extends pts_module_interface
|
||||
|
||||
$line = trim($line);
|
||||
|
||||
if(!empty($line) && $line >= 0)
|
||||
if(!empty($line) && $line >= 0 && is_numeric($line))
|
||||
{
|
||||
$results[] = $line;
|
||||
}
|
||||
@@ -504,9 +491,7 @@ class system_monitor extends pts_module_interface
|
||||
|
||||
if(call_user_func(array($sensor[2], 'parameter_check'), $param) === true)
|
||||
{
|
||||
$sensor_object = new $sensor[2]($instance, $param);
|
||||
self::$to_monitor[] = $sensor_object;
|
||||
pts_module::save_file('logs/' . phodevi::sensor_object_identifier($sensor_object));
|
||||
self::$to_monitor[] = new $sensor[2]($instance, $param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,7 +549,6 @@ class system_monitor extends pts_module_interface
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static function cgroup_remove($cgroup_name, $cgroup_controller)
|
||||
{
|
||||
$sudo_cmd = PTS_CORE_STATIC_PATH . 'root-access.sh ';
|
||||
@@ -578,33 +562,11 @@ class system_monitor extends pts_module_interface
|
||||
|
||||
//TODO should probably return some result
|
||||
}
|
||||
|
||||
// Saves offsets of sensor log files for the current test or for the specific test try.
|
||||
// As sensor monitoring results are saved to the single file during the whole testing process,
|
||||
// we need offset information to know where to start drawing chart for the individual test run from.
|
||||
private static function save_log_offsets($type)
|
||||
{
|
||||
foreach(self::$to_monitor as &$sensor)
|
||||
{
|
||||
$log_f = pts_module::read_file('logs/' . phodevi::sensor_object_identifier($sensor));
|
||||
$offset = count(explode(PHP_EOL, $log_f)) - 1; // as log file ends with an empty line
|
||||
|
||||
if($type === 'try')
|
||||
{
|
||||
self::$test_run_tries_offsets[phodevi::sensor_object_identifier($sensor)][self::$test_run_try_number] = $offset;
|
||||
}
|
||||
else if($type === 'run')
|
||||
{
|
||||
self::$individual_test_run_offsets[phodevi::sensor_object_identifier($sensor)] = $offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function process_perf_per_sensor(&$result_file)
|
||||
{
|
||||
foreach(self::$perf_per_sensor as $i => $s)
|
||||
{
|
||||
$sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_identifier($s), (isset(self::$individual_test_run_offsets[phodevi::sensor_identifier($s)]) ? self::$individual_test_run_offsets[phodevi::sensor_identifier($s)] : 0));
|
||||
$sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_identifier($s));
|
||||
|
||||
if(count($sensor_results) > 2 && self::$successful_test_run_request)
|
||||
{
|
||||
@@ -657,7 +619,7 @@ class system_monitor extends pts_module_interface
|
||||
}
|
||||
|
||||
// Saves average of perf-per-watt results to the result file.
|
||||
private static function process_perf_per_sensor_collection(&$test_run_manager)
|
||||
private static function process_perf_per_sensor_collection(&$test_run_manager, $print_inline = false)
|
||||
{
|
||||
foreach(self::$perf_per_sensor as $i => $s)
|
||||
{
|
||||
@@ -680,26 +642,21 @@ class system_monitor extends pts_module_interface
|
||||
$test_result->test_result_buffer = new pts_test_result_buffer();
|
||||
$test_result->test_result_buffer->add_test_result(self::$result_identifier, pts_math::set_precision($avg, 4));
|
||||
$test_run_manager->result_file->add_result($test_result);
|
||||
if($print_inline && $test_result)
|
||||
{
|
||||
pts_client::$display->test_run_success_inline($test_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static function process_test_run_results(&$sensor, &$result_file)
|
||||
{
|
||||
$result_buffer = new pts_test_result_buffer();
|
||||
$sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_object_identifier($sensor));
|
||||
|
||||
if(self::$per_test_try_monitoring)
|
||||
if(count($sensor_results) > 6)
|
||||
{
|
||||
self::prepare_per_try_results($sensor, $result_buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_object_identifier($sensor),
|
||||
self::$individual_test_run_offsets[phodevi::sensor_object_identifier($sensor)]);
|
||||
|
||||
if(count($sensor_results) > 6)
|
||||
{
|
||||
$result_buffer->add_test_result(self::$result_identifier, implode(',', $sensor_results), implode(',', $sensor_results));
|
||||
}
|
||||
$result_buffer->add_test_result(self::$result_identifier, implode(',', $sensor_results), implode(',', $sensor_results));
|
||||
}
|
||||
|
||||
if($result_buffer->get_count() == 0)
|
||||
@@ -708,8 +665,6 @@ class system_monitor extends pts_module_interface
|
||||
}
|
||||
|
||||
self::write_test_run_results($result_buffer, $result_file, $sensor);
|
||||
self::$individual_test_run_offsets[phodevi::sensor_object_identifier($sensor)] = array();
|
||||
self::$test_run_tries_offsets[phodevi::sensor_object_identifier($sensor)] = array();
|
||||
}
|
||||
private static function write_test_run_results(&$result_buffer, &$result_file, &$sensor)
|
||||
{
|
||||
@@ -742,37 +697,12 @@ class system_monitor extends pts_module_interface
|
||||
$test_result->set_used_arguments(phodevi::sensor_object_name($sensor) . ' ' . $test_result->get_arguments());
|
||||
$test_result->test_result_buffer = $result_buffer;
|
||||
|
||||
if(self::$per_test_try_monitoring && $result_buffer->get_count() > 1)
|
||||
{
|
||||
$test_result->set_used_arguments_description($arguments_try_description);
|
||||
}
|
||||
|
||||
$ro = $result_file->add_result_return_object($test_result);
|
||||
if($ro)
|
||||
{
|
||||
pts_client::$display->test_run_success_inline($ro);
|
||||
}
|
||||
}
|
||||
private static function prepare_per_try_results(&$sensor, &$result_buffer)
|
||||
{
|
||||
$sensor_offsets = self::$test_run_tries_offsets[phodevi::sensor_object_identifier($sensor)];
|
||||
|
||||
for($try_number = 1; $try_number <= self::$test_run_try_number; $try_number++)
|
||||
{
|
||||
$start_offset = $sensor_offsets[$try_number - 1];
|
||||
$end_offset = $sensor_offsets[$try_number];
|
||||
|
||||
$sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_object_identifier($sensor),
|
||||
$start_offset, $end_offset);
|
||||
|
||||
if(count($sensor_results) > 2)
|
||||
{
|
||||
$result_identifier = self::$result_identifier . " (try " . ($try_number) . ")";
|
||||
$result_value = implode(',', $sensor_results);
|
||||
$result_buffer->add_test_result($result_identifier, $result_value, $result_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Generates summary result (covering all test runs) for specified sensor and adds it to the result file.
|
||||
private static function process_summary_results(&$sensor, &$test_run_manager)
|
||||
{
|
||||
@@ -801,7 +731,6 @@ class system_monitor extends pts_module_interface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -146,6 +146,11 @@ class pts_module_interface
|
||||
// Passed is a read-only copy of the current pts_test_result for the given test
|
||||
return;
|
||||
}
|
||||
public static function __calling_test_script($obj = null)
|
||||
{
|
||||
// Passed is a read-only copy of the current pts_test_result for the given test
|
||||
return;
|
||||
}
|
||||
public static function __test_running($obj = null)
|
||||
{
|
||||
// This is called after proc_open() on the test and passed is the proc_open()'s resource, to obtain the PID, etc.
|
||||
|
||||
@@ -294,6 +294,7 @@ class pts_test_execution
|
||||
}
|
||||
}
|
||||
|
||||
pts_module_manager::module_process('__calling_test_script', $test_run_request);
|
||||
$test_process = proc_open($test_prepend . $to_exec . ' ' . $execute_binary_prepend . $execute_binary_prepend_final . $execute_binary . ' ' . $pts_test_arguments . $post_test_args, $descriptorspec, $pipes, $to_execute, array_merge($host_env, pts_client::environment_variables(), $terv));
|
||||
|
||||
if(is_resource($test_process))
|
||||
|
||||
@@ -38,7 +38,7 @@ class gpu_temp extends phodevi_sensor
|
||||
|
||||
if($temp_c == -1 || empty($temp_c))
|
||||
{
|
||||
foreach(array_merge(array('/sys/class/drm/card0/device/temp1_input'), pts_file_io::glob('/sys/class/drm/card0/device/hwmon/hwmon*/temp1_input')) as $temp_input)
|
||||
foreach(array_merge(array('/sys/class/drm/card0/device/temp1_input'), pts_file_io::glob('/sys/class/drm/card*/device/hwmon/hwmon*/temp1_input')) as $temp_input)
|
||||
{
|
||||
// This works for at least Nouveau driver with Linux 2.6.37 era DRM
|
||||
if(is_readable($temp_input) == false)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/*
|
||||
Phoronix Test Suite
|
||||
URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
|
||||
Copyright (C) 2010 - 2021, Phoronix Media
|
||||
Copyright (C) 2010 - 2021, Michael Larabel
|
||||
Copyright (C) 2010 - 2024, Phoronix Media
|
||||
Copyright (C) 2010 - 2024, Michael Larabel
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -758,6 +758,179 @@ class pts_result_file_analyzer
|
||||
|
||||
return false;
|
||||
}
|
||||
public static function generate_composite_for_sensors($result_file, $do_sort = false, $do_perf_per_sensor = 'Power', $gen_composite_results = true)
|
||||
{
|
||||
$sensor_types = array(
|
||||
'cpu.power' => 'CPU Power Consumption',
|
||||
'gpu.power' => 'GPU Power Consumption',
|
||||
'sys.power' => 'System Power Consumption',
|
||||
'cpu.peak-freq' => 'CPU Peak Freq',
|
||||
'cpu.temp' => 'CPU Temp',
|
||||
'gpu.temp' => 'GPU Temp',
|
||||
);
|
||||
$results = array();
|
||||
foreach($result_file->get_result_objects() as &$result)
|
||||
{
|
||||
if(stripos($result->get_arguments_description(), ' Monitor') === false || $result->test_profile->get_display_format() != 'LINE_GRAPH')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$this_sensor = null;
|
||||
foreach($sensor_types as $sensor_check)
|
||||
{
|
||||
if(stripos($result->get_arguments_description(), $sensor_check) !== false)
|
||||
{
|
||||
$this_sensor = $sensor_check;
|
||||
}
|
||||
}
|
||||
if($this_sensor == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this_round = array();
|
||||
foreach($result->test_result_buffer->get_buffer_items() as $buffer_item)
|
||||
{
|
||||
$r = explode(',', $buffer_item->get_result_value());
|
||||
$skip = false;
|
||||
for($i = 0; $i < count($r); $i++)
|
||||
{
|
||||
if(!is_numeric($r[$i]))
|
||||
{
|
||||
$skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($i < 3)
|
||||
{
|
||||
$skip = true;
|
||||
}
|
||||
if($skip)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$ri = $buffer_item->get_result_identifier();
|
||||
$this_round[$ri] = $r;
|
||||
|
||||
if(!isset($results[$this_sensor][$ri]))
|
||||
{
|
||||
$results[$this_sensor][$ri] = array();
|
||||
}
|
||||
$results[$this_sensor][$ri]= array_merge($results[$this_sensor][$ri], $r);
|
||||
}
|
||||
|
||||
if($do_perf_per_sensor != false && stripos($this_sensor, $do_perf_per_sensor) !== false && $result->get_parent_hash() != '' && !empty($this_round))
|
||||
{
|
||||
$perf_per_result = clone $result_file->get_result($result->get_parent_hash());
|
||||
if($perf_per_result && $perf_per_result->test_profile->get_display_format() == 'BAR_GRAPH')
|
||||
{
|
||||
$perf_per_result->test_profile->set_identifier(null);
|
||||
//$perf_per_result->set_used_arguments(' xxx s');
|
||||
$orig_result_buffer = $perf_per_result->test_result_buffer;
|
||||
$perf_per_result->test_result_buffer = new pts_test_result_buffer();
|
||||
$perf_per_result->set_parent_hash($result->get_parent_hash());
|
||||
$sensor_scale = $result->test_profile->get_result_scale();
|
||||
if(substr($sensor_scale, -1) == 's')
|
||||
{
|
||||
$sensor_scale = substr($sensor_scale, 0, -1);
|
||||
}
|
||||
|
||||
if($perf_per_result->test_profile->get_result_proportion() == 'HIB')
|
||||
{
|
||||
$perf_per_result->append_to_arguments_description(' [Perf Per ' . $sensor_scale . ' Using ' . str_replace(array(' Monitor', ' Consumption'), '', $result->get_arguments_description()) . ']');
|
||||
$perf_per_result->test_profile->set_result_scale($perf_per_result->test_profile->get_result_scale() . ' Per ' . $sensor_scale);
|
||||
foreach($this_round as $identifier => $all_results_array)
|
||||
{
|
||||
$perf_result = $orig_result_buffer->get_result_from_identifier($identifier);
|
||||
if($perf_result != false && is_numeric($perf_result))
|
||||
{
|
||||
$perf_per_result->test_result_buffer->add_test_result($identifier, round($perf_result / pts_math::arithmetic_mean($all_results_array), 3));
|
||||
}
|
||||
}
|
||||
$result_file->add_result($perf_per_result);
|
||||
}
|
||||
else if($perf_per_result->test_profile->get_result_proportion() == 'LIB' && $sensor_scale == 'Watt')
|
||||
{
|
||||
$multiplier = -1;
|
||||
switch($perf_per_result->test_profile->get_result_scale())
|
||||
{
|
||||
case 'Seconds':
|
||||
$multiplier = 1;
|
||||
break;
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
$multiplier = 0.001;
|
||||
break;
|
||||
case 'Microseconds':
|
||||
case 'us':
|
||||
$multiplier = 0.000001;
|
||||
break;
|
||||
}
|
||||
if($multiplier != -1)
|
||||
{
|
||||
$perf_per_result->append_to_arguments_description(' [Power Efficiency Using ' . str_replace(array(' Monitor', ' Consumption'), '', $result->get_arguments_description()) . ']');
|
||||
$perf_per_result->test_profile->set_result_scale('Joules Per Run Average');
|
||||
foreach($this_round as $identifier => $all_results_array)
|
||||
{
|
||||
$perf_result = $orig_result_buffer->get_result_from_identifier($identifier);
|
||||
if($perf_result != false && is_numeric($perf_result))
|
||||
{
|
||||
$perf_per_result->test_result_buffer->add_test_result($identifier, round(($perf_result * $multiplier) * pts_math::arithmetic_mean($all_results_array), 3));
|
||||
}
|
||||
}
|
||||
$result_file->add_result($perf_per_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($results as $identifier_set => $result_set)
|
||||
{
|
||||
foreach($reset_set as $identifier => $values)
|
||||
{
|
||||
if(count($values) < 2)
|
||||
{
|
||||
// If small result file with not a lot of data, don't bother showing...
|
||||
unset($results[$identifier_set][$identifier]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return_result_objects = array();
|
||||
if($gen_composite_results && !empty($results))
|
||||
{
|
||||
foreach($results as $set_identifier => $result_set)
|
||||
{
|
||||
$test_profile = new pts_test_profile();
|
||||
$test_result = new pts_test_result($test_profile);
|
||||
$test_result->test_profile->set_test_title($set_identifier . ' Monitoring Overview');
|
||||
$test_result->test_profile->set_identifier(null);
|
||||
$test_result->test_profile->set_version(null);
|
||||
$test_result->test_profile->set_result_proportion(null);
|
||||
$test_result->test_profile->set_display_format('LINE_GRAPH');
|
||||
$test_result->test_profile->set_result_scale('Watts');
|
||||
//$test_result->test_profile->set_result_proportion('HIB');
|
||||
$test_result->set_used_arguments_description('Accumulated ' . $set_identifier . ' Monitoring');
|
||||
$test_result->set_used_arguments('Result Composite ' . $set_identifier);
|
||||
$test_result->test_result_buffer = new pts_test_result_buffer();
|
||||
|
||||
foreach($result_set as $identifier => $values)
|
||||
{
|
||||
$test_result->test_result_buffer->add_test_result($identifier, implode(',', $values));
|
||||
}
|
||||
|
||||
if(!$result_file->is_multi_way_comparison() && $do_sort)
|
||||
{
|
||||
$test_result->sort_results_by_performance();
|
||||
}
|
||||
$test_result->dynamically_generated = true;
|
||||
$return_result_objects[] = $test_result;
|
||||
}
|
||||
}
|
||||
|
||||
return $return_result_objects;
|
||||
}
|
||||
public static function generate_geometric_mean_result_per_test($result_file, $do_sort = false, $selector = null, $best_is_last = false)
|
||||
{
|
||||
$geo_results = array();
|
||||
|
||||
@@ -413,6 +413,7 @@ class pts_result_viewer_embed
|
||||
$run_counts_for_identifier[$bi->get_result_identifier()] = $bi->get_sample_count();
|
||||
}
|
||||
}
|
||||
/*
|
||||
foreach($c_ro->test_result_buffer->buffer_items as $bi)
|
||||
{
|
||||
$res_tally = $bi->get_result_value();
|
||||
@@ -425,7 +426,7 @@ class pts_result_viewer_embed
|
||||
$res_tally = array_sum($res_tally);
|
||||
$graph->addTestNote($bi->get_result_identifier() . ': Approximate power consumption of ' . round($res_tally / $run_counts_for_identifier[$bi->get_result_identifier()]) . ' Joules per run.');
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
$tabs[$dindex] = pts_render::render_graph_inline_embed($graph, $result_file, $extra_attributes);
|
||||
$show_on_print[] = $dindex;
|
||||
@@ -935,6 +936,18 @@ class pts_result_viewer_embed
|
||||
|
||||
$analyze_checkboxes['Table'][] = array('sdt', 'Show Detailed System Result Table');
|
||||
|
||||
$result_file_env_vars = pts_strings::parse_value_string_vars($result_file->get_preset_environment_variables());
|
||||
if(isset($result_file_env_vars['MONITOR']))
|
||||
{
|
||||
$analyze_checkboxes['Sensor Monitoring'] = array(
|
||||
array('asm', 'Show Accumulated Sensor Monitoring Data For Displayed Results')
|
||||
);
|
||||
if(stripos($result_file_env_vars['MONITOR'], '.power') !== false)
|
||||
{
|
||||
$analyze_checkboxes['Sensor Monitoring'][] = array('ppw', 'Generate Power Efficiency / Performance Per Watt Results');
|
||||
}
|
||||
}
|
||||
|
||||
$t = null;
|
||||
foreach($analyze_checkboxes as $title => $group)
|
||||
{
|
||||
@@ -1604,6 +1617,18 @@ class pts_result_viewer_embed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(self::check_request_for_var($request, 'asm') || self::check_request_for_var($request, 'ppw'))
|
||||
{
|
||||
$results = pts_result_file_analyzer::generate_composite_for_sensors($result_file, false, (self::check_request_for_var($request, 'ppw') ? 'Power' : false), (self::check_request_for_var($request, 'asm') ? true : false));
|
||||
if($results)
|
||||
{
|
||||
foreach($results as $result)
|
||||
{
|
||||
$result_file->add_result($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(self::check_request_for_var($request, 'grs'))
|
||||
{
|
||||
$result_file->sort_result_object_order_by_spread();
|
||||
|
||||
Reference in New Issue
Block a user