public function generate_download_object_list($do_file_checks = true) { $download_xml_file = $this->test_profile->get_file_download_spec(); if ($download_xml_file != null) { $xml_parser = new pts_test_downloads_nye_XmlReader($download_xml_file); $package_url = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/URL'); $package_md5 = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/MD5'); $package_sha256 = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/SHA256'); $package_filename = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/FileName'); $package_filesize = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/FileSize'); $package_platform = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/PlatformSpecific'); $package_architecture = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/ArchitectureSpecific'); foreach (array_keys($package_url) as $i) { if (!empty($package_platform[$i]) && $do_file_checks) { $platforms = pts_strings::comma_explode($package_platform[$i]); if (!in_array(phodevi::operating_system(), $platforms) && !(phodevi::is_bsd() && in_array('Linux', $platforms) && (pts_client::executable_in_path('kldstat') && strpos(shell_exec('kldstat -n linux 2>&1'), 'linux.ko') != false))) { // This download does not match the operating system continue; } } if (!empty($package_architecture[$i]) && $do_file_checks) { $architectures = pts_strings::comma_explode($package_architecture[$i]); if (phodevi::cpu_arch_compatible($architectures) == false) { // This download does not match the CPU architecture continue; } } $this->test_files[] = new pts_test_file_download($package_url[$i], $package_filename[$i], $package_filesize[$i], $package_md5[$i], $package_sha256[$i], $package_platform[$i], $package_architecture[$i]); } } }
public function get_package_format($distro_package = null, $file_check = null, $arch_specific = null) { if (!is_array($arch_specific)) { $arch_specific = pts_strings::comma_explode($arch_specific); } return array('os_package' => $distro_package, 'file_check' => $file_check, 'arch_specific' => $arch_specific); }
public function __construct(&$result_object, &$result_file = null, $extra_attributes = null) { $max_count = 0; if (!isset($extra_attributes['force_tracking_line_graph']) || !$extra_attributes['force_tracking_line_graph']) { foreach ($result_object->test_result_buffer->buffer_items as &$buffer_item) { /* $r = pts_strings::comma_explode($buffer_item->get_result_raw()); $c = count($r); foreach($r as $val) { echo $val; } */ $values = pts_strings::comma_explode($buffer_item->get_result_value()); $buffer_item->reset_result_value($values); $buffer_item->reset_raw_value(pts_strings::comma_explode($buffer_item->get_result_raw())); $max_count = max($max_count, count($values)); } } //$extra_attributes['no_compact_results_var'] = true; parent::__construct($result_object, $result_file, $extra_attributes); $this->i['show_graph_key'] = true; $this->i['show_background_lines'] = true; $this->i['iveland_view'] = true; $this->i['min_identifier_size'] = 6.5; $this->i['plot_overview_text'] = isset($extra_attributes['no_overview_text']) == false; $this->i['display_select_identifiers'] = false; $this->i['hide_graph_identifiers'] = !isset($extra_attributes['force_tracking_line_graph']) || !$extra_attributes['force_tracking_line_graph']; // XXX removed on 20 January from here: $this->is_multi_way_comparison && if (isset($extra_attributes['force_tracking_line_graph']) && $extra_attributes['force_tracking_line_graph'] && is_array($this->results)) { // need to do compacting here $this->test_result->test_result_buffer = new pts_test_result_buffer(); foreach ($this->results as $system => $results) { $result_r = array(); $raw_r = array(); //$json_r = array(); foreach ($this->graph_identifiers as $d) { $result_r[$d] = null; $raw_r[$d] = null; //$json_r[$d] = null; } foreach ($results as &$buffer_item) { $result_r[$buffer_item->get_result_identifier()] = $buffer_item->get_result_value(); $raw_r[$buffer_item->get_result_identifier()] = $buffer_item->get_result_raw(); $json_r[$buffer_item->get_result_identifier()] = $buffer_item->get_result_json(); } // add array_values($json_r) $this->test_result->test_result_buffer->add_test_result($system, array_values($result_r), array_values($raw_r)); } $max_count = count($this->graph_identifiers) + 1; } $this->max_count = $max_count; }
public function add_test_profile($test_profile) { $added = false; if (($e = pts_client::read_env('SKIP_TESTS')) != false && (in_array($test_profile->get_identifier(false), pts_strings::comma_explode($e)) || in_array($test_profile->get_identifier(true), pts_strings::comma_explode($e)))) { //pts_client::$display->test_install_error($test_profile->get_identifier() . ' is being skipped from installation.'); } else { if (($e = pts_client::read_env('SKIP_TESTING_SUBSYSTEMS')) != false && in_array(strtolower($test_profile->get_test_hardware_type()), pts_strings::comma_explode(strtolower($e)))) { //pts_client::$display->test_install_error($test_profile->get_identifier() . ' is being skipped from installation.'); } else { $added = pts_arrays::unique_push($this->tests_to_install, new pts_test_install_request($test_profile)); } } return $added; }
public static function run($args) { $result_file = new pts_result_file($args[0]); $result_file_identifiers = $result_file->get_system_identifiers(); if (count($result_file_identifiers) < 2) { echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL; return false; } $extract_identifiers = pts_strings::comma_explode(pts_user_io::prompt_text_menu('Select the test run(s) to extract', $result_file_identifiers, true)); $remove_identifiers = array_diff($result_file_identifiers, $extract_identifiers); $result_file->remove_run($remove_identifiers); do { echo PHP_EOL . 'Enter new result file to extract to: '; $extract_to = pts_user_io::read_user_input(); $extract_to = pts_test_run_manager::clean_save_name($extract_to); } while (empty($extract_to)); pts_client::save_test_result($extract_to . '/composite.xml', $result_file->get_xml()); pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/index.html'); }
public static function __pre_run_process(&$test_run_manager) { self::$result_identifier = $test_run_manager->get_results_identifier(); self::$individual_monitoring = pts_module::read_variable('MONITOR_INDIVIDUAL') !== '0'; self::$to_monitor = array(); $to_show = pts_strings::comma_explode(pts_module::read_variable('MONITOR')); if (pts_module::read_variable('PERFORMANCE_PER_WATT')) { // We need to ensure the system power consumption is being tracked to get performance-per-Watt pts_arrays::unique_push($to_show, 'sys.power'); self::$individual_monitoring = true; echo PHP_EOL . 'To Provide Performance-Per-Watt Outputs.' . PHP_EOL; } $monitor_all = in_array('all', $to_show); foreach (phodevi::supported_sensors() as $sensor) { if ($monitor_all || in_array(phodevi::sensor_identifier($sensor), $to_show) || in_array('all.' . $sensor[0], $to_show)) { array_push(self::$to_monitor, $sensor); pts_module::save_file('logs/' . phodevi::sensor_identifier($sensor)); } } if (in_array('i915_energy', $to_show) && is_readable('/sys/kernel/debug/dri/0/i915_energy')) { // For now the Intel monitoring is a special case separate from the rest // of the unified sensor monitoring since we're not polling it every time but just pre/post test. self::$monitor_i915_energy = true; } if (count(self::$to_monitor) > 0) { echo PHP_EOL . 'Sensors To Be Logged:'; foreach (self::$to_monitor as &$sensor) { echo PHP_EOL . ' - ' . phodevi::sensor_name($sensor); } echo PHP_EOL; if (pts_module::read_variable('MONITOR_INTERVAL') != null) { $proposed_interval = pts_module::read_variable('MONITOR_INTERVAL'); if (is_numeric($proposed_interval) && $proposed_interval >= 1) { self::$sensor_monitoring_frequency = $proposed_interval; } } // Pad some idling sensor results at the start sleep(self::$sensor_monitoring_frequency * 8); } pts_module::pts_timed_function('pts_monitor_update', self::$sensor_monitoring_frequency); }
public static function read_sun_ddu_dmi_info($find_objects, $args = null) { // Read Sun's Device Driver Utility for OpenSolaris $values = array(); if (in_array(phodevi::read_property('system', 'kernel-architecture'), array('i686', 'x86_64'))) { $dmi_info = '/usr/ddu/bin/i386/dmi_info'; } else { $dmi_info = '/usr/ddu/bin/sparc/dmi_info'; } if (is_executable($dmi_info) || is_executable($dmi_info = '/usr/ddu/bin/dmi_info')) { $info = shell_exec($dmi_info . ' ' . $args . ' 2>&1'); $lines = explode("\n", $info); $find_objects = pts_arrays::to_array($find_objects); for ($i = 0; $i < count($find_objects) && count($values) == 0; $i++) { $objects = pts_strings::comma_explode($find_objects[$i]); $this_section = null; if (count($objects) == 2) { $section = $objects[0]; $object = $objects[1]; } else { $section = null; $object = $objects[0]; } foreach ($lines as $line) { $line = pts_strings::colon_explode($line); $line_object = isset($line[0]) ? str_replace(' ', null, $line[0]) : null; $this_value = count($line) > 1 ? $line[1] : null; if (empty($this_value) && !empty($section)) { $this_section = $line_object; } if ($line_object == $object && ($this_section == $section || pts_strings::proximity_match($section, $this_section)) && !empty($this_value) && $this_value != 'Unknown') { array_push($values, $this_value); } } } } return $values; }
public static function run($args) { $result = $args[0]; $result_file = new pts_result_file($result); $result_file_identifiers = $result_file->get_system_identifiers(); if (count($result_file_identifiers) < 2) { echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL; return false; } $extract_identifiers = pts_strings::comma_explode(pts_user_io::prompt_text_menu('Select the test run(s) to extract', $result_file_identifiers, true)); $extract_selects = array(); foreach ($extract_identifiers as $extract_identifier) { array_push($extract_selects, new pts_result_merge_select($result, $extract_identifier)); } do { echo PHP_EOL . 'Enter new result file to extract to: '; $extract_to = pts_user_io::read_user_input(); $extract_to = pts_test_run_manager::clean_save_name($extract_to); } while (empty($extract_to) || pts_result_file::is_test_result_file($extract_to)); $extract_result = call_user_func_array(array('pts_merge', 'merge_test_results'), $extract_selects); pts_client::save_test_result($extract_to . '/composite.xml', $extract_result); pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/index.html'); }
private static function prepare_sensor_parameters() { $sensor_list = pts_strings::comma_explode(pts_module::read_variable('MONITOR')); $to_monitor = array(); foreach ($sensor_list as $sensor) { $sensor_split = pts_strings::trim_explode('.', $sensor); // Set 'all' from the beginning (eg. all.cpu.frequency) as the last // element (cpu.frequency.all). As sensor parameters are also supported // now, it's handy to mark that we want to include all sensors of specified // type (cpu.all) or just all supported parameters of specified sensor // (cpu.frequency.all). if ($sensor_split[0] === 'all') { $sensor_split[] = 'all'; array_shift($sensor_split); } $type =& $sensor_split[0]; $name =& $sensor_split[1]; $parameter =& $sensor_split[2]; if (empty($to_monitor[$type][$name])) { $to_monitor[$type][$name] = array(); } if ($parameter !== NULL) { $to_monitor[$type][$name][] = $parameter; } } return $to_monitor; }
public function get_architecture_array() { return pts_strings::comma_explode($this->architecture); }
public static function render_graph_process(&$result_object, &$result_file = null, $save_as = false, $extra_attributes = null) { if (isset($extra_attributes['sort_result_buffer'])) { $result_object->test_result_buffer->sort_buffer_items(); } if (isset($extra_attributes['reverse_result_buffer'])) { $result_object->test_result_buffer->buffer_values_reverse(); } if (isset($extra_attributes['normalize_result_buffer'])) { if (isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1) { $normalize_against = $extra_attributes['highlight_graph_values'][0]; } else { $normalize_against = false; } $result_object->normalize_buffer_values($normalize_against); } if ($result_file != null) { // Cache the redundant words on identifiers so it's not re-computed on every graph static $redundant_word_cache; if (!isset($redundant_word_cache[$result_file->get_title()])) { $redundant_word_cache[$result_file->get_title()] = pts_render::evaluate_redundant_identifier_words($result_file->get_system_identifiers()); } if ($redundant_word_cache[$result_file->get_title()]) { $result_object->test_result_buffer->auto_shorten_buffer_identifiers($redundant_word_cache[$result_file->get_title()]); } // COMPACT PROCESS if (!isset($extra_attributes['compact_to_scalar']) && $result_object->test_profile->get_display_format() == 'LINE_GRAPH' && $result_file->get_system_count() > 10) { // If there's too many lines being plotted on line graph, likely to look messy, so convert to scalar automatically $extra_attributes['compact_to_scalar'] = true; } // XXX: removed || $result_file->is_results_tracker() from below and should be added // Removing the command fixes cases like: 1210053-BY-MYRESULTS43 $result_identifiers = $result_object->test_result_buffer->get_identifiers(); if ($result_file->is_multi_way_comparison($result_identifiers, $extra_attributes) || isset($extra_attributes['compact_to_scalar']) || isset($extra_attributes['compact_scatter'])) { if ((isset($extra_attributes['compact_to_scalar']) || false && $result_file->is_multi_way_comparison($result_identifiers, $extra_attributes)) && in_array($result_object->test_profile->get_display_format(), array('FILLED_LINE_GRAPH'))) { // Convert multi-way line graph into horizontal box plot if (true) { $result_object->test_profile->set_display_format('HORIZONTAL_BOX_PLOT'); } /* else // XXX commented out during PTS 6.0 development, TODO decide if to delete { // Turn a multi-way line graph into an averaged bar graph $buffer_items = $result_object->test_result_buffer->get_buffer_items(); $result_object->test_result_buffer = new pts_test_result_buffer(); foreach($buffer_items as $buffer_item) { $values = pts_strings::comma_explode($buffer_item->get_result_value()); $avg_value = pts_math::set_precision(array_sum($values) / count($values), 2); $j = null; if(count($values) > 2) { $j['min-result'] = min($values); $j['max-result'] = max($values); if($j['min-result'] == $j['max-result']) { $json = null; } } $result_object->test_result_buffer->add_test_result($buffer_item->get_result_identifier(), $avg_value, null, $j, $j['min-result'], $j['max-result']); } $result_object->test_profile->set_display_format('BAR_GRAPH'); } */ } if ($result_object->test_profile->get_display_format() != 'PIE_CHART') { $result_table = false; pts_render::compact_result_file_test_object($result_object, $result_table, $result_file, $extra_attributes); } } else { if (in_array($result_object->test_profile->get_display_format(), array('LINE_GRAPH'))) { // Check to see for line graphs if every result is an array of the same result (i.e. a flat line for every result). // If all the results are just flat lines, you might as well convert it to a bar graph $buffer_items = $result_object->test_result_buffer->get_buffer_items(); $all_values_are_flat = false; $flat_values = array(); foreach ($buffer_items as $i => $buffer_item) { $unique_in_buffer = array_unique(explode(',', $buffer_item->get_result_value())); $all_values_are_flat = count($unique_in_buffer) == 1; if ($all_values_are_flat == false) { break; } $flat_values[$i] = array_pop($unique_in_buffer); } if ($all_values_are_flat) { $result_object->test_result_buffer = new pts_test_result_buffer(); foreach ($buffer_items as $i => $buffer_item) { $result_object->test_result_buffer->add_test_result($buffer_item->get_result_identifier(), $flat_values[$i]); } $result_object->test_profile->set_display_format('BAR_GRAPH'); } } } } $display_format = $result_object->test_profile->get_display_format(); $bar_orientation = 'HORIZONTAL'; // default to horizontal bar graph switch ($display_format) { case 'LINE_GRAPH': if (false && $result_object->test_result_buffer->get_count() > 5) { // If there's too many lines close to each other, it's likely to look cluttered so turn it into horizontal range bar / box chart graph $display_format = 'HORIZONTAL_BOX_PLOT'; $graph = new pts_HorizontalBoxPlotGraph($result_object, $result_file); } else { $graph = new pts_LineGraph($result_object, $result_file); } break; case 'HORIZONTAL_BOX_PLOT': $graph = new pts_HorizontalBoxPlotGraph($result_object, $result_file); break; case 'BAR_ANALYZE_GRAPH': case 'BAR_GRAPH': if ($bar_orientation == 'VERTICAL') { $graph = new pts_VerticalBarGraph($result_object, $result_file); } else { $graph = new pts_HorizontalBarGraph($result_object, $result_file); } break; case 'PASS_FAIL': $graph = new pts_PassFailGraph($result_object, $result_file); break; case 'MULTI_PASS_FAIL': $graph = new pts_MultiPassFailGraph($result_object, $result_file); break; case 'TEST_COUNT_PASS': $graph = new pts_TestCountPassGraph($result_object, $result_file); break; case 'PIE_CHART': $graph = new pts_PieChart($result_object, $result_file); break; case 'IMAGE_COMPARISON': $graph = new pts_ImageComparisonGraph($result_object, $result_file); break; case 'SCATTER_PLOT': $graph = new pts_ScatterPlot($result_object, $result_file); break; default: if (isset($extra_attributes['graph_render_type'])) { $requested_graph_type = $extra_attributes['graph_render_type']; } else { if (defined('GRAPH_RENDER_TYPE')) { $requested_graph_type = GRAPH_RENDER_TYPE; } else { $requested_graph_type = null; } } switch ($requested_graph_type) { case 'CANDLESTICK': $graph = new pts_CandleStickGraph($result_object, $result_file); break; case 'LINE_GRAPH': $graph = new pts_LineGraph($result_object, $result_file); break; default: if ($bar_orientation == 'VERTICAL') { $graph = new pts_VerticalBarGraph($result_object, $result_file); } else { $graph = new pts_HorizontalBarGraph($result_object, $result_file); } break; } break; } if (isset($extra_attributes['regression_marker_threshold'])) { $graph->markResultRegressions($extra_attributes['regression_marker_threshold']); } if (isset($extra_attributes['set_alternate_view'])) { $graph->setAlternateView($extra_attributes['set_alternate_view']); } if (isset($extra_attributes['sort_result_buffer_values'])) { $result_object->test_result_buffer->buffer_values_sort(); if ($result_object->test_profile->get_result_proportion() == 'HIB') { $result_object->test_result_buffer->buffer_values_reverse(); } } if (isset($extra_attributes['highlight_graph_values'])) { $graph->highlight_values($extra_attributes['highlight_graph_values']); } if (isset($extra_attributes['force_simple_keys'])) { $graph->override_i_value('force_simple_keys', true); } else { if (PTS_IS_CLIENT && pts_client::read_env('GRAPH_HIGHLIGHT') != false) { $graph->highlight_values(pts_strings::comma_explode(pts_client::read_env('GRAPH_HIGHLIGHT'))); } } switch ($display_format) { case 'LINE_GRAPH': if (isset($extra_attributes['no_overview_text']) && $graph instanceof pts_LineGraph) { $graph->plot_overview_text = false; } case 'BAR_ANALYZE_GRAPH': case 'SCATTER_PLOT': //$graph->hideGraphIdentifiers(); foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) { $graph->loadGraphValues(pts_strings::comma_explode($buffer_item->get_result_value()), $buffer_item->get_result_identifier()); $graph->loadGraphRawValues(pts_strings::comma_explode($buffer_item->get_result_raw())); } $scale_special = $result_object->test_profile->get_result_scale_offset(); if (!empty($scale_special) && count($ss = pts_strings::comma_explode($scale_special)) > 0) { $graph->loadGraphIdentifiers($ss); } break; case 'HORIZONTAL_BOX_PLOT': // TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph $identifiers = array(); $values = array(); foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) { array_push($identifiers, $buffer_item->get_result_identifier()); array_push($values, pts_strings::comma_explode($buffer_item->get_result_value())); } $graph->loadGraphIdentifiers($identifiers); $graph->loadGraphValues($values); break; default: // TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph $identifiers = array(); $values = array(); $raw_values = array(); foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) { array_push($identifiers, $buffer_item->get_result_identifier()); array_push($values, $buffer_item->get_result_value()); array_push($raw_values, $buffer_item->get_result_raw()); } $graph->loadGraphIdentifiers($identifiers); $graph->loadGraphValues($values); $graph->loadGraphRawValues($raw_values); break; } self::report_test_notes_to_graph($graph, $result_object); return $graph; }
public static function render_graph_process(&$result_object, &$result_file = null, $save_as = false, $extra_attributes = null) { if (isset($extra_attributes['sort_result_buffer'])) { $result_object->test_result_buffer->sort_buffer_items(); } if (isset($extra_attributes['reverse_result_buffer'])) { $result_object->test_result_buffer->buffer_values_reverse(); } if (isset($extra_attributes['normalize_result_buffer'])) { if (isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1) { $normalize_against = $extra_attributes['highlight_graph_values'][0]; } else { $normalize_against = false; } $result_object->normalize_buffer_values($normalize_against); } if ($result_file != null) { // Cache the redundant words on identifiers so it's not re-computed on every graph static $redundant_word_cache; if (!isset($redundant_word_cache[$result_file->get_title()])) { $redundant_word_cache[$result_file->get_title()] = pts_render::evaluate_redundant_identifier_words($result_file->get_system_identifiers()); } if ($redundant_word_cache[$result_file->get_title()]) { $result_object->test_result_buffer->auto_shorten_buffer_identifiers($redundant_word_cache[$result_file->get_title()]); } } self::multi_way_compact($result_file, $result_object, $extra_attributes); $display_format = $result_object->test_profile->get_display_format(); $bar_orientation = 'HORIZONTAL'; // default to horizontal bar graph switch ($display_format) { case 'LINE_GRAPH': if (false && $result_object->test_result_buffer->get_count() > 5) { // If there's too many lines close to each other, it's likely to look cluttered so turn it into horizontal range bar / box chart graph $display_format = 'HORIZONTAL_BOX_PLOT'; $graph = new pts_HorizontalBoxPlotGraph($result_object, $result_file); } else { $graph = new pts_LineGraph($result_object, $result_file); } break; case 'HORIZONTAL_BOX_PLOT': $graph = new pts_HorizontalBoxPlotGraph($result_object, $result_file); break; case 'BAR_ANALYZE_GRAPH': case 'BAR_GRAPH': if ($bar_orientation == 'VERTICAL') { $graph = new pts_VerticalBarGraph($result_object, $result_file); } else { $graph = new pts_HorizontalBarGraph($result_object, $result_file); } break; case 'PASS_FAIL': $graph = new pts_PassFailGraph($result_object, $result_file); break; case 'MULTI_PASS_FAIL': $graph = new pts_MultiPassFailGraph($result_object, $result_file); break; case 'TEST_COUNT_PASS': $graph = new pts_TestCountPassGraph($result_object, $result_file); break; case 'PIE_CHART': $graph = new pts_PieChart($result_object, $result_file); break; case 'IMAGE_COMPARISON': $graph = new pts_ImageComparisonGraph($result_object, $result_file); break; case 'FILLED_LINE_GRAPH': $graph = new pts_FilledLineGraph($result_object, $result_file); break; case 'SCATTER_PLOT': $graph = new pts_ScatterPlot($result_object, $result_file); break; default: if (isset($extra_attributes['graph_render_type'])) { $requested_graph_type = $extra_attributes['graph_render_type']; } else { if (defined('GRAPH_RENDER_TYPE')) { $requested_graph_type = GRAPH_RENDER_TYPE; } else { $requested_graph_type = null; } } switch ($requested_graph_type) { case 'CANDLESTICK': $graph = new pts_CandleStickGraph($result_object, $result_file); break; case 'LINE_GRAPH': $graph = new pts_LineGraph($result_object, $result_file); break; case 'FILLED_LINE_GRAPH': $graph = new pts_FilledLineGraph($result_object, $result_file); break; default: if ($bar_orientation == 'VERTICAL') { $graph = new pts_VerticalBarGraph($result_object, $result_file); } else { $graph = new pts_HorizontalBarGraph($result_object, $result_file); } break; } break; } if (isset($extra_attributes['regression_marker_threshold'])) { $graph->markResultRegressions($extra_attributes['regression_marker_threshold']); } if (isset($extra_attributes['set_alternate_view'])) { $graph->setAlternateView($extra_attributes['set_alternate_view']); } if (isset($extra_attributes['sort_result_buffer_values'])) { $result_object->test_result_buffer->buffer_values_sort(); if ($result_object->test_profile->get_result_proportion() == 'HIB') { $result_object->test_result_buffer->buffer_values_reverse(); } } if (isset($extra_attributes['highlight_graph_values'])) { $graph->highlight_values($extra_attributes['highlight_graph_values']); } if (isset($extra_attributes['force_simple_keys'])) { $graph->override_i_value('force_simple_keys', true); } else { if (PTS_IS_CLIENT && pts_client::read_env('GRAPH_HIGHLIGHT') != false) { $graph->highlight_values(pts_strings::comma_explode(pts_client::read_env('GRAPH_HIGHLIGHT'))); } } switch ($display_format) { case 'LINE_GRAPH': if (isset($extra_attributes['no_overview_text']) && $graph instanceof pts_LineGraph) { $graph->plot_overview_text = false; } case 'FILLED_LINE_GRAPH': case 'BAR_ANALYZE_GRAPH': case 'SCATTER_PLOT': //$graph->hideGraphIdentifiers(); foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) { $graph->loadGraphValues(pts_strings::comma_explode($buffer_item->get_result_value()), $buffer_item->get_result_identifier()); $graph->loadGraphRawValues(pts_strings::comma_explode($buffer_item->get_result_raw())); } $scale_special = $result_object->test_profile->get_result_scale_offset(); if (!empty($scale_special) && count($ss = pts_strings::comma_explode($scale_special)) > 0) { $graph->loadGraphIdentifiers($ss); } break; case 'HORIZONTAL_BOX_PLOT': // TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph $identifiers = array(); $values = array(); foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) { array_push($identifiers, $buffer_item->get_result_identifier()); array_push($values, pts_strings::comma_explode($buffer_item->get_result_value())); } $graph->loadGraphIdentifiers($identifiers); $graph->loadGraphValues($values); break; default: // TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph $identifiers = array(); $values = array(); $raw_values = array(); foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) { array_push($identifiers, $buffer_item->get_result_identifier()); array_push($values, $buffer_item->get_result_value()); array_push($raw_values, $buffer_item->get_result_raw()); } $graph->loadGraphIdentifiers($identifiers); $graph->loadGraphValues($values); $graph->loadGraphRawValues($raw_values); break; } self::report_test_notes_to_graph($graph, $result_object); return $graph; }
public function read_sensor() { // Graphics processor real/current frequency $show_memory = false; $core_freq = 0; $mem_freq = 0; if (phodevi::is_nvidia_graphics()) { $nv_freq = phodevi_parser::read_nvidia_extension('GPUCurrentClockFreqs'); $nv_freq = pts_strings::comma_explode($nv_freq); $core_freq = isset($nv_freq[0]) ? $nv_freq[0] : 0; $mem_freq = isset($nv_freq[1]) ? $nv_freq[1] : 0; } else { if (phodevi::is_ati_graphics() && phodevi::is_linux()) { $od_clocks = phodevi_linux_parser::read_ati_overdrive('CurrentClocks'); if (is_array($od_clocks) && count($od_clocks) >= 2) { $core_freq = array_shift($od_clocks); $mem_freq = array_pop($od_clocks); } } else { if (phodevi::is_linux()) { if (isset(phodevi::$vfs->radeon_pm_info)) { // radeon_pm_info should be present with Linux 2.6.34+ foreach (pts_strings::trim_explode("\n", phodevi::$vfs->radeon_pm_info) as $pm_line) { $pm_line = pts_strings::colon_explode($pm_line); if (isset($pm_line[1])) { list($descriptor, $value) = $pm_line; } else { continue; } switch ($descriptor) { case 'current engine clock': $core_freq = pts_arrays::first_element(explode(' ', $value)) / 1000; break; case 'current memory clock': $mem_freq = pts_arrays::first_element(explode(' ', $value)) / 1000; break; } } if ($core_freq == null && ($x = strpos(phodevi::$vfs->radeon_pm_info, 'sclk: '))) { $x = substr(phodevi::$vfs->radeon_pm_info, $x + strlen('sclk: ')); $x = substr($x, 0, strpos($x, ' ')); if (is_numeric($x)) { if ($x > 1000) { $x = $x / 100; } $core_freq = $x; } } if ($mem_freq == null && ($x = strpos(phodevi::$vfs->radeon_pm_info, 'mclk: '))) { $x = substr(phodevi::$vfs->radeon_pm_info, $x + strlen('mclk: ')); $x = substr($x, 0, strpos($x, ' ')); if (is_numeric($x)) { if ($x > 1000) { $x = $x / 100; } $mem_freq = $x; } } } else { if (is_file('/sys/class/drm/card0/gt_cur_freq_mhz')) { $gt_cur_freq_mhz = pts_file_io::file_get_contents('/sys/class/drm/card0/gt_cur_freq_mhz'); if ($gt_cur_freq_mhz > 2) { $core_freq = $gt_cur_freq_mhz; } } else { if (is_file('/sys/class/drm/card0/device/performance_level')) { $performance_level = pts_file_io::file_get_contents('/sys/class/drm/card0/device/performance_level'); $performance_level = explode(' ', $performance_level); $core_string = array_search('core', $performance_level); if ($core_string !== false && isset($performance_level[$core_string + 1])) { $core_string = str_ireplace('MHz', null, $performance_level[$core_string + 1]); if (is_numeric($core_string) && $core_string > $core_freq) { $core_freq = $core_string; } } $mem_string = array_search('memory', $performance_level); if ($mem_string !== false && isset($performance_level[$mem_string + 1])) { $mem_string = str_ireplace('MHz', null, $performance_level[$mem_string + 1]); if (is_numeric($mem_string) && $mem_string > $mem_freq) { $mem_freq = $mem_string; } } } else { if (isset(phodevi::$vfs->i915_cur_delayinfo)) { $i915_cur_delayinfo = phodevi::$vfs->i915_cur_delayinfo; $cagf = strpos($i915_cur_delayinfo, 'CAGF: '); if ($cagf !== false) { $cagf_mhz = substr($i915_cur_delayinfo, $cagf + 6); $cagf_mhz = substr($cagf_mhz, 0, strpos($cagf_mhz, 'MHz')); if (is_numeric($cagf_mhz)) { $core_freq = $cagf_mhz; } } } } } } } } } if (!is_numeric($core_freq)) { $core_freq = 0; } if (!is_numeric($mem_freq)) { $mem_freq = 0; } if ($core_freq == 0 && $mem_freq == 0) { $show_memory = false; $core_freq = -1; } return $show_memory ? array($core_freq, $mem_freq) : $core_freq; }
public static function monitor_count() { // Report number of connected/enabled monitors $monitor_count = 0; // First try reading number of monitors from xdpyinfo $monitor_count = count(phodevi_parser::read_xdpy_monitor_info()); if ($monitor_count == 0) { // Fallback support for ATI and NVIDIA if phodevi_parser::read_xdpy_monitor_info() fails if (phodevi::is_nvidia_graphics()) { $enabled_displays = phodevi_parser::read_nvidia_extension('EnabledDisplays'); switch ($enabled_displays) { case '0x00010000': $monitor_count = 1; break; case '0x00010001': $monitor_count = 2; break; default: $monitor_count = 1; break; } } else { if (phodevi::is_ati_graphics() && phodevi::is_linux()) { $amdpcsdb_enabled_monitors = phodevi_linux_parser::read_amd_pcsdb('SYSTEM/BUSID-*/DDX,EnableMonitor'); $amdpcsdb_enabled_monitors = pts_arrays::to_array($amdpcsdb_enabled_monitors); foreach ($amdpcsdb_enabled_monitors as $enabled_monitor) { foreach (pts_strings::comma_explode($enabled_monitor) as $monitor_connection) { $monitor_count++; } } } else { $monitor_count = 1; } } } return $monitor_count; }
public static function gpu_stock_frequency() { // Graphics processor stock frequency $core_freq = 0; $mem_freq = 0; if (phodevi::is_nvidia_graphics() && phodevi::is_macosx() == false) { // GPUDefault3DClockFreqs is the default and does not show under/over-clocking $clock_freqs_3d = pts_strings::comma_explode(phodevi_parser::read_nvidia_extension('GPU3DClockFreqs')); $clock_freqs_current = pts_strings::comma_explode(phodevi_parser::read_nvidia_extension('GPUCurrentClockFreqs')); if (is_array($clock_freqs_3d) && isset($clock_freqs_3d[1])) { list($core_freq, $mem_freq) = $clock_freqs_3d; } if (is_array($clock_freqs_current) && isset($clock_freqs_current[1])) { $core_freq = max($core_freq, $clock_freqs_current[0]); $mem_freq = max($mem_freq, $clock_freqs_current[1]); } } else { if (phodevi::is_ati_graphics() && phodevi::is_linux()) { $od_clocks = phodevi_linux_parser::read_ati_overdrive('CurrentPeak'); if (is_array($od_clocks) && count($od_clocks) >= 2) { list($core_freq, $mem_freq) = $od_clocks; } } else { if (phodevi::is_linux()) { $display_driver = phodevi::read_property('system', 'display-driver'); switch ($display_driver) { case '': case 'nouveau': if (is_file('/sys/class/drm/card0/device/performance_level')) { /* EXAMPLE OUTPUTS: memory 1000MHz core 500MHz voltage 1300mV fanspeed 100% 3: memory 333MHz core 500MHz shader 1250MHz fanspeed 100% c: memory 333MHz core 500MHz shader 1250MHz */ $performance_level = pts_file_io::file_get_contents('/sys/class/drm/card0/device/performance_level'); $performance_level = explode(' ', $performance_level); $core_string = array_search('core', $performance_level); if ($core_string !== false && isset($performance_level[$core_string + 1])) { $core_string = str_ireplace('MHz', null, $performance_level[$core_string + 1]); if (is_numeric($core_string)) { $core_freq = $core_string; } } $mem_string = array_search('memory', $performance_level); if ($mem_string !== false && isset($performance_level[$mem_string + 1])) { $mem_string = str_ireplace('MHz', null, $performance_level[$mem_string + 1]); if (is_numeric($mem_string)) { $mem_freq = $mem_string; } } } else { if (is_file('/sys/class/drm/card0/device/pstate')) { // pstate is present with Linux 3.13 as the new performance states on Fermi/Kepler $performance_state = pts_file_io::file_get_contents('/sys/class/drm/card0/device/pstate'); $performance_level = substr($performance_state, 0, strpos($performance_state, ' *')); if ($performance_level == null) { // Method for Linux 3.17+ $performance_level = substr($performance_state, strpos($performance_state, 'AC: ') + 4); if ($t = strpos($performance_level, PHP_EOL)) { $performance_level = substr($performance_level, 0, $t); } } else { // Method for Linux ~3.13 through Linux 3.16 $performance_level = substr($performance_level, strrpos($performance_level, ': ') + 2); } $performance_level = explode(' ', $performance_level); $core_string = array_search('core', $performance_level); if ($core_string !== false && isset($performance_level[$core_string + 1])) { $core_string = str_ireplace('MHz', null, $performance_level[$core_string + 1]); if (strpos($core_string, '-') !== false) { // to work around a range of values, e.g. // 0a: core 405-1032 MHz memory 1620 MHz AC DC * $core_string = max(explode('-', $core_string)); } if (is_numeric($core_string)) { $core_freq = $core_string; } } $mem_string = array_search('memory', $performance_level); if ($mem_string !== false && isset($performance_level[$mem_string + 1])) { $mem_string = str_ireplace('MHz', null, $performance_level[$mem_string + 1]); if (strpos($mem_string, '-') !== false) { // to work around a range of values, e.g. // 0a: core 405-1032 MHz memory 1620 MHz AC DC * $mem_string = max(explode('-', $mem_string)); } if (is_numeric($mem_string)) { $mem_freq = $mem_string; } } } } if ($display_driver != null) { break; } case 'radeon': if (isset(phodevi::$vfs->radeon_pm_info)) { // radeon_pm_info should be present with Linux 2.6.34+ but was changed with Linux 3.11 Radeon DPM if (stripos(phodevi::$vfs->radeon_pm_info, 'default')) { foreach (pts_strings::trim_explode("\n", phodevi::$vfs->radeon_pm_info) as $pm_line) { if ($pm_line == null) { continue; } list($descriptor, $value) = pts_strings::colon_explode($pm_line); switch ($descriptor) { case 'default engine clock': $core_freq = pts_arrays::first_element(explode(' ', $value)) / 1000; break; case 'default memory clock': $mem_freq = pts_arrays::first_element(explode(' ', $value)) / 1000; break; } } } if ($core_freq == 0 && ($x = stripos(phodevi::$vfs->radeon_pm_info, 'sclk: ')) != false) { $x = substr(phodevi::$vfs->radeon_pm_info, $x + strlen('sclk: ')); $x = substr($x, 0, strpos($x, ' ')); if (is_numeric($x) && $x > 100) { if ($x > 10000) { $x = $x / 100; } $core_freq = $x; } if (($x = stripos(phodevi::$vfs->radeon_pm_info, 'mclk: ')) != false) { $x = substr(phodevi::$vfs->radeon_pm_info, $x + strlen('mclk: ')); $x = substr($x, 0, strpos($x, ' ')); if (is_numeric($x) && $x > 100) { if ($x > 10000) { $x = $x / 100; } $mem_freq = $x; } } } } if ($core_freq == null) { // Attempt to read the LAST power level reported to dmesg, this is the current way for Radeon DPM on Linux 3.11+ $dmesg_parse = isset(phodevi::$vfs->dmesg) ? phodevi::$vfs->dmesg : null; if ($x = strrpos($dmesg_parse, ' sclk:')) { $dmesg_parse = substr($dmesg_parse, $x); $dmesg_parse = explode(' ', substr($dmesg_parse, 0, strpos($dmesg_parse, PHP_EOL))); $sclk = array_search('sclk:', $dmesg_parse); if ($sclk !== false && isset($dmesg_parse[$sclk + 1]) && is_numeric($dmesg_parse[$sclk + 1])) { $sclk = $dmesg_parse[$sclk + 1]; if ($sclk > 10000) { $sclk = $sclk / 100; } $core_freq = $sclk; } $mclk = array_search('mclk:', $dmesg_parse); if ($mclk !== false && isset($dmesg_parse[$mclk + 1]) && is_numeric($dmesg_parse[$mclk + 1])) { $mclk = $dmesg_parse[$mclk + 1]; if ($mclk > 10000) { $mclk = $mclk / 100; } $mem_freq = $mclk; } } } if ($core_freq == null) { // Old ugly way of handling the clock information $log_parse = isset(phodevi::$vfs->xorg_log) ? phodevi::$vfs->xorg_log : null; if ($engine_clock = strpos($log_parse, 'Default Engine Clock: ')) { $core_freq = substr($log_parse, $engine_clock + 22); $core_freq = substr($core_freq, 0, strpos($core_freq, "\n")); $core_freq = is_numeric($core_freq) ? $core_freq / 1000 : 0; if ($core_freq && ($mem_clock = strpos($log_parse, 'Default Memory Clock: '))) { $mem_freq = substr($log_parse, $mem_clock + 22); $mem_freq = substr($mem_freq, 0, strpos($mem_freq, "\n")); $mem_freq = is_numeric($mem_freq) ? $mem_freq / 1000 : 0; } else { $core_freq = 0; } } } if ($display_driver != null) { break; } case 'intel': // try to read the maximum dynamic frequency if (is_file('/sys/class/drm/card0/gt_max_freq_mhz')) { $gt_max_freq_mhz = pts_file_io::file_get_contents('/sys/class/drm/card0/gt_max_freq_mhz'); if (is_numeric($gt_max_freq_mhz) && $gt_max_freq_mhz > 100) { // Tested on Linux 3.11. Assume the max frequency on any competent GPU is beyond 100MHz $core_freq = $gt_max_freq_mhz; } } if ($core_freq == 0 && is_file('/sys/kernel/debug/dri/0/i915_max_freq')) { $i915_max_freq = pts_file_io::file_get_contents('/sys/kernel/debug/dri/0/i915_max_freq'); $freq_mhz = substr($i915_max_freq, strpos($i915_max_freq, ': ') + 2); if (is_numeric($freq_mhz)) { $core_freq = $freq_mhz; } } // Fallback to base frequency if ($core_freq == 0 && isset(phodevi::$vfs->i915_cur_delayinfo)) { $i915_cur_delayinfo = phodevi::$vfs->i915_cur_delayinfo; $freq = strpos($i915_cur_delayinfo, 'Max overclocked frequency: '); if ($freq === false) { $freq = strpos($i915_cur_delayinfo, 'Max non-overclocked (RP0) frequency: '); } if ($freq === false) { $freq = strpos($i915_cur_delayinfo, 'Nominal (RP1) frequency: '); } if ($freq !== false) { $freq_mhz = substr($i915_cur_delayinfo, strpos($i915_cur_delayinfo, ': ', $freq) + 2); $freq_mhz = trim(substr($freq_mhz, 0, strpos($freq_mhz, 'MHz'))); if (is_numeric($freq_mhz)) { $core_freq = $freq_mhz; } } } if ($display_driver != null) { break; } } } } } $core_freq = !is_numeric($core_freq) ? 0 : round($core_freq); $mem_freq = !is_numeric($mem_freq) ? 0 : round($mem_freq); return array($core_freq, $mem_freq); }
public function get_supported_architectures() { return pts_strings::comma_explode($this->xml_parser->getXMLValue('PhoronixTestSuite/TestProfile/SupportedArchitectures')); }
public function get_supported_architectures() { return pts_strings::comma_explode($this->xg('TestProfile/SupportedArchitectures')); }
public static function result_file_to_result_table(&$result_file, &$system_id_keys = null, &$result_object_index = -1, &$flag_delta_results = false, $extra_attributes = null) { $result_table = array(); $result_tests = array(); $result_counter = 0; foreach ($result_file->get_system_identifiers() as $sys_identifier) { $result_table[$sys_identifier] = null; } foreach ($result_file->get_result_objects($result_object_index) as $ri => $result_object) { if ($result_object->test_profile->get_identifier() == null) { continue; } if ($extra_attributes != null) { if (isset($extra_attributes['reverse_result_buffer'])) { $result_object->test_result_buffer->buffer_values_reverse(); } if (isset($extra_attributes['normalize_result_buffer'])) { if (isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1) { $normalize_against = $extra_attributes['highlight_graph_values'][0]; } else { $normalize_against = false; } $result_object->normalize_buffer_values($normalize_against); } } if ($result_object_index != -1) { if (is_array($result_object_index)) { $result_tests[$result_counter] = new pts_graph_ir_value($result_object->get_arguments_description()); } else { $result_tests[$result_counter] = new pts_graph_ir_value('Results'); } } else { $result_tests[$result_counter] = new pts_graph_ir_value($result_object->test_profile->get_title()); $result_tests[$result_counter]->set_attribute('title', $result_object->get_arguments_description()); if ($result_object->test_profile->get_identifier() != null) { $result_tests[$result_counter]->set_attribute('href', 'http://openbenchmarking.org/test/' . $result_object->test_profile->get_identifier()); } } if ($result_object->test_profile->get_identifier() == null) { if ($result_object->test_profile->get_display_format() == 'BAR_GRAPH') { $result_tests[$result_counter]->set_attribute('alert', true); foreach ($result_object->test_result_buffer->get_buffer_items() as $index => $buffer_item) { $identifier = $buffer_item->get_result_identifier(); $value = $buffer_item->get_result_value(); $result_table[$identifier][$result_counter] = new pts_graph_ir_value($value, array('alert' => true)); } $result_counter++; } continue; } switch ($result_object->test_profile->get_display_format()) { case 'BAR_GRAPH': $best_value = 0; $worst_value = 0; if (!defined('PHOROMATIC_TRACKER') && count($result_object->test_result_buffer->get_values()) > 1) { switch ($result_object->test_profile->get_result_proportion()) { case 'HIB': $best_value = max($result_object->test_result_buffer->get_values()); $worst_value = min($result_object->test_result_buffer->get_values()); break; case 'LIB': $best_value = min($result_object->test_result_buffer->get_values()); $worst_value = max($result_object->test_result_buffer->get_values()); break; } } $prev_value = 0; $prev_identifier = null; $prev_identifier_0 = null; $values_in_buffer = $result_object->test_result_buffer->get_values(); sort($values_in_buffer); $min_value_in_buffer = $values_in_buffer[0]; if ($min_value_in_buffer == 0) { // Go through the values until something not 0, otherwise down in the code will be a divide by zero for ($i = 1; $i < count($values_in_buffer) && $min_value_in_buffer == 0; $i++) { $min_value_in_buffer = $values_in_buffer[$i]; } } $max_value_in_buffer = $values_in_buffer[count($values_in_buffer) - 1]; foreach ($result_object->test_result_buffer->get_buffer_items() as $index => $buffer_item) { $identifier = $buffer_item->get_result_identifier(); $value = $buffer_item->get_result_value(); $raw_values = pts_strings::colon_explode($buffer_item->get_result_raw()); $percent_std = pts_math::set_precision(pts_math::percent_standard_deviation($raw_values), 2); $std_error = pts_math::set_precision(pts_math::standard_error($raw_values), 2); $delta = 0; if (defined('PHOROMATIC_TRACKER')) { $identifier_r = pts_strings::colon_explode($identifier); if ($identifier_r[0] == $prev_identifier_0 && $prev_value != 0) { $delta = pts_math::set_precision(abs(1 - $value / $prev_value), 4); if ($delta > 0.02 && $delta > pts_math::standard_deviation($raw_values)) { switch ($result_object->test_profile->get_result_proportion()) { case 'HIB': if ($value < $prev_value) { $delta = 0 - $delta; } break; case 'LIB': if ($value > $prev_value) { $delta = 0 - $delta; } break; } } else { $delta = 0; } } $prev_identifier_0 = $identifier_r[0]; $highlight = false; $alert = false; } else { if ($result_file->is_multi_way_comparison()) { // TODO: make it work better for highlighting multiple winners in multi-way comparisons $highlight = false; $alert = false; // TODO: get this working right if (false && $index % 2 == 1 && $prev_value != 0) { switch ($result_object->test_profile->get_result_proportion()) { case 'HIB': if ($value > $prev_value) { $highlight = true; } else { $result_table[$prev_identifier][$result_counter]->set_attribute('highlight', true); $result_table[$prev_identifier][$result_counter]->set_attribute('delta', -1); } break; case 'LIB': if ($value < $prev_value) { $highlight = true; } else { $result_table[$prev_identifier][$result_counter]->set_attribute('highlight', true); $result_table[$prev_identifier][$result_counter]->set_attribute('delta', -1); } break; } } } else { $alert = $worst_value == $value; $highlight = $best_value == $value; } if ($min_value_in_buffer != $max_value_in_buffer) { switch ($result_object->test_profile->get_result_proportion()) { case 'HIB': $delta = pts_math::set_precision($value / $min_value_in_buffer, 2); break; case 'LIB': $delta = pts_math::set_precision(1 - $value / $max_value_in_buffer + 1, 2); break; } } } $attributes = array('std_percent' => $percent_std, 'std_error' => $std_error, 'delta' => $delta, 'highlight' => $highlight, 'alert' => $alert); if ($delta > $percent_std && $flag_delta_results !== false) { $flag_delta_results[$ri] = $delta; } $result_table[$identifier][$result_counter] = new pts_graph_ir_value($value, $attributes); $prev_identifier = $identifier; $prev_value = $value; } break; case 'LINE_GRAPH': case 'FILLED_LINE_GRAPH': $result_tests[$result_counter] = new pts_graph_ir_value($result_object->test_profile->get_title() . ' (Avg)'); foreach ($result_object->test_result_buffer->get_buffer_items() as $index => $buffer_item) { $identifier = $buffer_item->get_result_identifier(); $values = pts_strings::comma_explode($buffer_item->get_result_value()); $avg_value = pts_math::set_precision(array_sum($values) / count($values), 2); $result_table[$identifier][$result_counter] = new pts_graph_ir_value($avg_value); } break; } $result_counter++; } if ($result_counter == 1) { // This should provide some additional information under normal modes $has_written_std = false; $has_written_diff = false; $has_written_error = false; foreach ($result_table as $identifier => $info) { if (!isset($info[$result_counter - 1])) { continue; } $std_percent = $info[$result_counter - 1]->get_attribute('std_percent'); $std_error = $info[$result_counter - 1]->get_attribute('std_error'); $delta = $info[$result_counter - 1]->get_attribute('delta'); if ($delta != 0) { $result_table[$identifier][] = new pts_graph_ir_value($delta . 'x'); $has_written_diff = true; } if ($std_error != 0) { $result_table[$identifier][] = new pts_graph_ir_value($std_error); $has_written_error = true; } if ($std_percent != 0) { $result_table[$identifier][] = new pts_graph_ir_value($std_percent . '%'); $has_written_std = true; } } if ($has_written_diff) { $result_tests[] = new pts_graph_ir_value('Difference'); } if ($has_written_error) { $result_tests[] = new pts_graph_ir_value('Standard Error'); } if ($has_written_std) { $result_tests[] = new pts_graph_ir_value('Standard Deviation'); } } if (defined('PHOROMATIC_TRACKER')) { // Resort the results by SYSTEM, then date $systems_table = array(); $sorted_table = array(); foreach ($result_table as $system_identifier => &$identifier_table) { $identifier = pts_strings::colon_explode($system_identifier); if (!isset($systems_table[$identifier[0]])) { $systems_table[$identifier[0]] = array(); } $systems_table[$identifier[0]][$system_identifier] = $identifier_table; } $result_table = array(); $result_systems = array(); foreach ($systems_table as &$group) { foreach ($group as $identifier => $table) { $result_table[$identifier] = $table; $identifier = pts_strings::colon_explode($identifier); $show_id = isset($identifier[1]) ? $identifier[1] : $identifier[0]; /* if($system_id_keys != null && ($s = array_search($identifier[0], $system_id_keys)) !== false) { $system_id = $s; } else { $system_id = null; }*/ $result_systems[] = $show_id; } } } else { $result_systems = array(); foreach (array_keys($result_table) as $id) { $result_systems[] = $id; } } return array($result_tests, $result_systems, $result_table); }
public function parse_selection_choice_input($input, $use_default_on_empty = true) { $return_keys = array(); if ($input === '0') { array_push($return_keys, 0); } else { foreach (pts_strings::comma_explode($input) as $input_choice) { if ($input_choice == $this->option_count() || $input_choice == 'Test All Options') { // Add all options foreach (array_keys($this->options) as $i) { array_push($return_keys, $i); } break; } else { if (($c = $this->is_valid_select_choice($input_choice)) !== false) { array_push($return_keys, $c); } } } } $return_keys = array_unique($return_keys); sort($return_keys); if ($use_default_on_empty && count($return_keys) == 0) { // Use the default as no valid options were presented array_push($return_keys, $this->get_option_default()); } return $return_keys; }
protected function render_graph_passfail() { $identifier_count = $this->test_result->test_result_buffer->get_count(); $vertical_border = 20; $horizontal_border = 14; $heading_height = 24; $graph_width = $this->i['graph_left_end'] - $this->i['left_start'] - $horizontal_border * 2; $graph_height = $this->i['graph_top_end'] - $this->i['top_start'] - $vertical_border * 2 - $heading_height; $line_height = floor($graph_height / $identifier_count); $pass_color = $this->get_paint_color('PASS'); $fail_color = $this->get_paint_color('FAIL'); $main_width = floor($graph_width * 0.24); $main_font_size = self::$c['size']['bars']; $main_greatest_length = $this->test_result->test_result_buffer->get_longest_identifier(); $width = $main_width - 8; $height = $line_height - 4; $main_font_size = $this->text_size_bounds($main_greatest_length, $main_font_size, 4, $width, $height); if (($new_size = $this->text_string_width($main_greatest_length, $main_font_size)) < $main_width - 12) { $main_width = $new_size + 10; } $identifiers_total_width = $graph_width - $main_width - 2; $headings = pts_strings::comma_explode($this->graph_y_title); $identifiers_width = floor($identifiers_total_width / (count($headings) != 0 ? count($headings) : 1)); $headings_font_size = self::$c['size']['bars']; while ($this->text_string_width(pts_strings::find_longest_string($headings), $headings_font_size) > $identifiers_width - 2 || $this->text_string_height($this->i['graph_max_value'], $headings_font_size) > $line_height - 4) { $headings_font_size -= 0.5; } for ($j = 0; $j < $this->test_result->test_result_buffer->get_count(); $j++) { $results = array_reverse(pts_strings::comma_explode($this->test_result->test_result_buffer->buffer_items[$j]->get_result_value())); $line_ttf_height = $this->text_string_height('AZ@![]()@|_', self::$c['size']['bars']); for ($i = 0; $i < count($headings) && $i < count($results); $i++) { $paint_color = $results[$i] == 'PASS' ? $pass_color : $fail_color; $this_bottom_end = $this->i['top_start'] + $vertical_border + ($j + 1) * $line_height + $heading_height + 1; if ($this_bottom_end >= $this->i['graph_top_end'] - $vertical_border) { $this_bottom_end = $this->i['graph_top_end'] - $vertical_border - 1; } else { if ($j == $this->test_result->test_result_buffer->get_count() - 1 && $this_bottom_end < $this->i['graph_top_end'] - $vertical_border) { $this_bottom_end = $this->i['graph_top_end'] - $vertical_border - 1; } } $x = $this->i['graph_left_end'] - $horizontal_border - $i * $identifiers_width; $y = $this->i['top_start'] + $vertical_border + $j * $line_height + $heading_height; $this->svg_dom->add_element('rect', array('x' => $x - $identifiers_width, 'y' => $y, 'width' => $identifiers_width, 'height' => $this_bottom_end - $y, 'fill' => $paint_color, 'stroke' => self::$c['color']['border'], 'stroke-width' => 1)); $x = $this->i['graph_left_end'] - $horizontal_border - $i * $identifiers_width - $identifiers_width * 0.5; $y = $this->i['top_start'] + $vertical_border + $j * $line_height + $heading_height + $line_height / 2 - $line_ttf_height / 2; $this->svg_dom->add_text_element($results[$i], array('x' => $x, 'y' => $y, 'font-size' => self::$c['size']['bars'], 'fill' => self::$c['color']['body_text'], 'text-anchor' => 'middle', 'dominant-baseline' => 'text-before-edge')); } } $headings = array_reverse($headings); $line_ttf_height = $this->text_string_height('AZ@![]()@|_', $headings_font_size); for ($i = 0; $i < count($headings); $i++) { $this->svg_dom->draw_svg_line($this->i['graph_left_end'] - $horizontal_border - ($i + 1) * $identifiers_width, $this->i['top_start'] + $vertical_border, $this->i['graph_left_end'] - $horizontal_border - ($i + 1) * $identifiers_width, $this->i['graph_top_end'] - $vertical_border, self::$c['color']['body_light']); $x = $this->i['graph_left_end'] - $horizontal_border - $i * $identifiers_width - 0.5 * $identifiers_width; $y = $this->i['top_start'] + $vertical_border + $heading_height / 2 - $line_ttf_height / 2; $this->svg_dom->add_text_element($headings[$i], array('x' => $x, 'y' => $y, 'font-size' => $headings_font_size, 'fill' => self::$c['color']['headers'], 'text-anchor' => 'middle', 'dominant-baseline' => 'text-before-edge')); } $line_ttf_height = $this->text_string_height('AZ@![]()@|_', $main_font_size); for ($i = 0; $i < $this->test_result->test_result_buffer->get_count(); $i++) { $this->svg_dom->draw_svg_line($this->i['left_start'] + $horizontal_border, $this->i['top_start'] + $vertical_border + $i * $line_height + $heading_height, $this->i['graph_left_end'] - $horizontal_border, $this->i['top_start'] + $vertical_border + $i * $line_height + $heading_height, self::$c['color']['body_light']); $x = $this->i['left_start'] + $horizontal_border + $main_width; $y = $this->i['top_start'] + $vertical_border + $i * $line_height + $heading_height + $line_height / 2 - 2; $this->svg_dom->add_text_element($this->test_result->test_result_buffer->buffer_items[$i]->get_result_identifier(), array('x' => $x, 'y' => $y, 'font-size' => $main_font_size, 'fill' => self::$c['color']['headers'], 'text-anchor' => 'end', 'dominant-baseline' => 'middle')); } $this->svg_dom->draw_svg_line($this->i['left_start'] + $horizontal_border, $this->i['top_start'] + $vertical_border, $this->i['graph_left_end'] - $horizontal_border, $this->i['top_start'] + $vertical_border, self::$c['color']['body_light']); $this->svg_dom->draw_svg_line($this->i['left_start'] + $horizontal_border, $this->i['top_start'] + $vertical_border, $this->i['left_start'] + $horizontal_border, $this->i['graph_top_end'] - $vertical_border, self::$c['color']['body_light']); $this->svg_dom->draw_svg_line($this->i['graph_left_end'] - $horizontal_border, $this->i['top_start'] + $vertical_border, $this->i['graph_left_end'] - $horizontal_border, $this->i['graph_top_end'] - $vertical_border, self::$c['color']['body_light']); $this->svg_dom->draw_svg_line($this->i['left_start'] + $horizontal_border, $this->i['graph_top_end'] - $vertical_border, $this->i['graph_left_end'] - $horizontal_border, $this->i['graph_top_end'] - $vertical_border, self::$c['color']['body_light']); }
private static function file_missing_check($file_arr) { // Checks if file is missing $file_missing = false; if (!is_array($file_arr)) { $file_arr = pts_strings::comma_explode($file_arr); } foreach ($file_arr as $file) { $file_is_there = false; $file = explode('OR', $file); for ($i = 0; $i < count($file) && $file_is_there == false; $i++) { $file[$i] = trim($file[$i]); if (is_file($file[$i]) || is_dir($file[$i]) || is_link($file[$i])) { $file_is_there = true; } else { if (isset($file[$i][1]) && $file[$i][0] != '/') { // See if it's some relative command/path if (substr($file[$i], -2) == '.h' || substr($file[$i], -4) == '.hpp') { // May just be a relative header file to look for... $possible_paths = array('/usr/local/include', '/usr/target/include/', '/usr/include/'); foreach ($possible_paths as $path) { if (is_file($path . $file[$i]) || is_link($path . $file[$i])) { $file_is_there = true; } } } else { if (strpos($file[$i], '.so') !== false || substr($file[$i], -2) == '.a') { // May just be a relative shared library to look for... $possible_paths = array('/usr/local/lib/', '/usr/lib/', '/usr/lib64/', '/usr/lib/x86_64-linux-gnu/', '/usr/lib/i386-linux-gnu/', '/usr/lib/arm-linux-gnueabihf/'); if (getenv('LD_LIBRARY_PATH')) { foreach (explode(':', getenv('LD_LIBRARY_PATH')) as $path) { array_push($possible_paths, $path . '/'); } } foreach ($possible_paths as $path) { if (is_file($path . $file[$i]) || is_link($path . $file[$i])) { $file_is_there = true; } } } else { if (strpos($file[$i], '/') === false) { // May just be a command to look for... $possible_paths = array('/usr/local/bin/', '/usr/bin/'); if (getenv('PATH')) { foreach (explode(':', getenv('PATH')) as $path) { array_push($possible_paths, $path . '/'); } } foreach ($possible_paths as $path) { if (is_file($path . $file[$i]) || is_link($path . $file[$i])) { $file_is_there = true; } } } } } } } } $file_missing = $file_missing || !$file_is_there; } return $file_missing; }
public function __construct(&$result_object = null, &$result_file = null, $extra_attributes = null) { // Initalize Colors $this->i['identifier_size'] = self::$c['size']['identifiers']; // Copy this since it's commonly overwritten $this->i['graph_orientation'] = 'VERTICAL'; $this->i['graph_value_type'] = 'NUMERICAL'; $this->i['hide_graph_identifiers'] = false; $this->i['show_graph_key'] = false; $this->i['show_background_lines'] = false; $this->i['iveland_view'] = false; $this->i['graph_max_value_multiplier'] = 1.285; $this->i['graph_max_value'] = 0; $this->i['bottom_offset'] = 0; $this->i['hide_y_title'] = false; $this->i['compact_result_view'] = false; $this->i['key_line_height'] = 0; $this->i['graph_height'] = 0; $this->i['graph_width'] = 0; $this->i['left_start'] = 10; $this->i['left_end_right'] = 10; $this->i['top_start'] = 62; $this->i['top_end_bottom'] = 22; $this->i['mark_count'] = 6; // Number of marks to make on vertical axis $this->i['notes'] = array(); // Reset of setup besides config if ($result_object != null) { $test_version = $result_object->test_profile->get_app_version(); if (isset($test_version[2]) && is_numeric($test_version[0])) { $test_version = 'v' . $test_version; } $this->graph_title = trim($result_object->test_profile->get_title() . ' ' . $test_version); $this->graph_y_title = $result_object->test_profile->get_result_scale_formatted(); $this->test_identifier = $result_object->test_profile->get_identifier(); $this->i['graph_proportion'] = $result_object->test_profile->get_result_proportion(); $this->addSubTitle($result_object->get_arguments_description()); } $this->update_graph_dimensions(self::$c['graph']['width'], self::$c['graph']['height'], true); if (isset($extra_attributes['force_tracking_line_graph'])) { // Phoromatic result tracker $this->is_multi_way_comparison = true; } else { $this->is_multi_way_comparison = phx_graph_render::multi_way_identifier_check($result_object->test_result_buffer->get_identifiers()); } $this->i['graph_version'] = 'Phoronix Test Suite ' . PTS_VERSION; if (isset($extra_attributes['regression_marker_threshold'])) { $this->d['regression_marker_threshold'] = $extra_attributes['regression_marker_threshold']; } if (isset($extra_attributes['set_alternate_view'])) { $this->d['link_alternate_view'] = $extra_attributes['set_alternate_view']; } if (isset($extra_attributes['highlight_graph_values'])) { $this->value_highlights = $extra_attributes['highlight_graph_values']; } else { if (PTS_IS_CLIENT && pts_client::read_env('GRAPH_HIGHLIGHT') != false) { $this->value_highlights = pts_strings::comma_explode(pts_client::read_env('GRAPH_HIGHLIGHT')); } } if (isset($extra_attributes['force_simple_keys'])) { $this->override_i_value('force_simple_keys', true); } $this->test_result =& $result_object; $this->generate_results_var(); }
public static function module_framework_init() { // Process initially called when PTS starts up // Check for modules to auto-load from the configuration file $load_modules = pts_config::read_user_config('PhoronixTestSuite/Options/Modules/LoadModules', null); if (!empty($load_modules)) { foreach (pts_strings::comma_explode($load_modules) as $module) { $module_r = pts_strings::trim_explode('=', $module); if (count($module_r) == 2) { // TODO: end up hooking this into pts_module::read_variable() rather than using the real env pts_client::set_environment_variable($module_r[0], $module_r[1]); } else { pts_module_manager::attach_module($module); } } } // Check for modules to load manually in PTS_MODULES if (($load_modules = pts_client::read_env('PTS_MODULES')) !== false) { foreach (pts_strings::comma_explode($load_modules) as $module) { if (!pts_module_manager::is_module_attached($module)) { pts_module_manager::attach_module($module); } } } // Detect modules to load automatically pts_module_manager::detect_modules_to_load(); // Clean-up modules list pts_module_manager::clean_module_list(); // Reset counter pts_module_manager::set_current_module(null); // Load the modules $module_store_list = array(); foreach (pts_module_manager::attached_modules() as $module) { $class_vars = get_class_vars($module); $module_store_vars = isset($class_vars['module_store_vars']) ? $class_vars['module_store_vars'] : null; if (is_array($module_store_vars)) { foreach ($module_store_vars as $store_var) { if (!in_array($store_var, $module_store_list)) { array_push($module_store_list, $store_var); } } } } // Should any of the module options be saved to the results? foreach ($module_store_list as $var) { $var_value = pts_client::read_env($var); if (!empty($var_value)) { pts_module_manager::var_store_add($var, $var_value); } } pts_module_manager::module_process('__startup'); pts_define('PTS_STARTUP_TASK_PERFORMED', true); register_shutdown_function(array('pts_module_manager', 'module_process'), '__shutdown'); }
public static function read_amd_pcsdb_direct_parser($attribute, $find_once = false) { // Read AMD's AMDPCSDB, AMD Persistent Configuration Store Database but using our own internal parser instead of relying upon aticonfig/amdconfig $amdpcsdb_file = null; $last_found_section_count = -1; $this_section_count = 0; $attribute_values = array(); $attribute = pts_strings::comma_explode($attribute); if (count($attribute) == 2) { $attribute_prefix = array_reverse(explode('/', $attribute[0])); $attribute_key = $attribute[1]; $is_in_prefix = false; if (is_file('/etc/ati/amdpcsdb')) { $amdpcsdb_file = explode("\n", file_get_contents('/etc/ati/amdpcsdb')); } for ($l = 0; $l < count($amdpcsdb_file) && ($find_once == false || $last_found_section_count == -1); $l++) { $line = trim($amdpcsdb_file[$l]); if (substr($line, 0, 1) == '[' && substr($line, -1) == ']') { // AMDPCSDB Header $prefix_matches = true; $header = array_reverse(explode('/', substr($line, 1, -1))); for ($i = 0; $i < count($attribute_prefix) && $i < count($header) && $prefix_matches; $i++) { if ($attribute_prefix[$i] != $header[$i] && pts_strings::proximity_match($attribute_prefix[$i], $header[$i]) == false) { $prefix_matches = false; } } if ($prefix_matches) { $is_in_prefix = true; $this_section_count++; } else { $is_in_prefix = false; } } else { if ($is_in_prefix && $this_section_count != $last_found_section_count && count($key_components = explode('=', $line)) == 2) { // AMDPCSDB Value if ($key_components[0] == $attribute_key) { $value_type = substr($key_components[1], 0, 1); $value = substr($key_components[1], 1); switch ($value_type) { case 'V': // Value if (is_numeric($value) && strlen($value) < 9) { $value = dechex($value); $value = '0x' . str_repeat(0, 8 - strlen($value)) . strtoupper($value); } break; case 'R': // Raw break; case 'S': // String break; } array_push($attribute_values, $value); $last_found_section_count = $this_section_count; } } } } } if (count($attribute_values) == 0) { $attribute_values = null; } else { if (count($attribute_values) == 1) { $attribute_values = $attribute_values[0]; } } return $attribute_values; }
public static function prompt_text_menu($user_string, $options_r, $allow_multi_select = false, $return_index = false, $line_prefix = null) { $option_count = count($options_r); if ($option_count == 1) { return $return_index ? pts_arrays::last_element(array_keys($options_r)) : array_pop($options_r); } $select = array(); do { echo PHP_EOL; $key_index = array(); foreach (array_keys($options_r) as $i => $key) { $key_index[$i + 1] = $key; echo $line_prefix . ($i + 1) . ': ' . str_repeat(' ', strlen($option_count) - strlen($i + 1)) . $options_r[$key] . PHP_EOL; } echo $line_prefix . $user_string . ': '; $select_choice = pts_user_io::read_user_input(); foreach ($allow_multi_select ? pts_strings::comma_explode($select_choice) : array($select_choice) as $choice) { if (in_array($choice, $options_r)) { $select[] = array_search($choice, $options_r); } else { if (isset($key_index[$choice])) { $select[] = $key_index[$choice]; } else { if ($allow_multi_select && strpos($choice, '-') !== false) { $choice_range = pts_strings::trim_explode('-', $choice); if (count($choice_range) == 2 && is_numeric($choice_range[0]) && is_numeric($choice_range[1]) && isset($key_index[$choice_range[0]]) && isset($key_index[$choice_range[1]])) { for ($i = min($choice_range); $i <= max($choice_range); $i++) { $select[] = $key_index[$i]; } } } } } } } while (!isset($select[0])); if ($return_index == false) { foreach ($select as &$index) { $index = $options_r[$index]; } } return implode(',', $select); }
public static function test_profile_system_compatibility_check(&$test_profile, $report_errors = false) { $valid_test_profile = true; $test_type = $test_profile->get_test_hardware_type(); $skip_tests = pts_client::read_env('SKIP_TESTS') ? pts_strings::comma_explode(pts_client::read_env('SKIP_TESTS')) : false; $skip_test_subsystems = pts_client::read_env('SKIP_TESTING_SUBSYSTEMS') ? pts_strings::comma_explode(strtolower(pts_client::read_env('SKIP_TESTING_SUBSYSTEMS'))) : false; $display_driver = phodevi::read_property('system', 'display-driver'); $gpu = phodevi::read_name('gpu'); if ($test_profile->is_supported(false) == false) { $valid_test_profile = false; } else { if ($test_type == 'Graphics' && pts_client::read_env('DISPLAY') == false && pts_client::read_env('WAYLAND_DISPLAY') == false && phodevi::is_windows() == false && phodevi::is_macosx() == false) { $report_errors && pts_client::$display->test_run_error('No display server was found, cannot run ' . $test_profile); $valid_test_profile = false; } else { if ($test_type == 'Graphics' && in_array($display_driver, array('vesa', 'nv', 'cirrus')) && stripos($gpu, 'LLVM') === false) { // These display drivers end up being in known configurations without 3D hardware support so unless an LLVM-based string is reported as the GPU, don't advertise 3D tests $report_errors && pts_client::$display->test_run_error('3D acceleration support not available, cannot run ' . $test_profile); $valid_test_profile = false; } else { if ($test_type == 'Disk' && stripos(phodevi::read_property('system', 'filesystem'), 'SquashFS') !== false) { $report_errors && pts_client::$display->test_run_error('Running on a RAM-based live file-system, cannot run ' . $test_profile); $valid_test_profile = false; } else { if (pts_client::read_env('NO_' . strtoupper($test_type) . '_TESTS') || $skip_tests && (in_array($test_profile, $skip_tests) || in_array($test_type, $skip_tests) || in_array($test_profile->get_identifier(false), $skip_tests) || in_array($test_profile->get_identifier_base_name(), $skip_tests))) { $report_errors && pts_client::$display->test_run_error('Due to a pre-set environmental variable, skipping ' . $test_profile); $valid_test_profile = false; } else { if ($skip_test_subsystems && in_array(strtolower($test_profile->get_test_hardware_type()), $skip_test_subsystems)) { $report_errors && pts_client::$display->test_run_error('Due to a pre-set environmental variable, skipping ' . $test_profile); $valid_test_profile = false; } else { if ($test_profile->is_root_required() && $this->batch_mode && phodevi::is_root() == false) { $report_errors && pts_client::$display->test_run_error('Cannot run ' . $test_profile . ' in batch mode as root access is required.'); $valid_test_profile = false; } } } } } } } if ($valid_test_profile == false && pts_client::read_env('SKIP_ALL_TEST_SUPPORT_CHECKS')) { $report_errors && pts_client::$display->test_run_error('SKIP_ALL_TEST_SUPPORT_CHECKS is set for ' . $test_profile . '.'); $valid_test_profile = true; } return $valid_test_profile; }