How to use identifier_to_brand_color method of pts_render class

Best Phoronix-test-suite code snippet using pts_render.identifier_to_brand_color

pts_result_file_output.php

Source:pts_result_file_output.php Github

copy

Full Screen

...382 // First run through the items to see if it makes sense applying colors (e.g. multiple matches)383 $buffer_count = 0;384 foreach($buffers as &$buffer_item)385 {386 $brand_color = pts_render::identifier_to_brand_color($buffer_item->get_result_identifier(), null);387 if($brand_color != null)388 {389 // Quite simple handling, could do better390 $buffer_count++;391 }392 }393 $do_color = $buffer_count > 1 ? true : false;394 $longest_result++;395 $precision = ($max_value > 100 || ($min_value > 29 && $max_value > 79) ? 0 : 1);396 if($is_line_graph)397 {398 $largest_min_value = pts_math::set_precision($largest_min_value, $precision);399 $min_value = pts_math::set_precision($min_value, $precision);400 $largest_min_length = strlen($largest_min_value);401 $max_value_length = strlen(pts_math::set_precision($max_value, $precision));402 }403 foreach($buffers as &$buffer_item)404 {405 $val = $buffer_item->get_result_value();406 $result_line = $prepend_line . $buffer_item->get_result_identifier() . ' ';407 $result_length_offset = $longest_identifier_length - strlen($buffer_item->get_result_identifier());408 if($result_length_offset > 0)409 {410 $result_line .= str_repeat('.', $result_length_offset) . ' ';411 }412 if($is_line_graph)413 {414 // LINE GRAPH415 $values = explode(',', $val);416 $formatted_min = pts_math::set_precision(min($values), $precision);417 $formatted_avg = pts_math::set_precision(pts_math::arithmetic_mean($values), $precision);418 $min_value_offset = $largest_min_length - strlen($formatted_min);419 $min_value_offset = $min_value_offset > 0 ? str_repeat(' ', $min_value_offset) : null;420 $avg_value_offset = $max_value_length - strlen($formatted_avg);421 $avg_value_offset = $avg_value_offset > 0 ? str_repeat(' ', $avg_value_offset) : null;422 $result_line .= 'MIN: ' . $formatted_min . $min_value_offset . ' AVG: ' . $formatted_avg . $avg_value_offset . ' MAX: ' . pts_math::set_precision(max($values), $precision) . ' ';423 if($terminal_width > (strlen($result_line) * 2) && $buffer_count > 1)424 {425 $box_plot = str_repeat(' ', ($terminal_width - strlen($result_line)));426 $box_plot_size = strlen($box_plot);427 $box_plot = str_split($box_plot);428 // BOX PLOT429 sort($values, SORT_NUMERIC);430 $whisker_bottom = pts_math::find_percentile($values, 0.02, true);431 $whisker_top = pts_math::find_percentile($values, 0.98, true);432 $unique_values = array_unique($values);433 foreach($unique_values as &$val)434 {435 if(($val < $whisker_bottom || $val > $whisker_top) && $val > 0.1)436 {437 $x = floor($val / $max_value * $box_plot_size);438 if(isset($box_plot[$x]))439 $box_plot[$x] = '.';440 }441 }442 $whisker_start_char = round($whisker_bottom / $max_value * $box_plot_size);443 $whisker_end_char = round($whisker_top / $max_value * $box_plot_size);444 for($i = $whisker_start_char; $i <= $whisker_end_char && $i < ($box_plot_size - 1); $i++)445 {446 $box_plot[$i] = '-';447 }448 $box_left = round((pts_math::find_percentile($values, 0.25, true) / $max_value) * $box_plot_size);449 $box_middle = round((pts_math::find_percentile($values, 0.5, true) / $max_value) * $box_plot_size);450 $box_right = round((pts_math::find_percentile($values, 0.75, true) / $max_value) * $box_plot_size);451 for($i = $box_left; $i <= $box_right; $i++)452 {453 $box_plot[$i] = '#';454 }455 $box_plot[$whisker_start_char] = '|';456 $box_plot[$whisker_end_char] = '|';457 $box_plot[$box_middle] = 'X';458 // END OF BOX PLOT459 //$box_plot[0] = '[';460 //$box_plot[($box_plot_size - 1)] = ']';461 $result_line .= substr(implode('', $box_plot), 0, $box_plot_size);462 }463 }464 else if(is_numeric($val))465 {466 // STANDARD NUMERIC RESULT467 $result_line .= $val;468 $repeat_length = $longest_result - strlen($val);469 $result_line .= ($repeat_length >= 0 ? str_repeat(' ', $repeat_length) : null) . '|';470 $current_line_length = strlen($result_line);471 if($max_value > 0)472 {473 $result_line .= str_repeat('=', max(0, round(($val / $max_value) * ($terminal_width - $current_line_length))));474 }475 }476 else if($result_object->test_profile->get_display_format() == 'PASS_FAIL')477 {478 if($stylize_output && PTS_IS_CLIENT)479 {480 switch($val)481 {482 case 'PASS':483 $val = pts_client::cli_colored_text($val, 'green', true);484 break;485 case 'FAIL':486 $val = pts_client::cli_colored_text($val, 'red', true);487 break;488 }489 }490 $result_line .= $val;491 }492 if($stylize_output && PTS_IS_CLIENT)493 {494 $do_bold = false;495 // See if should bold the line496 if($highlight_result == $buffer_item->get_result_identifier())497 {498 $do_bold = true;499 }500 else if(is_array($highlight_result) && in_array($buffer_item->get_result_identifier(), $highlight_result))501 {502 $do_bold = true;503 }504 // Determine if color505 if($do_color)506 {507 $brand_color = pts_render::identifier_to_brand_color($buffer_item->get_result_identifier(), null);508 if($brand_color != null)509 {510 $brand_color = pts_client::hex_color_to_string($brand_color);511 }512 }513 else514 {515 $brand_color = false;516 }517 if($brand_color)518 {519 $result_line = pts_client::cli_colored_text($result_line, $brand_color, $do_bold);520 }521 else if($do_bold)522 {523 $result_line = pts_client::cli_just_bold($result_line);524 }525 }526 $result_output .= PHP_EOL . $result_line;527 }528 }529 return $result_output;530 }531 public static function result_file_to_detailed_html_table(&$result_file, $grid_class = 'grid', $extra_attributes = null, $detailed_table = true)532 {533 $table = array();534 $systems = array_merge(array(' '), $result_file->get_system_identifiers());535 $systems_count = count($systems) - 1;536 $systems_format = $systems;537 $af = function(&$value) { $value = '<strong style="writing-mode: vertical-rl; text-orientation: mixed;">' . strtoupper($value) . '</strong>'; };538 array_walk($systems_format, $af);539 $table[] = $systems_format;540 foreach($result_file->get_result_objects() as $ro)541 {542 if($ro == false || $ro->test_profile->get_display_format() != 'BAR_GRAPH' || $ro->test_profile->get_identifier() == null || $ro->test_result_buffer->get_max_value() == null)543 {544 continue;545 }546 $table[] = array_fill(0, count($systems), ' ');547 $row = &$table[count($table) - 1];548 if($detailed_table)549 {550 $table[] = array_fill(0, count($systems), ' ');551 $nor = &$table[count($table) - 1];552 $nor[0] = ' &nbsp; &nbsp; Normalized';553 $table[] = array_fill(0, count($systems), ' ');554 $samples = &$table[count($table) - 1];555 $samples[0] = ' &nbsp; &nbsp; Samples';556 if($ro->test_result_buffer->has_run_with_multiple_samples())557 {558 $table[] = array_fill(0, count($systems), ' ');559 $dev = &$table[count($table) - 1];560 $dev[0] = ' &nbsp; &nbsp; Standard Deviation';561 $table[] = array_fill(0, count($systems), ' ');562 $err = &$table[count($table) - 1];563 $err[0] = ' &nbsp; &nbsp; Standard Error';564 }565 }566 $hib = $ro->test_profile->get_result_proportion() == 'HIB';567 $row[0] = '<span><strong><a href="#r-' . $ro->get_comparison_hash(true, false) . '">' . $ro->test_profile->get_title() . '</a></strong><br />' . $ro->get_arguments_description_shortened(($systems_count > 11 ? true : false)) . ' (' . $ro->test_profile->get_result_scale_shortened() . ' ' . ($hib ? '&uarr;' : '&darr;') . ' )</span>';568 $best = $ro->get_result_first(false);569 $worst = $ro->get_result_last(false);570 $median = $ro->test_result_buffer->get_median();571 $normalize_against = 0;572 if(isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1)573 {574 $normalize_against = $ro->get_result_value_from_name($extra_attributes['highlight_graph_values'][0]);575 }576 if($normalize_against == 0)577 {578 $normalize_against = $best;579 }580 $result_buffer_count = $ro->test_result_buffer->get_count();581 foreach($ro->test_result_buffer->get_buffer_items() as $index => $buffer_item)582 {583 $identifier = $buffer_item->get_result_identifier();584 $value = $buffer_item->get_result_value();585 if(($x = array_search($identifier, $systems)) !== false)586 {587 $style = null;588 if($result_buffer_count > 1)589 {590 if($value == $best)591 {592 $style = ' style="font-weight: bold; color: #009900;"';593 }594 else if($value == $worst)595 {596 $style = ' style="font-weight: bold; color: #FF0000;"';597 }598 /* else if($hib && $value > $median)599 {600 $style = ' style="color: ' . pts_graph_core::shift_color('#009900', (($value - $median) / ($best - $median))) . ';"';601 }602 else if($hib && $value < ($best - $median))603 {604 $style = ' style="color: ' . pts_graph_core::shift_color('#FF0000', 1 - (abs($value - $median) / abs($best - $median))) . ';"';605 } */606 }607 if($value > 1000)608 {609 $value = round($value);610 }611 if($value == 0 || !is_numeric($value))612 {613 continue;614 }615 $row[$x] = '<span' . $style. '>' . round($value, 2) . '</span>';616 if(is_numeric($value) && is_numeric($normalize_against))617 {618 $nor[$x] = round(($hib ? ($value / $normalize_against) : ($normalize_against / $value)) * 100, 2) . '%';619 }620 $samples[$x] = $buffer_item->get_sample_count();621 if($samples[$x] > 1)622 {623 $raw = $buffer_item->get_result_raw_array();624 $dev[$x] = round(pts_math::standard_deviation($raw), 4);625 $err[$x] = round(pts_math::standard_error($raw), 4);626 }627 }628 }629 }630 // disable this for now631 if(false && $geo = pts_result_file_analyzer::generate_geometric_mean_result($result_file))632 {633 $table[] = array_fill(0, count($systems), ' ');634 $row = &$table[count($table) - 1];635 $row[0] = '<strong>GEOMETRIC MEAN</strong>';636 foreach($geo->test_result_buffer->get_buffer_items() as $index => $buffer_item)637 {638 $identifier = $buffer_item->get_result_identifier();639 $value = $buffer_item->get_result_value();640 if(($x = array_search($identifier, $systems)) !== false)641 {642 $row[$x] = '<strong>' . $value . '</strong>';643 }644 }645 }646 $html = '<div class="' . $grid_class .'" style="grid-template-columns: max-content ' . str_repeat('max-content ', count($systems) - 1) . '">';647 if(count($table) < 2)648 {649 return null;650 }651 foreach($table as $i => &$row)652 {653 foreach($row as $c)654 {655 $html .= '<span>' . $c . '</span>';656 }657 }658 $html .= '</div>' . PHP_EOL;659 return $html;660 }661 public static function diff_in_system($from, $to)662 {663 if($from == null)664 {665 return false;666 }667 $from = explode(', ', $from);668 $to = explode(', ', $to);669 $changed = array();670 foreach($from as $i => &$word)671 {672 if(isset($to[$i]) && $to[$i] != $from[$i])673 {674 list($component_type, $component) = explode(': ', $to[$i]);675 if(in_array($component_type, array('Audio', 'Monitor')))676 {677 continue;678 }679 $changed[$component_type] = $component;680 }681 }682 return !empty($changed) ? $changed : false;683 }684 public static function result_file_to_system_html(&$result_file, $footnote_mode = false)685 {686 $html = null;687 $systems = $result_file->get_systems();688 $system_count = count($systems);689 $prev_notes = null;690 $prev_sw = null;691 $prev_hw = null;692 $prev_data = array();693 foreach($systems as $i => $system)694 {695 if($footnote_mode)696 {697 $html .= '<h4><u>' . $system->get_identifier() . '</u></h4>';698 }699 else700 {701 $html .= '<h2>' . $system->get_identifier() . '</h2>';702 }703 $reporting_changed_text = false;704 if(isset($systems[($i + 1)]) && $systems[($i + 1)]->get_hardware() == $system->get_hardware() && $systems[($i + 1)]->get_software() == $system->get_software())705 {706 //continue;707 }708 else709 {710 $hw = $system->get_hardware();711 $sw = $system->get_software();712 if($footnote_mode || $hw != $prev_hw)713 {714 if($footnote_mode)715 {716 $html .= '<p>' . pts_strings::highlight_words_with_colon($hw) . '</p>';717 }718 else if(($diff = self::diff_in_system($prev_hw, $hw)) && count($diff) < 4 && $sw == $prev_sw)719 {720 foreach($diff as $type => $c)721 {722 $html .= '<p>Changed <strong>' . $type . '</strong> to <strong>' . $c . '</strong>.</p>';723 $reporting_changed_text = true;724 }725 }726 else727 {728 $html .= '<p>' . pts_strings::highlight_diff_two_structured_strings(pts_strings::highlight_words_with_colon($hw), pts_strings::highlight_words_with_colon($prev_hw)) . '</p>';729 }730 $prev_hw = $hw;731 }732 if($footnote_mode || $sw != $prev_sw)733 {734 $html .= '<p>' . pts_strings::highlight_words_with_colon($sw) . '</p>';735 }736 $prev_sw = $sw;737 }738 if(!$footnote_mode && isset($systems[($i - 1)]) && $systems[($i - 1)]->get_json() == $system->get_json() && $systems[($i - 1)]->get_notes() == $system->get_notes())739 {740 741 }742 else743 {744 $attributes = array();745 pts_result_file_analyzer::system_to_note_array($system, $attributes);746 if(!empty($attributes))747 {748 $notes = '<p class="mini">' . ($footnote_mode ? '' : '<em>');749 foreach($attributes as $section => $data)750 {751 foreach($data as $c => $val)752 {753 if(!$footnote_mode && $reporting_changed_text && isset($prev_data[$section]))754 {755 if($prev_data[$section] != $val)756 {757 $notes .= '<strong>' . $section . ' Change:</strong> ' . $val . '<br />';758 $prev_data[$c] = $val;759 }760 continue;761 }762 $notes .= '<strong>' . $section . ' Notes:</strong> ' . $val . '<br />';763 $prev_data[$section] = $val;764 }765 }766 $notes .= ($footnote_mode ? '' : '</em>') . '</p>';767 if($footnote_mode || $notes != $prev_notes)768 {769 $html .= $notes;770 $prev_notes = $notes;771 }772 }773 }774 if($footnote_mode)775 {776 $html .= '<p>Testing initiated at ' . date('j F Y H:i', strtotime($system->get_timestamp())) . ' by user ' . $system->get_username() . '.</p>';777 }778 }779 return $html;780 }781 public static function result_file_to_html(&$result_file, $extra_attributes = null, $referral_url = '')782 {783 $html = '<html><head><title>' . $result_file->get_title() . ' - Phoronix Test Suite</title></head><body>';784 $html .= '<h1>' . $result_file->get_title() . '</h1>';785 $html .= '<p>' . $result_file->get_description() . '</p>';786 if($referral_url != '')787 {788 $html .= '<p>HTML result view exported from: <a href="' . $referral_url . '">' . $referral_url . '</a>.</p>';789 }790 $table = new pts_ResultFileSystemsTable($result_file);791 $html .= '<p style="text-align: center; overflow: auto;">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes, true, 'SVG') . '</p>';792 $intent = null;793 $table = new pts_ResultFileTable($result_file, $intent);794 $html .= '<p style="text-align: center; overflow: auto;">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes, true, 'SVG') . '</p>';795 // The Results796 foreach($result_file->get_result_objects() as $result_object)797 {798 $res = pts_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes, true, 'SVG');799 if($res == false)800 {801 continue;802 }803 $html .= '<h2>' . $result_object->test_profile->get_title() . '</h2>';804 $html .= '<h3>' . $result_object->get_arguments_description() . '</h3>';805 $html .= '<p align="center">';806 $html .= $res;807 $html .= '</p>';808 if($result_object->get_annotation() == null)809 {810 $html .= '<p align="center">' . $result_object->get_annotation() . '</p>';811 }812 foreach($result_object->test_result_buffer->buffer_items as &$bi)813 {814 if($bi->get_result_value() == null)815 {816 $bi_error = $bi->get_error();817 if($bi_error == null)818 {819 $bi_error = 'Test failed to run.';820 }821 $html .= '<p align="center"><strong>' . $bi->get_result_identifier() . ':</strong> ' . strip_tags($bi_error) . '</p>';822 }823 }824 unset($result_object);825 }826 // Footer827 $html .= '<hr /><p align="center">' . pts_core::program_title() . '</p>';828 $html .= '</body></html>';829 return $html;830 }831 public static function result_file_to_pdf(&$result_file, $dest, $output_name, $extra_attributes = null)832 {833 //ini_set('memory_limit', '1024M');834 ob_start();835 $_REQUEST['force_format'] = 'PNG'; // Force to PNG renderer836 $_REQUEST['svg_dom_gd_no_interlacing'] = true; // Otherwise FPDF will fail837 $pdf = new pts_pdf_template($result_file->get_title(), null);838 $pdf->AddPage();839 $pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38);840 $pdf->Ln(120);841 $pdf->WriteStatementCenter('www.phoronix-test-suite.com');842 $pdf->Ln(15);843 $pdf->WriteBigHeaderCenter($result_file->get_title());844 $pdf->WriteText($result_file->get_description());845 // Executive Summary846 $highlight_result = null;847 if(isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1)848 {849 $highlight_result = $extra_attributes['highlight_graph_values'][0];850 }851 $exec_summary = pts_result_file_analyzer::generate_executive_summary($result_file, $highlight_result);852 if(!empty($exec_summary))853 {854 $pdf->CreateBookmark('Automated Executive Summary', 0);855 $pdf->WriteText('Automated Executive Summary', 'B');856 $pdf->WriteText(implode(PHP_EOL . PHP_EOL, $exec_summary), 'I');857 }858 $pdf->Ln(5);859 //$pdf->WriteText('This file was automatically generated via the Phoronix Test Suite benchmarking software.', 'I');860 //$pdf->AddPage();861 $pdf->Ln(15);862 $pdf->SetSubject($result_file->get_title() . ' Benchmarks');863 //$pdf->SetKeywords(implode(', ', $identifiers));864 $pdf->WriteHeader('Test Systems:');865 $pdf->CreateBookmark('System Information', 0);866 $systems = $result_file->get_systems();867 $system_count = count($systems);868 foreach($systems as $i => $system)869 {870 $pdf->Ln(5);871 $pdf->CreateBookmark($system->get_identifier(), 1);872 $pdf->WriteMiniHeader($system->get_identifier());873 if(isset($systems[($i + 1)]) && $systems[($i + 1)]->get_hardware() == $system->get_hardware() && $systems[($i + 1)]->get_software() == $system->get_software())874 {875 continue;876 }877 $pdf->WriteText($system->get_hardware());878 $pdf->WriteText($system->get_software());879 $attributes = array();880 pts_result_file_analyzer::system_to_note_array($system, $attributes);881 foreach($attributes as $section => $data)882 {883 //$pdf->WriteMiniText($section . ' Notes');884 foreach($data as $c => $val)885 {886 $pdf->WriteMiniText($section . ' Notes: ' . $val);887 }888 }889 $pdf->Ln();890 }891 //$pdf->AddPage();892 $columns = $result_file->get_system_identifiers();893 array_unshift($columns, ' ');894 $table_data = array();895 $table_data_hints = array();896 $row = 0;897 $last_test_profile = null;898 foreach($result_file->get_result_objects() as $ro)899 {900 if($ro->test_profile->get_display_format() != 'BAR_GRAPH' || $ro->test_result_buffer->get_max_value() == null)901 {902 continue;903 }904 if($last_test_profile != null && $last_test_profile != $ro->test_profile->get_identifier())905 {906 $geo_for_test = pts_result_file_analyzer::generate_geometric_mean_result($result_file, false, $last_test_profile);907 if(false && $geo_for_test)908 {909 $table_data[$row][0] = $geo_for_test->test_profile->get_title();910 $table_data_hints[$row][0] = 'divide';911 for($i = 1; $i < count($columns); $i++)912 {913 $table_data[$row][$i] = ' ';914 }915 $best = $geo_for_test->get_result_first(false);916 $worst = $geo_for_test->get_result_last(false);917 foreach($geo_for_test->test_result_buffer->get_buffer_items() as $index => $buffer_item)918 {919 $identifier = $buffer_item->get_result_identifier();920 $value = $buffer_item->get_result_value();921 if(($x = array_search($identifier, $columns)) !== false)922 {923 $table_data_hints[$row][$x] = 'divide';924 switch($value)925 {926 case $best:927 $table_data_hints[$row][$x] = 'green';928 break;929 case $worst:930 $table_data_hints[$row][$x] = 'red';931 break;932 }933 if($value > 1000)934 {935 $value = round($value);936 }937 $table_data[$row][$x] = $value;938 }939 }940 $row++;941 }942 }943 $last_test_profile = $ro->test_profile->get_identifier();944 $table_data[$row][0] = $ro->test_profile->get_title() . ($ro->get_arguments_description() != null ? ' - ' : null) . $ro->get_arguments_description_shortened() . ' (' . $ro->test_profile->get_result_scale_shortened() . ')';945 for($i = 1; $i < count($columns); $i++)946 {947 $table_data[$row][$i] = ' ';948 }949 $hib = $ro->test_profile->get_result_proportion() == 'HIB';950 $best = $ro->get_result_first(false);951 $worst = $ro->get_result_last(false);952 if($best == $worst)953 {954 $best = -1;955 $worst = -1;956 }957 $normalize_against = 0;958 if(isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1)959 {960 $normalize_against = $ro->get_result_value_from_name($extra_attributes['highlight_graph_values'][0]);961 }962 if($normalize_against == 0)963 {964 $normalize_against = $best;965 }966 $extra_rows = array(array(), array());967 foreach($ro->test_result_buffer->get_buffer_items() as $index => $buffer_item)968 {969 $identifier = $buffer_item->get_result_identifier();970 $value = $buffer_item->get_result_value();971 if(($x = array_search($identifier, $columns)) !== false)972 {973 switch($value)974 {975 case $best:976 $table_data_hints[$row][$x] = 'green';977 break;978 case $worst:979 $table_data_hints[$row][$x] = 'red';980 break;981 }982 if($normalize_against != -1)983 {984 $extra_rows[0][0] = 'Normalized';985 $extra_rows[0][$x] = round(($hib ? ($value / $normalize_against) : ($normalize_against / $value)) * 100, 2) . '%';986 }987 $raw = $buffer_item->get_result_raw_array();988 if(count($raw) > 1)989 {990 $extra_rows[1][0] = 'Standard Deviation';991 $extra_rows[1][$x] = round(pts_math::percent_standard_deviation($raw), 1) . '%';992 }993 if($value > 1000)994 {995 $value = round($value);996 }997 $table_data[$row][$x] = $value;998 }999 }1000 foreach($extra_rows as $extra_row)1001 {1002 if(empty($extra_row))1003 {1004 continue;1005 }1006 $row++;1007 for($i = 0; $i < count($columns); $i++)1008 {1009 $table_data[$row][$i] = ' ';1010 $table_data_hints[$row][$i] = 'small';1011 }1012 foreach($extra_row as $x => $value)1013 {1014 $table_data[$row][$x] = $value;1015 $table_data_hints[$row][$x] = 'small';1016 }1017 }1018 $row++;1019 }1020 $pdf->CreateBookmark('Result Overview Table', 0);1021 $pdf->ResultTable($columns, $table_data, $table_data_hints);1022 $pdf->AddPage();1023 /*1024 if($result_file->get_system_count() == 2)1025 {1026 $graph = new pts_graph_run_vs_run($result_file);1027 if($graph)1028 {1029 //$graph = pts_render::render_graph_process($graph, $result_file, $extra_attributes);1030 self::add_graph_result_object_to_pdf($pdf, $graph);1031 }1032 }1033 else if(!$result_file->is_multi_way_comparison())1034 {1035 foreach(array('', 'Per Watt', 'Per Dollar') as $selector)1036 {1037 $graph = new pts_graph_radar_chart($result_file, $selector);1038 if($graph)1039 {1040 //$graph = pts_render::render_graph_process($graph, $result_file, $extra_attributes);1041 self::add_graph_result_object_to_pdf($pdf, $graph);1042 }1043 }1044 }1045 */1046 $last_result_title = null;1047 $extra_attributes['pdf_generation'] = true;1048 foreach($result_file->get_result_objects() as $key => $result_object)1049 {1050 if($last_result_title != $result_object->test_profile->get_title())1051 {1052 $last_result_title = $result_object->test_profile->get_title();1053 $pdf->CreateBookmark($last_result_title, 0);1054 }1055 $graph = pts_render::render_graph_process($result_object, $result_file, false, $extra_attributes);1056 self::add_graph_result_object_to_pdf($pdf, $graph);1057 if($result_object->get_annotation() != null)1058 {1059 $pdf->WriteText($result_object->get_annotation());1060 }1061 }1062 $geo_mean_for_suites = pts_result_file_analyzer::generate_geometric_mean_result_for_suites_in_result_file($result_file, true, 18);1063 if(!empty($geo_mean_for_suites))1064 {1065 $pdf->AddPage();1066 $pdf->CreateBookmark('Geometric Means', 0);1067 $pdf->WriteText('These geometric means are based upon test groupings / test suites for this result file.');1068 foreach($geo_mean_for_suites as $result_object)1069 {1070 $pdf->CreateBookmark(str_replace('Geometric Mean Of ', '', $result_object->test_profile->get_title()), 1);1071 $graph = pts_render::render_graph_process($result_object, $result_file, false, $extra_attributes);1072 self::add_graph_result_object_to_pdf($pdf, $graph);1073 if($result_object->get_annotation() != null)1074 {1075 $pdf->WriteText($result_object->get_annotation());1076 }1077 }1078 }1079 $pdf->WriteText('This file was automatically generated via the Phoronix Test Suite benchmarking software on ' . date('l, j F Y H:i') . '.', 'I');1080 ob_get_clean();1081 return $pdf->Output($dest, $output_name);1082 }1083 protected static function add_graph_result_object_to_pdf(&$pdf, &$graph)1084 {1085 if($graph == false)1086 {1087 return false;1088 }1089 $graph->renderGraph();1090 $tmp_file = sys_get_temp_dir() . '/' . microtime() . rand(0, 999) . '.png';1091 $output = $graph->svg_dom->output($tmp_file);1092 if(!is_file($tmp_file))1093 {1094 return false;1095 }1096 //$pdf->Ln(1);1097 $pdf->Image($tmp_file);1098 unlink($tmp_file);1099 }1100 public static function text_box_plut_from_ae(&$ae_data, $active_result = -1, $results_to_show = array(), &$result_object = false, $percentiles = null, $sample_count = -1)1101 {1102 if($percentiles == null)1103 {1104 $percentiles = isset($ae_data['percentiles']) ? $ae_data['percentiles'] : array();1105 }1106 if(empty($percentiles))1107 {1108 return false;1109 }1110 if($sample_count == -1)1111 {1112 $sample_count = $ae_data['samples'];1113 }1114 $terminal_width = pts_client::terminal_width();1115 $box_plot = str_repeat(' ', $terminal_width - 4);1116 $box_plot_size = strlen($box_plot);1117 $box_plot = str_split($box_plot);1118 $max_value = max(max($percentiles), $active_result);1119 $hib = $ae_data['hib'] == 1 && strtolower($ae_data['unit']) != 'seconds';1120 if($hib)1121 {1122 $max_value = $max_value * 1.02;1123 }1124 $results_at_pos = array(0, 1, ($box_plot_size - 1));1125 // BOX PLOT1126 $whisker_bottom = $percentiles[2];1127 $whisker_top = $percentiles[98];1128 $whisker_start_char = round($whisker_bottom / $max_value * $box_plot_size);1129 $whisker_end_char = round($whisker_top / $max_value * $box_plot_size);1130 for($i = $whisker_start_char; $i <= $whisker_end_char && $i < ($box_plot_size - 1); $i++)1131 {1132 $box_plot[$i] = '-';1133 }1134 $box_left = floor(($percentiles[25] / $max_value) * $box_plot_size);1135 $box_middle = round(($percentiles[50] / $max_value) * $box_plot_size);1136 $box_right = ceil(($percentiles[75] / $max_value) * $box_plot_size);1137 for($i = $box_left; $i <= $box_right; $i++)1138 {1139 $box_plot[$i] = '#';1140 }1141 $box_plot[$whisker_start_char] = '|';1142 $box_plot[min($whisker_end_char, ($box_plot_size - 1))] = '|';1143 $box_plot[$box_middle] = '!';1144 // END OF BOX PLOT1145 if(!$hib)1146 {1147 $box_plot = array_reverse($box_plot);1148 }1149 $box_plot[0] = '[';1150 $box_plot[($box_plot_size - 1)] = ']';1151 if($active_result < $max_value)1152 {1153 $box_plot_complement = array();1154 for($i = 0; $i < 6; $i++)1155 {1156 $box_plot_complement[$i] = str_repeat(' ', $terminal_width - 4);1157 $box_plot_complement[$i] = str_split($box_plot_complement[$i]);1158 }1159 $reference_results_added = 0;1160 if(isset($ae_data['reference_results']) && is_array($ae_data['reference_results']))1161 {1162 $st = phodevi_base::determine_system_type(phodevi::system_hardware(), phodevi::system_software());1163 foreach($ae_data['reference_results'] as $component => $value)1164 {1165 $this_type = phodevi_base::determine_system_type($component, $component);1166 if($this_type == $st)1167 {1168 $results_to_show[$component] = $value;1169 unset($ae_data['reference_results'][$component]);1170 }1171 }1172 foreach($ae_data['reference_results'] as $component => $value)1173 {1174 $results_to_show[$component] = $value;1175 }1176 }1177 else if(empty($results_to_show))1178 {1179 // Show some common percentile marks for some perspective1180 foreach(array(10, 25, 60, 75, 90) as $p_to_show)1181 {1182 $value = $percentiles[($hib ? $p_to_show : 100 - $p_to_show)];1183 if($value > 60)1184 {1185 $value = round($percentiles[($hib ? $p_to_show : 100 - $p_to_show)]);1186 }1187 $results_to_show[pts_strings::number_suffix_handler($p_to_show) . ' Percentile'] = $value;1188 }1189 }1190 if($active_result > 0)1191 {1192 $this_result_percentile = -1;1193 foreach($percentiles as $percentile => $v)1194 {1195 if(!$hib)1196 {1197 if($v > $active_result)1198 {1199 $this_result_percentile = 100 - $percentile ;1200 break;1201 }1202 }1203 else if($v > $active_result)1204 {1205 $this_result_percentile = $percentile - 1;1206 break;1207 }1208 }1209 $results_to_show = array_merge(array('This Result' . ($this_result_percentile > 0 && $this_result_percentile < 100 ? ' (' . pts_strings::number_suffix_handler($this_result_percentile) . ' Percentile)' : '') => ($active_result > 99 ? round($active_result) : $active_result)), $results_to_show);1210 }1211 foreach($results_to_show as $component => $value)1212 {1213 if($value > $max_value)1214 {1215 continue;1216 }1217 $this_result_pos = round($value / $max_value * $box_plot_size);1218 if(in_array($this_result_pos, $results_at_pos) || (strpos($component, 'This Result') === false && !in_array((isset($box_plot[$this_result_pos]) ? $box_plot[$this_result_pos] : null), array(' ', '-', '#'))))1219 {1220 continue;1221 }1222 $skip_result = false;1223 foreach(array(' Sample', 'Confidential') as $avoid_strings)1224 {1225 // Extra protection1226 if(stripos($component, $avoid_strings) !== false)1227 {1228 $skip_result = true;1229 break;1230 }1231 }1232 if($skip_result)1233 {1234 continue;1235 }1236 // Blocks other entries from overwriting or being immediately adjacent to one another1237 $results_at_pos[] = $this_result_pos;1238 $results_at_pos[] = $this_result_pos - 1;1239 $results_at_pos[] = $this_result_pos + 1;1240 if($terminal_width <= 80)1241 {1242 // Try to shorten up some components/identifiers if terminal narrow to fit in more data1243 $component = str_replace(array('AMD ', 'Intel ', 'NVIDIA ', 'Radeon ', 'GeForce ', ' '), ' ', str_replace(' x ', ' x ', $component));1244 $component = str_replace('Ryzen Threadripper', 'Threadripper', $component);1245 $component = trim($component);1246 }1247 foreach(array('-Core', ' with ') as $cutoff)1248 {1249 // On AMD product strings, trip the XX-Core from string to save space...1250 // Similarly some "APU with Radeon" text also chop off1251 if(($cc = strpos($component, $cutoff)) !== false)1252 {1253 $component = substr($component, 0, $cc);1254 $component = substr($component, 0, strrpos($component, ' '));1255 }1256 }1257 if(empty($component))1258 {1259 continue;1260 }1261 if(!$hib)1262 {1263 $this_result_pos = $box_plot_size - $this_result_pos;1264 }1265 $string_to_show_length = strlen('^ ' . $component . ': ' . $value);1266 if($this_result_pos - $string_to_show_length - 3 > 4)1267 {1268 // print to left1269 $string_to_print = $component . ': ' . $value . ' ^';1270 $write_pos = ($this_result_pos - strlen($string_to_print) + 1);1271 }1272 else if($this_result_pos + $string_to_show_length < ($terminal_width - 3))1273 {1274 // print to right of line1275 $string_to_print = '^ ' . $component . ': ' . $value;1276 $write_pos = $this_result_pos;1277 }1278 else1279 {1280 continue;1281 }1282 // validate no overwrites1283 $complement_line = ($reference_results_added % 5);1284 if($complement_line == 0 && strpos($component, 'This Result') === false)1285 {1286 $complement_line = 1;1287 }1288 $no_overwrites = true;1289 for($i = $write_pos; $i < ($write_pos + $string_to_show_length) + 1 && isset($box_plot_complement[$complement_line][$i]); $i++)1290 {1291 if($box_plot_complement[$complement_line][$i] != ' ')1292 {1293 $no_overwrites = false;1294 break;1295 }1296 }1297 if($no_overwrites == false)1298 {1299 continue;1300 }1301 // end1302 $brand_color = null;1303 if(strpos($component, 'This Result') !== false)1304 {1305 $brand_color = 'cyan';1306 $string_to_print = pts_client::cli_colored_text($string_to_print, 'cyan', true);1307 $box_plot[$this_result_pos] = pts_client::cli_colored_text('X', 'cyan', true);1308 }1309 else if($result_object && in_array($component, $result_object->test_result_buffer->get_identifiers()))1310 {1311 $string_to_print = pts_client::cli_colored_text($string_to_print, 'white', true);1312 }1313 else if(($brand_color = pts_render::identifier_to_brand_color($component, null)) != null)1314 {1315 $brand_color = pts_client::hex_color_to_string($brand_color);1316 $string_to_print = pts_client::cli_colored_text($string_to_print, $brand_color, false);1317 }1318 for($i = $write_pos; $i < ($write_pos + $string_to_show_length) && $i < count($box_plot_complement[$complement_line]); $i++)1319 {1320 $box_plot_complement[$complement_line][$i] = '';1321 }1322 $box_plot_complement[$complement_line][$write_pos] = $string_to_print;1323 $box_plot[$this_result_pos] = pts_client::cli_colored_text('*', $brand_color, false);1324 $reference_results_added++;1325 }1326 $last_appeared_text = '';1327 if(isset($ae_data['last_appeared']) && $ae_data['last_appeared'] > 0 && $ae_data['last_appeared'] < (time() - (86400 * 30)))...

