public static function multi_way_compact(&$result_file, &$result_object, $extra_attributes = null) { if ($result_file == null) { return; } 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'])) { 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('LINE_GRAPH', 'FILLED_LINE_GRAPH'))) { // Convert multi-way line graph into horizontal box plot if (stripos($result_object->get_arguments_description(), 'frame time') !== false || true) { $result_object->test_profile->set_display_format('HORIZONTAL_BOX_PLOT'); } else { // 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', 'FILLED_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'); } } } }
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_page_process($PATH) { $main = null; $identifier_item = isset($PATH[1]) ? $PATH[0] . '/' . $PATH[1] : false; if ($identifier_item && pts_test_profile::is_test_profile($identifier_item)) { $tp = new pts_test_profile($identifier_item); $tp_identifier = $tp->get_identifier(false); $main .= '<h1>' . $tp->get_title() . '</h1><p>' . $tp->get_description() . '</p>'; $main .= '<p style="font-size: 90%;"><strong>' . $tp->get_test_hardware_type() . ' - ' . phoromatic_server::test_result_count_for_test_profile($_SESSION['AccountID'], $tp_identifier) . ' Results On This Account - ' . $tp->get_test_software_type() . ' - Maintained By: ' . $tp->get_maintainer() . ' - Supported Platforms: ' . implode(', ', $tp->get_supported_platforms()) . '</strong></p>'; $main .= '<h2>Recent Results With This Test</h2>'; $stmt = phoromatic_server::$db->prepare('SELECT Title, PPRID FROM phoromatic_results WHERE AccountID = :account_id AND UploadID IN (SELECT DISTINCT UploadID FROM phoromatic_results_results WHERE AccountID = :account_id AND TestProfile LIKE :tp) ORDER BY UploadTime DESC LIMIT 30'); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $stmt->bindValue(':tp', $tp_identifier . '%'); $result = $stmt->execute(); $recent_result_count = 0; while ($result && ($row = $result->fetchArray())) { $recent_result_count++; $main .= '<h2><a href="/?result/' . $row['PPRID'] . '">' . $row['Title'] . '</a></h2>'; } if ($recent_result_count > 5) { $stmt = phoromatic_server::$db->prepare('SELECT UploadID, SystemID, UploadTime FROM phoromatic_results WHERE AccountID = :account_id AND UploadID IN (SELECT DISTINCT UploadID FROM phoromatic_results_results WHERE AccountID = :account_id AND TestProfile LIKE :tp) ORDER BY UploadTime DESC LIMIT 1000'); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $stmt->bindValue(':tp', $tp_identifier . '%'); $result = $stmt->execute(); $recent_result_count = 0; $result_file = new pts_result_file(null, true); while ($result && ($row = $result->fetchArray())) { $composite_xml = phoromatic_server::phoromatic_account_result_path($_SESSION['AccountID'], $row['UploadID']) . 'composite.xml'; if (!is_file($composite_xml)) { continue; } // Add to result file $system_name = strtotime($row['UploadTime']) . ': ' . phoromatic_server::system_id_to_name($row['SystemID']); $sub_result_file = new pts_result_file($composite_xml, true); foreach ($sub_result_file->get_result_objects() as $obj) { if ($obj->test_profile->get_identifier(false) == $tp_identifier) { $obj->test_result_buffer->rename(null, $system_name); $result_file->add_result($obj); } } } $table = null; $extra_attributes = array(); $f = false; foreach ($result_file->get_result_objects() as $obj) { $obj->test_profile->set_display_format('SCATTER_PLOT'); foreach ($obj->test_result_buffer->buffer_items as $i => &$item) { if (!is_numeric(substr($item->get_result_identifier(), 0, strpos($item->get_result_identifier(), ':')))) { unset($obj->test_result_buffer->buffer_items[$i]); } } pts_render::compact_result_file_test_object($obj, $table, $f, $extra_attributes); $main .= '<p align="center">' . pts_render::render_graph_inline_embed($obj) . '</p>'; } } } else { $dc = pts_strings::add_trailing_slash(pts_client::parse_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH))); $dc_exists = is_file($dc . 'pts-download-cache.json'); foreach (pts_openbenchmarking::available_tests() as $test) { $cache_checked = false; if ($dc_exists) { $cache_json = file_get_contents($dc . 'pts-download-cache.json'); $cache_json = json_decode($cache_json, true); if ($cache_json && isset($cache_json['phoronix-test-suite']['cached-tests'])) { $cache_checked = true; if (!in_array($test, $cache_json['phoronix-test-suite']['cached-tests'])) { //continue; } } } if (!$cache_checked && phoromatic_server::read_setting('show_local_tests_only') && pts_test_install_request::test_files_in_cache($test, true, true) == false) { continue; } $tp = new pts_test_profile($test); if ($tp->get_title() == null) { continue; } $main .= '<h1 style="margin-bottom: 0;"><a href="/?tests/' . $tp->get_identifier(false) . '">' . $tp->get_title() . '</a></h1>'; $main .= '<p style="font-size: 90%;"><strong>' . $tp->get_test_hardware_type() . '</strong> <em>-</em> ' . phoromatic_server::test_result_count_for_test_profile($_SESSION['AccountID'], $tp->get_identifier(false)) . ' Results On This Account' . ' </p>'; } } echo phoromatic_webui_header_logged_in(); echo '<div id="pts_phoromatic_main_area">' . $main . '</div>'; echo phoromatic_webui_footer(); }