protected function render_graph_pre_init()
 {
     // Do some common work to this object
     $this->i['identifier_width'] = $this->max_count > 0 ? ($this->i['graph_left_end'] - $this->i['left_start']) / $this->max_count : 1;
     if (!$this->i['hide_graph_identifiers']) {
         $identifier_count = $this->test_result->test_result_buffer->get_count();
         $longest_string = pts_strings::find_longest_string($this->graph_identifiers);
         $this->i['identifier_size'] = $this->text_size_bounds($longest_string, $this->i['identifier_size'], $this->i['min_identifier_size'], $this->i['identifier_width'] - 4);
         if ($this->i['identifier_size'] <= $this->i['min_identifier_size']) {
             list($text_width, $text_height) = pts_svg_dom::estimate_text_dimensions($longest_string, $this->i['min_identifier_size'] + 0.5);
             $this->i['bottom_offset'] += $text_width;
             $this->update_graph_dimensions($this->i['graph_width'], $this->i['graph_height'] + $text_width);
             if ($text_height + 4 > $this->i['identifier_width'] && $identifier_count > 3) {
                 // Show the identifiers as frequently as they will fit
                 $this->i['display_select_identifiers'] = ceil(($text_height + 4) / $this->i['identifier_width']);
             }
         }
     }
     $max_value = 0;
     foreach ($this->test_result->test_result_buffer->buffer_items as &$buffer_item) {
         if (!is_array($buffer_item->get_result_value())) {
             $max_value = max($max_value, $buffer_item->get_result_value());
         } else {
             $max_value = max($max_value, max($buffer_item->get_result_value()));
         }
     }
     $max_value *= 1.25;
     // leave room at top of graph
     $this->i['graph_max_value'] = round($max_value, $max_value < 10 ? 1 : 0);
 }
 protected function render_graph_identifiers()
 {
     $key_strings = array();
     foreach (array_keys($this->graph_identifiers) as $i) {
         $percent = pts_math::set_precision($this->graph_data[0][$i] / $this->i['pie_sum'] * 100, 2);
         array_push($key_strings, '[' . $percent . "%]");
         //array_push($key_strings, '[' . $this->graph_data[0][$i] . ' / ' . $percent . "%]");
     }
     $key_count = count($key_strings);
     $key_item_width = 18 + $this->text_string_width(pts_strings::find_longest_string($this->graph_identifiers), self::$c['size']['key']);
     $key_item_width_value = 12 + $this->text_string_width(pts_strings::find_longest_string($key_strings), self::$c['size']['key']);
     $keys_per_line = floor(($this->i['graph_left_end'] - $this->i['left_start'] - 14) / ($key_item_width + $key_item_width_value));
     if ($keys_per_line < 1) {
         $keys_per_line = 1;
     }
     $key_line_height = 14;
     $this->i['top_start'] += 12;
     $c_y = $this->i['top_start'] - $key_line_height - 5;
     //$this->reset_paint_index();
     for ($i = 0; $i < $key_count; $i++) {
         $this_color = $this->get_paint_color($i);
         if ($i > 0 && $i % $keys_per_line == 0) {
             $c_y += $key_line_height;
             $this->i['top_start'] += $key_line_height;
         }
         $c_x = $this->i['left_start'] + 13 + ($key_item_width + $key_item_width_value) * ($i % $keys_per_line);
         $this->svg_dom->add_element('rect', array('x' => $c_x - 13, 'y' => $c_y - 5, 'width' => 10, 'height' => 10, 'fill' => $this_color, 'stroke' => self::$c['color']['notches'], 'stroke-width' => 1));
         $this->svg_dom->add_text_element($this->graph_identifiers[$i], array('x' => $c_x, 'y' => $c_y, 'font-size' => self::$c['size']['key'], 'fill' => $this_color, 'text-anchor' => 'start', 'dominant-baseline' => 'middle'));
         $this->svg_dom->add_text_element($key_strings[$i], array('x' => $c_x + $key_item_width + 30, 'y' => $c_y, 'font-size' => self::$c['size']['key'], 'fill' => $this_color, 'text-anchor' => 'end', 'dominant-baseline' => 'middle'));
     }
 }
 public function __construct($rows, $columns, $table_data, &$result_file)
 {
     parent::__construct();
     if ($result_file instanceof pts_result_file) {
         $this->is_multi_way = $result_file->is_multi_way_comparison();
     }
     if ($this->is_multi_way) {
         foreach ($columns as &$c_str) {
             // in multi-way comparisons this will be reported above, so don't need to report it in the column header as it kills space
             if (($c = strpos($c_str, ':')) !== false) {
                 $c_str = substr($c_str, $c + 1);
             }
         }
     }
     $this->rows = $rows;
     $this->columns = $columns;
     $this->table_data = $table_data;
     // Do some calculations
     $this->longest_column_identifier = pts_strings::find_longest_string($this->columns);
     $this->longest_row_identifier = pts_strings::find_longest_string($this->rows);
     $this->i['graph_max_value'] = $this->find_longest_string_in_table_data($this->table_data);
     foreach ($this->columns as &$column) {
         if ($column instanceof pts_graph_ir_value == false) {
             $column = new pts_graph_ir_value($column);
         }
     }
 }
 protected function render_graph_pre_init()
 {
     // Do some common work to this object
     $identifier_count = count($this->graph_identifiers);
     $this->i['identifier_width'] = floor(($this->i['graph_left_end'] - $this->i['left_start']) / $identifier_count);
     $longest_string = pts_strings::find_longest_string($this->graph_identifiers);
     $width = $this->i['identifier_width'] - 4;
     $this->i['identifier_size'] = $this->text_size_bounds($longest_string, $this->i['identifier_size'], $this->i['min_identifier_size'], $width);
     if ($this->i['identifier_size'] <= $this->i['min_identifier_size']) {
         $this->update_graph_dimensions($this->i['graph_width'], $this->i['graph_height'] + $this->text_string_width($longest_string, 9));
     }
 }
 public function __construct($result_file)
 {
     $result_object = null;
     parent::__construct($result_object, $result_file);
     // System Identifiers
     if ($result_file->is_multi_way_comparison()) {
         // Multi way comparisons currently render the overview graph as blank
         $this->skip_graph = true;
         return;
     }
     $this->system_identifiers = $result_file->get_system_identifiers();
     if (count($this->system_identifiers) < 2) {
         // No point in generating this when there is only one identifier
         $this->skip_graph = true;
         return;
     }
     $result_objects = array();
     $test_titles = array();
     foreach ($result_file->get_result_objects() as $result_object) {
         if ($result_object->test_profile->get_display_format() == 'BAR_GRAPH') {
             array_push($result_objects, $result_object);
             array_push($test_titles, $result_object->test_profile->get_title());
             foreach ($result_object->test_result_buffer->buffer_items as &$buffer_item) {
                 pts_arrays::unique_push($this->graph_identifiers, $buffer_item->get_result_identifier());
             }
         }
     }
     $result_object_count = count($result_objects);
     if ($result_object_count < 3) {
         // No point in generating this if there aren't many tests
         $this->skip_graph = true;
         return;
     }
     $result_file->override_result_objects($result_objects);
     // Test Titles
     $this->i['identifier_size'] = 6.5;
     $this->i['graph_width'] = 1000;
     list($longest_title_width, $longest_title_height) = pts_svg_dom::estimate_text_dimensions(pts_strings::find_longest_string($test_titles), $this->i['identifier_size']);
     $this->i['left_start'] += 20;
     $this->graphs_per_row = min(count($this->system_identifiers) > 10 ? 6 : 10, floor(($this->i['graph_width'] - $this->i['left_start'] - $this->i['left_end_right']) / ($longest_title_width + 4)));
     $this->graph_item_width = floor(($this->i['graph_width'] - $this->i['left_start'] - $this->i['left_end_right']) / $this->graphs_per_row);
     $this->graph_row_count = ceil($result_object_count / $this->graphs_per_row);
     $this->i['top_start'] += 20 + count($this->system_identifiers) / 3 * $this->i['identifier_size'];
     $height = $this->i['top_start'] + $this->graph_row_count * ($this->graph_row_height + 15);
     $this->graph_title = $result_file->get_title();
     $this->graph_y_title = null;
     $this->i['graph_proportion'] = 'HIB';
     $this->i['show_background_lines'] = true;
     $this->update_graph_dimensions($this->i['graph_width'], $height, true);
     $this->result_file = $result_file;
     return true;
 }
 public function __construct($rows, $columns, $table_data)
 {
     parent::__construct();
     $this->rows = $rows;
     $this->columns = $columns;
     $this->table_data = $table_data;
     // Do some calculations
     $this->longest_column_identifier = pts_strings::find_longest_string($this->columns);
     $this->longest_row_identifier = pts_strings::find_longest_string($this->rows);
     foreach ($this->columns as &$column) {
         if ($column instanceof pts_graph_ir_value == false) {
             $column = new pts_graph_ir_value($column);
         }
     }
     $this->column_heading_vertical = false;
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Recently Updated OpenBenchmarking.org Tests');
     $recently_updated = array();
     foreach (pts_openbenchmarking::linked_repositories() as $repo) {
         if ($repo == 'local') {
             // Skip local since it's a fake repository
             continue;
         }
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         $changes[$repo] = pts_openbenchmarking_client::fetch_repository_changelog($repo);
         if (isset($repo_index['tests']) && is_array($repo_index['tests'])) {
             foreach (array_keys($repo_index['tests']) as $identifier) {
                 if ($repo_index['tests'][$identifier]['last_updated'] > time() - 90 * 86400) {
                     $recently_updated[$repo . '/' . $identifier] = $repo_index['tests'][$identifier];
                 }
             }
         }
     }
     if (count($recently_updated) > 0) {
         // sort by date
         uasort($recently_updated, array('openbenchmarking_changes', 'compare_time_stamps'));
         // so that tests are shown from newest to oldest
         $recently_updated = array_reverse($recently_updated);
         $longest_identifier_length = array_keys($recently_updated);
         $longest_identifier_length = strlen(pts_strings::find_longest_string($longest_identifier_length)) + 1;
         foreach ($recently_updated as $test_profile => $repo_data) {
             echo sprintf('%-' . $longest_identifier_length . 'ls - %-35ls', $test_profile, $repo_data['title']) . PHP_EOL;
             $br = explode('/', $test_profile);
             if (isset($changes[$br[0]]['tests'][$br[1]]['changes'])) {
                 foreach ($changes[$br[0]]['tests'][$br[1]]['changes'] as $test_profile_version => $data) {
                     echo 'v' . $test_profile_version . ' [' . date('d M Y', $data['last_updated']) . ']' . PHP_EOL;
                     echo '  - ' . $data['commit_description'] . PHP_EOL;
                 }
             } else {
                 echo 'Last Updated: ' . date('d F Y', $repo_data['last_updated']) . PHP_EOL;
             }
             echo PHP_EOL;
             // $repo_data['test_type']
         }
     } else {
         echo PHP_EOL . 'No updated tests were found.' . PHP_EOL;
     }
 }
 protected function render_graph_pre_init()
 {
     $this->i['min_time'] = strtotime(min($this->test_result->test_result_buffer->get_identifiers()));
     $this->i['max_time'] = strtotime(max($this->test_result->test_result_buffer->get_identifiers()));
     $this->i['spread_time'] = $this->i['max_time'] - $this->i['min_time'];
     // Do some common work to this object
     $graph_identifiers_count = count($this->graph_identifiers);
     $identifier_count = $graph_identifiers_count > 1 ? $graph_identifiers_count : count($this->graph_data[0]);
     $this->i['identifier_width'] = ($this->i['graph_left_end'] - $this->i['left_start']) / ($identifier_count + 1);
     $longest_string = pts_strings::find_longest_string($this->graph_identifiers);
     $this->i['identifier_size'] = $this->text_size_bounds($longest_string, $this->i['identifier_size'], $this->i['min_identifier_size'], $this->i['identifier_width'] - 4);
     if ($this->i['identifier_size'] <= $this->i['min_identifier_size']) {
         list($text_width, $text_height) = pts_svg_dom::estimate_text_dimensions($longest_string, $this->i['min_identifier_size'] + 0.5);
         $this->i['bottom_offset'] += $text_width;
         $this->update_graph_dimensions($this->i['graph_width'], $this->i['graph_height'] + $text_width);
         if ($text_height + 4 > $this->i['identifier_width'] && $graph_identifiers_count > 3) {
             // Show the identifiers as frequently as they will fit
             $this->i['display_select_identifiers'] = ceil(($text_height + 4) / $this->i['identifier_width']);
         }
     }
 }
 public function generate_display()
 {
     $bar_width = 580;
     $bar_height = 38;
     $heading_per_bar = 16;
     $title_bar_height = 35;
     $footer_bar_height = 14;
     $category_offsets = 0;
     $category_heights = 30;
     $categories = array();
     $border = 3;
     foreach ($this->bars as &$bar) {
         if ($bar['test_data']['h'] != null && !in_array($bar['test_data']['h'], $categories)) {
             array_push($categories, $bar['test_data']['h']);
         }
     }
     if (empty($this->keys)) {
         foreach ($this->bars as &$bar_index) {
             foreach (array_keys($bar_index['results']) as $result_identifier) {
                 if (!in_array($result_identifier, $this->keys)) {
                     array_push($this->keys, $result_identifier);
                 }
             }
         }
     }
     if (!empty($this->keys)) {
         list($longest_key_width, $key_line_height) = pts_svg_dom::estimate_text_dimensions(pts_strings::find_longest_string($this->keys), '', 10, true);
         $key_line_height += 18;
         $keys_per_line = max(floor($bar_width / max(1, $longest_key_width + 12)), 1);
         $title_key_offset = ceil(count($this->keys) / $keys_per_line) * $key_line_height;
     } else {
         $title_key_offset = 0;
     }
     $this->i['graph_width'] = $bar_width + $border * 2;
     $this->i['graph_height'] = ($bar_height + $heading_per_bar + $border) * count($this->bars) + $border + count($categories) * $category_heights + $title_bar_height + $title_key_offset + $footer_bar_height;
     $this->svg_dom = new pts_svg_dom(ceil($this->i['graph_width']), ceil($this->i['graph_height']));
     $text_color = '#e12128';
     $alt_text_color = '#646464';
     // Setup
     $start_x = $border;
     $end_x = $start_x + $bar_width;
     // Title bar
     $this->svg_dom->add_element('image', array('xlink:href' => 'https://openbenchmarking.org/static/images/ob-fulltext-183x32.png', 'x' => $end_x - 190, 'y' => 10, 'width' => 183, 'height' => 32));
     if (!empty($this->keys)) {
         $color_cache = array('e12128', '065695', '007400');
         for ($i = 0, $c = count($this->keys); $i < $c; $i++) {
             $component_x = $border + $i % $keys_per_line * ($longest_key_width + 10);
             $component_y = floor($i / $keys_per_line) * $key_line_height + $title_bar_height + 3;
             $key_color = self::color_cache('opc', $this->keys[$i], $color_cache);
             //$key_color = self::color_gradient('e12128', '065695', ($i / $c));
             $key_colors[$this->keys[$i]] = $key_color;
             $this->svg_dom->add_element('rect', array('x' => $component_x + 1, 'y' => $component_y, 'width' => 10, 'height' => 10, 'fill' => $key_color, 'stroke' => self::$c['color']['border'], 'stroke-width' => 1));
             $this->svg_dom->add_text_element($this->keys[$i], array('x' => $component_x + 15, 'y' => $component_y + 5, 'font-size' => 10, 'fill' => $key_color, 'text-anchor' => 'start'));
         }
     }
     $previous_category = null;
     foreach ($this->bars as $i => &$hmap) {
         $upper_y = $i * ($bar_height + $border + $heading_per_bar) + $border + $title_bar_height + $title_key_offset + $category_offsets + $heading_per_bar;
         if ($hmap['test_data']['h'] != null && $hmap['test_data']['h'] != $previous_category) {
             $this->svg_dom->add_text_element($hmap['test_data']['h'] . ' Tests', array('x' => $start_x + $bar_width / 2, 'y' => $upper_y, 'font-size' => 16, 'fill' => $text_color, 'text-anchor' => 'middle'));
             $category_offsets += $category_heights;
             $upper_y += $category_heights;
         }
         $previous_category = $hmap['test_data']['h'];
         $lower_y = $upper_y + $bar_height;
         $value_size = $bar_width / ($hmap['max_value'] - $hmap['min_value']);
         $prev_color = '#ffffff';
         $last_plot_x = $start_x;
         $this->svg_dom->add_text_element($hmap['test_data']['t'], array('x' => $start_x, 'y' => $upper_y, 'font-size' => 12, 'fill' => $text_color, 'text-anchor' => 'start'));
         $this->svg_dom->add_text_element($hmap['test_data']['a'], array('x' => $end_x, 'y' => $upper_y, 'font-size' => 10, 'fill' => $alt_text_color, 'text-anchor' => 'end'));
         if ($hmap['test_data']['p'] == 'LIB') {
             // Invert results
             $new_sections = array();
             foreach ($hmap['sections'] as $next_section => $next_section_value) {
                 $new_sections[$hmap['max_value'] - $next_section] = $next_section_value;
             }
             ksort($new_sections);
             $hmap['sections'] = $new_sections;
             foreach ($hmap['draw_lines'] as &$value) {
                 $value = $hmap['max_value'] - $value;
             }
             foreach ($hmap['results'] as &$value) {
                 $value = $hmap['max_value'] - $value;
             }
             sort($hmap['draw_lines']);
             $hmap['max_value'] -= $hmap['min_value'];
             $hmap['min_value'] = 0;
         }
         $prev_section = $hmap['min_value'];
         $max_section_value = max($hmap['sections']);
         /*
         for($i = $hmap['min_value']; $i <= $hmap['max_size'] && $hmap['bin_size'] > 0; $i += $hmap['bin_size'])
         {
         
         }
         */
         $color_weight = 0.61 - 0 / $max_section_value * 0.5;
         $background_color = self::color_gradient('#FFFFFF', '#000000', $color_weight);
         $this->svg_dom->add_element('rect', array('x' => $start_x, 'y' => $upper_y, 'width' => $bar_width, 'height' => $bar_height, 'fill' => $background_color));
         foreach ($hmap['sections'] as $next_section => $next_section_value) {
             $color_weight = 0.61 - $next_section_value / $max_section_value * 0.5;
             $color = self::color_gradient('#FFFFFF', '#000000', $color_weight);
             if ($next_section > $hmap['min_value']) {
                 $next_section = $next_section > $hmap['max_value'] ? $hmap['max_value'] : $next_section;
                 $plot_x = floor($last_plot_x + ($next_section - $prev_section) * $value_size);
                 $plot_x = $plot_x > $end_x ? $end_x : $plot_x;
                 if ($prev_color != $color || $color != $background_color) {
                     // don't uselessly paint background color, it's already painted
                     $this->svg_dom->draw_rectangle_gradient($last_plot_x, $upper_y, abs($plot_x - $last_plot_x), $bar_height, $prev_color, $color);
                 }
                 $last_plot_x = floor($plot_x - 0.6);
                 $prev_section = $next_section;
                 if ($next_section > $hmap['max_value']) {
                     break;
                 }
             }
             $prev_color = $color;
         }
         /*
         
         if($prev_color != $background_color && $plot_x < $end_x)
         {
         	$plot_x = $last_plot_x + $next_section + $hmap['bin_size'];
         	$plot_x = $plot_x > $end_x ? $end_x : $plot_x;
         	$this->svg_dom->draw_rectangle_gradient($last_plot_x, $upper_y, ceil($plot_x - $last_plot_x), $bar_height, $prev_color, $background_color);
         }
         if($last_plot_x < $end_x)
         {
         	// Fill in the blank
         	$this->svg_dom->add_element('rect', array('x' => $last_plot_x, 'y' => $upper_y, 'width' => ($end_x - $last_plot_x), 'height' => $bar_height, 'fill' => $prev_color));
         }
         */
         foreach ($hmap['draw_lines'] as $line_value) {
             $line_x = $start_x + ($line_value - $hmap['min_value']) * $value_size;
             $this->svg_dom->draw_svg_line($line_x, $upper_y, $line_x, $lower_y, self::$c['color']['border'], 1);
         }
         foreach ($hmap['results'] as $identifier => $value) {
             if (!isset($key_colors[$identifier])) {
                 continue;
             }
             $line_x = $start_x + ($value - $hmap['min_value']) * $value_size;
             if (false && $start_x + 10 < $line_x && $line_x < $end_x - 10) {
                 $this->svg_dom->draw_svg_line($line_x, $lower_y - 10, $line_x, $lower_y - 1, $key_colors[$identifier], 1);
                 $this->svg_dom->draw_svg_line($line_x, $lower_y + 10, $line_x, $lower_y + 1, $key_colors[$identifier], 1);
             }
             $this->svg_dom->draw_svg_line($line_x, $upper_y, $line_x, $lower_y, $key_colors[$identifier], 1);
         }
         $this->svg_dom->add_element('rect', array('x' => $start_x, 'y' => $upper_y, 'width' => $bar_width, 'height' => $bar_height, 'fill' => 'none', 'stroke' => self::$c['color']['border'], 'stroke-width' => 1));
     }
     // Footer
     $this->draw_arrow($start_x + 8, $lower_y + 8, $start_x + 1, $lower_y + 8, $alt_text_color, self::$c['color']['border'], 1);
     $this->svg_dom->add_text_element('Percentile Rank' . ($this->last_updated != null ? '; Data As Of ' . pts_strings::time_stamp_to_string($this->last_updated, 'j F Y') . ' For Trailing 200 Days' : null), array('x' => $start_x + 13, 'y' => $lower_y + 8, 'font-size' => 7, 'fill' => $alt_text_color, 'text-anchor' => 'start', 'dominant-baseline' => 'middle'));
     $this->svg_dom->add_text_element('OpenBenchmarking.org Performance Classification', array('x' => $end_x, 'y' => $lower_y + 8, 'font-size' => 7, 'fill' => $alt_text_color, 'text-anchor' => 'end', 'dominant-baseline' => 'middle'));
     return $this->svg_dom;
 }
 public function render_graph_start()
 {
     $this->i['top_heading_height'] = 22 + self::$c['size']['headers'];
     $longest_component = pts_strings::find_longest_string($this->components);
     $component_header_height = $this->text_string_height($longest_component, $this->i['identifier_size'] + 3) + 6;
     $this->i['graph_width'] = 10 + max($this->text_string_width($this->graph_title, self::$c['size']['headers']) - (isset($this->graph_title[30]) ? 20 : 0), $this->text_string_width($longest_component, $this->i['identifier_size'] + (isset($longest_component[29]) ? 1.8 : 2)));
     $intent_count = 0;
     $dupes = array();
     if ($this->intent[1] && is_array($this->intent[1])) {
         foreach ($this->intent[1] as $x) {
             if (!in_array($x, $dupes)) {
                 $intent_count += count($x);
                 array_push($dupes, $x);
             }
         }
         $intent_count -= count($this->intent[0]);
     }
     unset($dupes);
     $bottom_footer = 50 + $this->note_display_height();
     // needs to be at least 86 to make room for PTS logo
     $this->i['graph_height'] = $this->i['top_heading_height'] + (count($this->components) + $intent_count) * $component_header_height + $bottom_footer;
     // Do the actual work
     $this->render_graph_pre_init();
     $this->render_graph_init();
     // Header
     $this->svg_dom->add_element('rect', array('x' => 2, 'y' => 1, 'width' => $this->i['graph_width'] - 3, 'height' => $this->i['top_heading_height'] - 1, 'fill' => self::$c['color']['main_headers'], 'stroke' => self::$c['color']['border'], 'stroke-width' => 1));
     $this->svg_dom->add_text_element($this->graph_title, array('x' => $this->i['graph_width'] / 2, 'y' => 2 + self::$c['size']['headers'], 'font-size' => self::$c['size']['headers'], 'fill' => self::$c['color']['background'], 'text-anchor' => 'middle'));
     $this->svg_dom->add_text_element(self::$c['text']['watermark'], array('x' => 4, 'y' => $this->i['top_heading_height'] - 3, 'font-size' => 8, 'fill' => self::$c['color']['background'], 'text-anchor' => 'start', 'xlink:show' => 'new', 'xlink:href' => self::$c['text']['watermark_url']));
     $this->svg_dom->add_text_element($this->i['graph_version'], array('x' => $this->i['graph_width'] - 4, 'y' => $this->i['top_heading_height'] - 3, 'font-size' => 8, 'fill' => self::$c['color']['background'], 'text-anchor' => 'end', 'xlink:show' => 'new', 'xlink:href' => 'http://www.phoronix-test-suite.com/'));
     // Body
     $offset = $this->i['top_heading_height'];
     $dash = false;
     foreach ($this->components as $type => $component) {
         if (is_array($this->intent[0]) && ($key = array_search($type, $this->intent[0])) !== false) {
             $component = array();
             foreach ($this->intent[1] as $s) {
                 if (isset($s[$key])) {
                     array_push($component, $s[$key]);
                 }
             }
             // Eliminate duplicates from printing
             $component = array_unique($component);
             $next_offset = $offset + $component_header_height * count($component);
         } else {
             $next_offset = $offset + $component_header_height;
             $component = array($component);
         }
         if ($dash) {
             $this->svg_dom->add_element('rect', array('x' => 0, 'y' => $offset, 'width' => $this->i['graph_width'], 'height' => $next_offset - $offset, 'fill' => self::$c['color']['body_light']));
         }
         $this->svg_dom->draw_svg_line(0, $offset, $this->i['graph_width'], $offset, self::$c['color']['notches'], 1);
         if (isset($component[1])) {
             $this->svg_dom->add_element('rect', array('x' => 1, 'y' => $offset + 1, 'width' => $this->i['graph_width'] - 2, 'height' => $next_offset - $offset - 1, 'fill' => 'none', 'stroke-width' => 1, 'stroke' => self::$c['color']['highlight']));
         }
         $text = $type . (isset($component[1]) && substr($type, -1) != 'y' && substr($type, -1) != 's' ? 's' : null);
         $this->svg_dom->add_text_element($text, array('x' => $this->i['graph_width'] - 4, 'y' => $offset + 9, 'font-size' => 7, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end'));
         $offset += 2;
         foreach ($component as $c) {
             $c = pts_result_file_analyzer::system_value_to_ir_value($c, $type);
             $this->svg_dom->add_text_element($c, array('x' => $this->i['graph_width'] / 2, 'y' => $offset + $component_header_height - 5, 'font-size' => $this->i['identifier_size'], 'fill' => self::$c['color']['text'], 'text-anchor' => 'middle', 'xlink:title' => $type . ': ' . $c, 'font-weight' => 'bold', 'xlink:href' => $c->get_attribute('href')));
             $offset += $component_header_height;
         }
         $offset = $next_offset;
         $dash = !$dash;
     }
     // Footer
     $this->svg_dom->add_element('rect', array('x' => 1, 'y' => $this->i['graph_height'] - $bottom_footer, 'width' => $this->i['graph_width'] - 2, 'height' => $bottom_footer, 'fill' => self::$c['color']['main_headers']));
     //$this->svg_dom->add_element('image', array('http_link' => 'http://www.phoronix-test-suite.com/', 'xlink:href' => pts_svg_dom::embed_png_image(PTS_CORE_STATIC_PATH . 'images/pts-80x42-white.png'), 'x' => 10, 'y' => ($this->i['graph_height'] - 46), 'width' => 80, 'height' => 42));
     if (defined('OPENBENCHMARKING_IDS')) {
         $back_width = $this->i['graph_width'] - 4;
         $this->svg_dom->add_text_element(OPENBENCHMARKING_TITLE, array('x' => $back_width, 'y' => $this->i['graph_height'] - $bottom_footer + 12, 'font-size' => 8, 'fill' => self::$c['color']['background'], 'text-anchor' => 'end', 'font-weight' => 'bold', 'xlink:show' => 'new', 'xlink:href' => 'http://openbenchmarking.org/result/' . OPENBENCHMARKING_IDS));
         $this->svg_dom->add_text_element('System Logs', array('x' => $back_width, 'y' => $this->i['graph_height'] - 20, 'font-size' => 8, 'fill' => self::$c['color']['background'], 'text-anchor' => 'end', 'xlink:show' => 'new', 'xlink:href' => 'http://openbenchmarking.org/system/' . OPENBENCHMARKING_IDS));
         $this->svg_dom->add_text_element('OPC Classification', array('x' => $back_width, 'y' => $this->i['graph_height'] - 6, 'font-size' => 8, 'fill' => self::$c['color']['background'], 'text-anchor' => 'end', 'xlink:show' => 'new', 'xlink:href' => 'http://openbenchmarking.org/opc/' . OPENBENCHMARKING_IDS));
     }
     if (!empty($this->i['notes'])) {
         $estimated_height = 0;
         foreach ($this->i['notes'] as $i => $note_r) {
             $this->svg_dom->add_textarea_element('- ' . $note_r['note'], array('x' => 4, 'y' => $this->i['graph_height'] - $bottom_footer + $estimated_height + 21, 'font-size' => self::$c['size']['key'], 'fill' => self::$c['color']['background'], 'text-anchor' => 'start', 'xlink:title' => $note_r['hover-title']), $estimated_height);
         }
     }
 }
 public static function result_file_to_text(&$result_file, $terminal_width = 80)
 {
     $result_output = null;
     $result_output .= $result_file->get_title() . PHP_EOL;
     $result_output .= $result_file->get_description() . PHP_EOL . PHP_EOL . PHP_EOL;
     $system_identifiers = array();
     $system_hardware = array();
     $system_software = array();
     foreach ($result_file->get_systems() as $system) {
         array_push($system_identifiers, $system->get_identifier());
         array_push($system_hardware, $system->get_hardware());
         array_push($system_software, $system->get_software());
     }
     for ($i = 0; $i < count($system_identifiers); $i++) {
         $result_output .= $system_identifiers[$i] . ': ' . PHP_EOL . PHP_EOL;
         $result_output .= "\t" . $system_hardware[$i] . PHP_EOL . PHP_EOL . "\t" . $system_software[$i] . PHP_EOL . PHP_EOL;
     }
     $longest_identifier_length = strlen(pts_strings::find_longest_string($system_identifiers)) + 2;
     foreach ($result_file->get_result_objects() as $result_object) {
         $result_output .= trim($result_object->test_profile->get_title() . ' ' . $result_object->test_profile->get_app_version() . PHP_EOL . $result_object->get_arguments_description());
         if ($result_object->test_profile->get_result_scale() != null) {
             $result_output .= PHP_EOL . '  ' . $result_object->test_profile->get_result_scale();
         }
         foreach ($result_object->test_result_buffer as &$buffers) {
             $max_value = 0;
             $min_value = pts_arrays::first_element($buffers)->get_result_value();
             foreach ($buffers as &$buffer_item) {
                 if ($buffer_item->get_result_value() > $max_value) {
                     $max_value = $buffer_item->get_result_value();
                 } else {
                     if ($buffer_item->get_result_value() < $min_value) {
                         $min_value = $buffer_item->get_result_value();
                     }
                 }
             }
             $longest_result = strlen($max_value) + 1;
             foreach ($buffers as &$buffer_item) {
                 $val = $buffer_item->get_result_value();
                 if (stripos($val, ',') !== false) {
                     $vals = explode(',', $val);
                     $val = 'MIN: ' . min($vals) . ' / AVG: ' . round(array_sum($vals) / count($vals), 2) . ' / MAX: ' . max($vals);
                 }
                 $result_output .= PHP_EOL . '    ' . $buffer_item->get_result_identifier() . ' ';
                 $result_length_offset = $longest_identifier_length - strlen($buffer_item->get_result_identifier());
                 if ($result_length_offset > 0) {
                     $result_output .= str_repeat('.', $result_length_offset) . ' ';
                 }
                 $result_output .= $val;
                 if (is_numeric($val)) {
                     $result_output .= str_repeat(' ', $longest_result - strlen($val)) . '|';
                     $current_line_length = strlen(substr($result_output, strrpos($result_output, PHP_EOL) + 1)) + 1;
                     $result_output .= str_repeat('=', round($val / $max_value * ($terminal_width - $current_line_length)));
                 }
             }
         }
         $result_output .= PHP_EOL . PHP_EOL;
     }
     return $result_output;
 }
 protected function graph_key_height()
 {
     if (count($this->graph_data_title) < 2 && $this->i['show_graph_key'] == false) {
         return 0;
     }
     $this->i['key_line_height'] = 16;
     $this->i['key_item_width'] = 16 + $this->text_string_width(pts_strings::find_longest_string($this->graph_data_title), self::$c['size']['key']);
     $this->i['keys_per_line'] = max(1, floor(($this->i['graph_left_end'] - $this->i['left_start']) / $this->i['key_item_width']));
     return ceil(count($this->graph_data_title) / $this->i['keys_per_line']) * $this->i['key_line_height'];
 }
 public static function recently_saved_results()
 {
     $recent_results = pts_tests::test_results_by_date();
     if (count($recent_results) > 0) {
         $recent_results = array_slice($recent_results, 0, 5, true);
         $res_length = strlen(pts_strings::find_longest_string($recent_results)) + 2;
         $current_time = time();
         foreach ($recent_results as $m_time => &$recent_result) {
             $days = floor(($current_time - $m_time) / 86400);
             $recent_result = sprintf('%-' . $res_length . 'ls [%-ls]', $recent_result, $days == 0 ? 'Today' : pts_strings::days_ago_format_string($days) . ' old');
         }
         echo PHP_EOL . 'Recently Saved Test Results:' . PHP_EOL;
         echo pts_user_io::display_text_list($recent_results) . PHP_EOL;
         return true;
     }
     return false;
 }
 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']);
 }
 protected function graph_key_height()
 {
     if (isset($this->i['force_simple_keys']) && $this->i['force_simple_keys']) {
         return parent::graph_key_height();
     }
     if (count($this->graph_data_title) < 2 && $this->i['show_graph_key'] == false) {
         return 0;
     }
     $this->i['key_line_height'] = 16;
     $this->i['key_longest_string_width'] = $this->text_string_width(pts_strings::find_longest_string($this->graph_data_title), self::$c['size']['key']);
     $item_width_spacing = 32;
     $this->i['key_item_width'] = $this->i['key_longest_string_width'] + $this->get_stat_word_width() * 3 + $item_width_spacing;
     // if there are <=4 data sets, then use a single column, otherwise, try and multi-col it
     if (count($this->graph_data_title) <= 3) {
         $this->i['keys_per_line'] = 1;
     } else {
         $this->i['keys_per_line'] = max(1, floor(($this->i['graph_left_end'] - $this->i['left_start']) / $this->i['key_item_width']));
     }
     $statistics_header_height = $this->getStatisticsHeaderHeight();
     $extra_spacing = 4;
     return ceil(count($this->graph_data_title) / $this->i['keys_per_line']) * $this->i['key_line_height'] + $statistics_header_height + $extra_spacing;
 }
 protected function graph_key_height()
 {
     if ((count($this->results) < 2 || $this->i['show_graph_key'] == false) && !$this->is_multi_way_comparison) {
         return 0;
     }
     $this->i['key_line_height'] = 16;
     $ak = array_keys($this->results);
     $this->i['key_item_width'] = 16 + self::text_string_width(pts_strings::find_longest_string($ak), self::$c['size']['key']);
     $this->i['keys_per_line'] = max(1, floor(($this->i['graph_left_end'] - $this->i['left_start']) / $this->i['key_item_width']));
     return ceil(count($this->results) / $this->i['keys_per_line']) * $this->i['key_line_height'];
 }