Full Screen

Full Screen

identifier_to_brand_color

Using AI Code Generation

copy

Full Screen

1require_once('pts-core.php');2$color = pts_render::identifier_to_brand_color('amd');3echo $color;4require_once('pts-core.php');5$color = pts_render::identifier_to_brand_color('nvidia');6echo $color;7require_once('pts-core.php');8$color = pts_render::identifier_to_brand_color('intel');9echo $color;10require_once('pts-core.php');11$color = pts_render::identifier_to_brand_color('arm');12echo $color;13require_once('pts-core.php');14$color = pts_render::identifier_to_brand_color('qualcomm');15echo $color;16require_once('pts-core.php');17$color = pts_render::identifier_to_brand_color('nvidia');18echo $color;19require_once('pts-core.php');20$color = pts_render::identifier_to_brand_color('amd');21echo $color;22require_once('pts-core.php');23$color = pts_render::identifier_to_brand_color('intel');24echo $color;25require_once('pts-core.php');26$color = pts_render::identifier_to_brand_color('arm');27echo $color;28require_once('pts-core.php');29$color = pts_render::identifier_to_brand_color('qualcomm');30echo $color;31require_once('pts-core.php');32$color = pts_render::identifier_to_brand_color('nvidia');33echo $color;

Full Screen

