示例#1
0
 public static function generate_result_file_graphs($test_results_identifier, $save_to_dir = false, $extra_attributes = null)
 {
     if ($save_to_dir) {
         if (pts_file_io::mkdir($save_to_dir . '/result-graphs') == false) {
             // Directory must exist, so remove any old graph files first
             foreach (pts_file_io::glob($save_to_dir . '/result-graphs/*') as $old_file) {
                 unlink($old_file);
             }
         }
     }
     if ($test_results_identifier instanceof pts_result_file) {
         $result_file =& $test_results_identifier;
     } else {
         $result_file = new pts_result_file($test_results_identifier);
     }
     $generated_graphs = array();
     $generated_graph_tables = false;
     // Render overview chart
     if ($save_to_dir) {
         $chart = new pts_ResultFileTable($result_file);
         $chart->renderChart($save_to_dir . '/result-graphs/overview.BILDE_EXTENSION');
         $intent = -1;
         if (($intent = pts_result_file_analyzer::analyze_result_file_intent($result_file, $intent, true)) || $result_file->get_system_count() == 1) {
             $chart = new pts_ResultFileCompactSystemsTable($result_file, $intent);
         } else {
             $chart = new pts_ResultFileSystemsTable($result_file);
         }
         $chart->renderChart($save_to_dir . '/result-graphs/systems.BILDE_EXTENSION');
         unset($chart);
         if ($intent && is_dir($save_to_dir . '/system-logs/')) {
             $chart = new pts_DetailedSystemComponentTable($result_file, $save_to_dir . '/system-logs/', $intent);
             if ($chart) {
                 $chart->renderChart($save_to_dir . '/result-graphs/detailed_component.BILDE_EXTENSION');
             }
         }
     }
     $result_objects = $result_file->get_result_objects();
     $test_titles = array();
     foreach ($result_objects as &$result_object) {
         array_push($test_titles, $result_object->test_profile->get_title());
     }
     $offset = 0;
     foreach ($result_objects as $key => &$result_object) {
         $save_to = $save_to_dir;
         $offset++;
         if ($save_to_dir && is_dir($save_to_dir)) {
             $save_to .= '/result-graphs/' . $offset . '.BILDE_EXTENSION';
             if (PTS_IS_CLIENT) {
                 if ($result_file->is_multi_way_comparison(null, $extra_attributes) || pts_client::read_env('GRAPH_GROUP_SIMILAR')) {
                     $table_keys = array();
                     foreach ($test_titles as $this_title_index => $this_title) {
                         if (isset($test_titles[$key]) && $this_title == $test_titles[$key]) {
                             array_push($table_keys, $this_title_index);
                         }
                     }
                 } else {
                     $table_keys = $key;
                 }
                 $chart = new pts_ResultFileTable($result_file, null, $table_keys);
                 $chart->renderChart($save_to_dir . '/result-graphs/' . $offset . '_table.BILDE_EXTENSION');
                 unset($chart);
                 $generated_graph_tables = true;
             }
         }
         if (getenv('USE_PHX_GRAPH')) {
             $graph = phx_graph_render::render_graph($result_object, $result_file, $save_to, $extra_attributes);
         } else {
             $graph = pts_render::render_graph($result_object, $result_file, $save_to, $extra_attributes);
         }
         array_push($generated_graphs, $graph);
     }
     // Generate mini / overview graphs
     if ($save_to_dir) {
         $graph = new pts_OverviewGraph($result_file);
         if ($graph->doSkipGraph() == false) {
             $graph->renderGraph();
             // Check to see if skip_graph was realized during the rendering process
             if ($graph->doSkipGraph() == false) {
                 $graph->svg_dom->output($save_to_dir . '/result-graphs/visualize.BILDE_EXTENSION');
             }
         }
         unset($graph);
         $graph = new pts_RadarOverviewGraph($result_file);
         if ($graph->doSkipGraph() == false) {
             $graph->renderGraph();
             // Check to see if skip_graph was realized during the rendering process
             if ($graph->doSkipGraph() == false) {
                 $graph->svg_dom->output($save_to_dir . '/result-graphs/radar.BILDE_EXTENSION');
             }
         }
         unset($graph);
     }
     // Save XSL
     if (count($generated_graphs) > 0 && $save_to_dir) {
         file_put_contents($save_to_dir . '/pts-results-viewer.xsl', pts_client::xsl_results_viewer_graph_template($generated_graph_tables));
     }
     return $generated_graphs;
 }
 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 (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 ($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('LINE_GRAPH', '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' && (phx_graph_render::multi_way_identifier_check($result_object->test_result_buffer->get_identifiers()) || isset($extra_attributes['force_tracking_line_graph']) && $extra_attributes['force_tracking_line_graph'])) {
                 //$result_table = false;
                 //pts_render::compact_result_file_test_object($result_object, $result_table, $result_file, $extra_attributes);
                 if ($result_object->test_profile->get_display_format() == 'LINE_GRAPH' || isset($extra_attributes['force_tracking_line_graph']) && $extra_attributes['force_tracking_line_graph']) {
                     $result_object->test_profile->set_display_format('LINE_GRAPH');
                 }
             }
         } 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');
                 }
             }
         }
     }
     if (isset($extra_attributes['graph_render_type'])) {
         $result_object->test_profile->set_display_format($extra_attributes['graph_render_type']);
     }
     $display_format = $result_object->test_profile->get_display_format();
     switch ($display_format) {
         case 'LINE_GRAPH':
             $graph = new phx_graph_lines($result_object, $result_file, $extra_attributes);
             break;
         case 'HORIZONTAL_BOX_PLOT':
             $graph = new phx_graph_box_plot($result_object, $result_file, $extra_attributes);
             break;
         case 'BAR_ANALYZE_GRAPH':
         case 'BAR_GRAPH':
             $graph = new phx_graph_horizontal_bars($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:
             switch ($requested_graph_type) {
                 case 'LINE_GRAPH':
                     $graph = new phx_graph_lines($result_object, $result_file, $extra_attributes);
                     break;
                 case 'HORIZONTAL_BOX_PLOT':
                     $graph = new phx_graph_box_plot($result_object, $result_file, $extra_attributes);
                     break;
                 default:
                     $graph = new phx_graph_horizontal_bars($result_object, $result_file, $extra_attributes);
                     break;
             }
             break;
     }
     self::report_test_notes_to_graph($graph, $result_object);
     return $graph;
 }
 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 run($r)
    {
        $render_dir = pts_client::temporary_directory() . '/pts-render-test-310815/';
        if (!is_file($render_dir . 'mega-render-test.tar.bz2')) {
            pts_file_io::mkdir($render_dir);
            pts_network::download_file('http://linuxbenchmarking.com/misc/mega-render-test-310815.tar.bz2', $render_dir . 'mega-render-test.tar.bz2');
            pts_compression::archive_extract($render_dir . 'mega-render-test.tar.bz2');
        }
        define('PATH_TO_EXPORTED_PHOROMATIC_DATA', $render_dir . 'mega-render-test-310815/');
        error_reporting(E_ALL);
        ini_set('memory_limit', '2048M');
        $export_index_json = file_get_contents(PATH_TO_EXPORTED_PHOROMATIC_DATA . 'export-index.json');
        $export_index_json = json_decode($export_index_json, true);
        $start = microtime(true);
        foreach (array_keys($export_index_json['phoromatic']) as $REQUESTED) {
            $this_render_test = time();
            $tracker =& $export_index_json['phoromatic'][$REQUESTED];
            $triggers = $tracker['triggers'];
            echo PHP_EOL . 'STARTING RENDER TEST ON: ' . $REQUESTED . ' (' . count($triggers) . ' Triggers)' . PHP_EOL;
            $length = count($tracker['triggers']);
            $result_files = array();
            foreach ($triggers as $trigger) {
                $results_for_trigger = glob(PATH_TO_EXPORTED_PHOROMATIC_DATA . '/' . $REQUESTED . '/' . $trigger . '/*/composite.xml');
                echo '.';
                if ($results_for_trigger == false) {
                    continue;
                }
                foreach ($results_for_trigger as $composite_xml) {
                    // Add to result file
                    $system_name = basename(dirname($composite_xml)) . ': ' . $trigger;
                    array_push($result_files, new pts_result_merge_select($composite_xml, null, $system_name));
                }
            }
            echo 'STARTING MERGE; ';
            $result_file = new pts_result_file(null, true);
            $result_file->merge($result_files);
            echo 'MAKING NEW RESULT FILE; ';
            $extra_attributes = array('reverse_result_buffer' => true, 'force_simple_keys' => true, 'force_line_graph_compact' => true, 'force_tracking_line_graph' => true);
            //$extra_attributes['normalize_result_buffer'] = true;
            $intent = null;
            //$table = new pts_ResultFileTable($result_file, $intent);
            //echo '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>';
            echo 'STARTING RESULT LOOP; ';
            $html_dump = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>';
            foreach ($result_file->get_result_objects(isset($_POST['show_only_changed_results']) ? 'ONLY_CHANGED_RESULTS' : -1) as $i => $result_object) {
                echo $result_object->test_profile->get_title() . ' ';
                $html_dump .= '<h3>' . $result_object->get_arguments_description() . '</h3>';
                if (getenv('USE_PHX_GRAPH')) {
                    $html_dump .= phx_graph_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes);
                } else {
                    $html_dump .= pts_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes);
                }
                unset($result_object);
            }
            $table = new pts_ResultFileSystemsTable($result_file);
            //$html_dump .= pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes);
            echo PHP_EOL . PHP_EOL . 'RENDER TEST ON: ' . $REQUESTED . ' TOOK ' . (time() - $this_render_test) . PHP_EOL;
            file_put_contents(PATH_TO_EXPORTED_PHOROMATIC_DATA . $REQUESTED . '.html', $html_dump . '</body></html>');
        }
        echo PHP_EOL . 'RENDER TEST TOOK: ' . (time() - $start) . PHP_EOL . PHP_EOL;
        echo PHP_EOL . 'PEAK MEMORY USAGE: ' . round(memory_get_peak_usage(true) / 1048576, 3) . ' MB';
        echo PHP_EOL . 'PEAK MEMORY USAGE (emalloc): ' . round(memory_get_peak_usage() / 1048576, 3) . ' MB';
        echo PHP_EOL;
    }