Full Screen

identifier_to_brand_color

Using AI Code Generation

copy

Full Screen

1require_once 'phoronix-test-suite.php';2echo pts_render::identifier_to_brand_color('pts/test-identifier');3echo pts_render::identifier_to_brand_color('pts/test-identifier', true);4require_once 'phoronix-test-suite.php';5echo pts_render::identifier_to_brand_color('pts/test-identifier');6echo pts_render::identifier_to_brand_color('pts/test-identifier', true);7require_once 'phoronix-test-suite.php';8echo pts_render::identifier_to_brand_color('pts/test-identifier');9echo pts_render::identifier_to_brand_color('pts/test-identifier', true);10require_once 'phoronix-test-suite.php';11echo pts_render::identifier_to_brand_color('pts/test-identifier');12echo pts_render::identifier_to_brand_color('pts/test-identifier', true);13require_once 'phoronix-test-suite.php';14echo pts_render::identifier_to_brand_color('pts/test-identifier');15echo pts_render::identifier_to_brand_color('pts/test-identifier', true);16require_once 'phoronix-test-suite.php';17echo pts_render::identifier_to_brand_color('pts/test-identifier');18echo pts_render::identifier_to_brand_color('pts/test-identifier', true);19require_once 'phoronix-test-suite.php';20echo pts_render::identifier_to_brand_color('pts/test-identifier');21echo pts_render::identifier_to_brand_color('pts/test-identifier', true);22require_once 'phoronix-test-suite.php';23echo pts_render::identifier_to_brand_color('pts/test-identifier');24echo pts_render::identifier_to_brand_color('pts/test-identifier', true);25require_once 'phoronix-test-suite.php';

Full Screen

Full Screen

identifier_to_brand_color

Using AI Code Generation

copy

Full Screen

1require_once 'pts_render.php';2$brand_color = pts_render::identifier_to_brand_color('intel-core2duo-e8400');3echo $brand_color;4require_once 'pts_render.php';5$brand_color = pts_render::identifier_to_brand_color('intel-corei7-3770k');6echo $brand_color;7require_once 'pts_render.php';8$brand_color = pts_render::identifier_to_brand_color('intel-corei7-3960x');9echo $brand_color;10require_once 'pts_render.php';11$brand_color = pts_render::identifier_to_brand_color('intel-corei7-3960x');12echo $brand_color;13require_once 'pts_render.php';14$brand_color = pts_render::identifier_to_brand_color('intel-corei7-3960x');15echo $brand_color;16require_once 'pts_render.php';17$brand_color = pts_render::identifier_to_brand_color('intel-corei7-3960x');18echo $brand_color;19require_once 'pts_render.php';20$brand_color = pts_render::identifier_to_brand_color('intel-corei7-3960x');21echo $brand_color;22require_once 'pts_render.php';23$brand_color = pts_render::identifier_to_brand_color('intel-corei7-3960x');24echo $brand_color;

Full Screen

Full Screen

identifier_to_brand_color

Using AI Code Generation

copy

Full Screen

1require_once 'phoronix-test-suite.php';2$pts = new pts_client();3$brand = $pts->render->identifier_to_brand_color('debian');4echo $brand;5require_once 'phoronix-test-suite.php';6$pts = new pts_client();7$brand = $pts->render->identifier_to_brand_color('ubuntu');8echo $brand;9require_once 'phoronix-test-suite.php';10$pts = new pts_client();11$brand = $pts->render->identifier_to_brand_color('fedora');12echo $brand;13require_once 'phoronix-test-suite.php';14$pts = new pts_client();15$brand = $pts->render->identifier_to_brand_color('opensuse');16echo $brand;17require_once 'phoronix-test-suite.php';18$pts = new pts_client();19$brand = $pts->render->identifier_to_brand_color('gentoo');20echo $brand;21require_once 'phoronix-test-suite.php';22$pts = new pts_client();23$brand = $pts->render->identifier_to_brand_color('mandriva');24echo $brand;25require_once 'phoronix-test-suite.php';26$pts = new pts_client();27$brand = $pts->render->identifier_to_brand_color('slackware');28echo $brand;29require_once 'phoronix-test-suite.php';

Full Screen

Full Screen

identifier_to_brand_color

Using AI Code Generation

copy

Full Screen

1$brand = "Intel";2$hex = pts_render::identifier_to_brand_color($brand);3echo "<body style=\"background-color:$hex\">";4$brand = "AMD";5$hex = pts_render::identifier_to_brand_color($brand);6echo "<body style=\"background-color:$hex\">";7$brand = "NVIDIA";8$hex = pts_render::identifier_to_brand_color($brand);9echo "<body style=\"background-color:$hex\">";10$brand = "ARM";11$hex = pts_render::identifier_to_brand_color($brand);12echo "<body style=\"background-color:$hex\">";13$brand = "Qualcomm";14$hex = pts_render::identifier_to_brand_color($brand);15echo "<body style=\"background-color:$hex\">";16$brand = "Broadcom";17$hex = pts_render::identifier_to_brand_color($brand);18echo "<body style=\"background-color:$hex\">";19$brand = "Samsung";

Full Screen

Full Screen

identifier_to_brand_color

Using AI Code Generation

copy

Full Screen

1require_once('pts_render.php');2$render = new pts_render();3echo $render->identifier_to_brand_color('my_identifier');4echo $render->identifier_to_brand_color('my string');5echo $render->identifier_to_brand_color('my string that is not a valid identifier');6echo $render->identifier_to_brand_color('my string that is not a valid identifier');7echo $render->identifier_to_brand_color('my string that is not a valid identifier');8echo $render->identifier_to_brand_color('my string that is not a valid identifier');9echo $render->identifier_to_brand_color('my string that is not a valid identifier');10echo $render->identifier_to_brand_color('my string that is not a valid identifier');11echo $render->identifier_to_brand_color('my string that is not a valid identifier');12echo $render->identifier_to_brand_color('my string that is not a valid identifier');

Full Screen

Full Screen

identifier_to_brand_color

Using AI Code Generation

copy

Full Screen

1include('phoromatic/render.php');2$render = new pts_render();3echo $render->identifier_to_brand_color('amd');4Method 2: Using pts_render::identifier_to_brand_color() method5include('phoromatic/render.php');6echo pts_render::identifier_to_brand_color('amd');7Method 3: Using pts_render::render_identifier() method8include('phoromatic/render.php');9echo pts_render::render_identifier('amd');10Method 4: Using pts_render::render_identifier() method11include('phoromatic/render.php');12echo pts_render::render_identifier('amd', false);13Method 5: Using pts_render::render_identifier() method14include('phoromatic/render.php');15echo pts_render::render_identifier('amd', false, 'AMD');16Method 6: Using pts_render::render_identifier() method17include('phoromatic/render.php');18echo pts_render::render_identifier('amd', false, 'AMD', 'AMD');19Method 7: Using pts_render::render_identifier() method20include('phoromatic/render.php');21echo pts_render::render_identifier('amd', false, 'AMD', 'AMD', 'AMD');22Method 8: Using pts_render::render_identifier() method

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger identifier_to_brand_color code on LambdaTest Cloud Grid

Execute automation tests with identifier_to_brand_color on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful