How to use check_for_frame_time_parsing method of pts_test_result_parser class

Best Phoronix-test-suite code snippet using pts_test_result_parser.check_for_frame_time_parsing

pts_test_result_parser.php

Source:pts_test_result_parser.php Github

copy

Full Screen

...556 }557 }558 }559 // Check if frame time parsing info560 if(self::check_for_frame_time_parsing($test_results, $template, $output, $prefix))561 {562 // Was frame time info, nothing else to do for parsing, $test_results already filled then563 }564 else565 {566 // Conventional searching for matching section for finding result567 if($e->get_delete_output_before() != null && ($x = strpos($output, $e->get_delete_output_before())) !== false)568 {569 $output = substr($output, $x);570 }571 if($e->get_delete_output_after() != null && ($x = strpos($output, $e->get_delete_output_after())) !== false)572 {573 $output = substr($output, 0, $x);574 }575 $line_before_hint = $e->get_line_before_hint();576 $line_after_hint = $e->get_line_after_hint();577 $line_hint = $e->get_line_hint();578 $search_key = self::determine_search_key($output, $line_hint, $line_before_hint, $line_after_hint, $template_line, $template, $template_r, $key_for_result); // SEARCH KEY579 if($search_key != null || $line_before_hint != null || $line_after_hint != null || $template_r[0] == $key_for_result)580 {581 $is_multi_match = !empty($multi_match) && $multi_match != 'NONE';582 do583 {584 $count = count($test_results);585 $possible_lines = array();586 if($line_before_hint != null)587 {588 pts_test_result_parser::debug_message('Result Parsing Line Before Hint: ' . $line_before_hint);589 $line = substr($output, strpos($output, "\n", strrpos($output, $line_before_hint)));590 $line = substr($line, 0, strpos($line, "\n", 1));591 $output = substr($output, 0, strrpos($output, "\n", strrpos($output, $line_before_hint))) . "\n";592 }593 else if($line_after_hint != null)594 {595 pts_test_result_parser::debug_message('Result Parsing Line After Hint: ' . $line_after_hint);596 $line = substr($output, 0, strrpos($output, "\n", strrpos($output, $line_after_hint)));597 $line = substr($line, strrpos($line, "\n", 1) + 1);598 $output = null;599 }600 else if($search_key != null)601 {602 if(trim($search_key) != null)603 {604 $search_key = trim($search_key);605 }606 pts_test_result_parser::debug_message('Result Parsing Search Key: "' . $search_key . '"');607 while(($line_x = strrpos($output, $search_key)) !== false)608 {609 $line = substr($output, 0, strpos($output, "\n", $line_x));610 $start_of_line = strrpos($line, "\n");611 $output = substr($line, 0, $start_of_line) . "\n";612 $possible_lines[] = substr($line, $start_of_line + 1);613 if((count($possible_lines) > 16 && $is_multi_match && phodevi::is_windows()) || $multi_match == 'REPORT_ALL')614 {615 // This vastly speeds up pts/dav1d result decoding on Windows as this expensive loop not used616 break;617 }618 }619 $line = !empty($possible_lines) ? array_shift($possible_lines) : null;620 }621 else622 {623 // Condition $template_r[0] == $key, include entire file since there is nothing to search624 pts_test_result_parser::debug_message('No Result Parsing Hint, Including Entire Result Output');625 $line = trim($output);626 }627 if($e->get_turn_chars_to_space() != null)628 {629 $line = str_replace($e->get_turn_chars_to_space(), ' ', $line);630 }631 pts_test_result_parser::debug_message('Result Line: ' . $line);632 // FALLBACK HELPERS FOR BELOW633 $did_try_colon_fallback = false;634 do635 {636 $try_again = false;637 $r = explode(' ', pts_strings::trim_spaces(str_replace($space_out_chars, ' ', str_replace('=', ' = ', $line))));638 $r_pos = array_search($key_for_result, $r);639 if($e->get_result_before_string() != null)640 {641 // Using ResultBeforeString tag642 $before_this = array_search($e->get_result_before_string(), $r);643 if($before_this && isset($r[($before_this - 1)]))644 {645 $possible_res = $r[($before_this - 1)];646 self::strip_result_cleaner($possible_res, $e);647 if($before_this !== false && (!$is_numeric_check || self::valid_numeric_input_handler($possible_res, $line)))648 {649 $test_results[] = $possible_res;650 }651 }652 }653 else if($e->get_result_after_string() != null)654 {655 // Using ResultBeforeString tag656 $after_this = array_search($e->get_result_after_string(), $r);657 if($after_this !== false)658 {659 $after_this++;660 for($f = $after_this; $f < count($r); $f++)661 {662 if(in_array($r[$f], array(':', ',', '-', '=')))663 {664 continue;665 }666 self::strip_result_cleaner($r[$f], $e);667 if(!$is_numeric_check || self::valid_numeric_input_handler($r[$f], $line))668 {669 $test_results[] = $r[$f];670 }671 break;672 }673 }674 }675 else if(isset($r[$template_r_pos]))676 {677 self::strip_result_cleaner($r[$template_r_pos], $e);678 if(!$is_numeric_check || self::valid_numeric_input_handler($r[$template_r_pos], $line))679 {680 $test_results[] = $r[$template_r_pos];681 }682 }683 else684 {685 // POSSIBLE FALLBACKS TO TRY AGAIN686 if(!$did_try_colon_fallback && strpos($line, ':') !== false)687 {688 $line = str_replace(':', ': ', $line);689 $did_try_colon_fallback = true;690 $try_again = true;691 }692 }693 if($try_again == false && empty($test_results) && !empty($possible_lines))694 {695 $line = array_shift($possible_lines);696 pts_test_result_parser::debug_message('Trying Backup Result Line: ' . $line);697 $try_again = true;698 }699 else if(!empty($test_results) && $is_multi_match && !empty($possible_lines) && $search_key != null)700 {701 // Rebuild output if it was disassembled in search key code above702 $output = implode(PHP_EOL, array_reverse($possible_lines)) . PHP_EOL;703 }704 }705 while($try_again);706 }707 while($is_multi_match && count($test_results) != $count && !empty($output));708 }709 }710 RESULTPOSTPROCESSING:711 if(empty($test_results))712 {713 pts_test_result_parser::debug_message('No Test Results');714 return false;715 }716 $multiply_by = $e->get_multiply_result_by();717 $divide_by = $e->get_divide_result_by();718 $divide_divisor = $e->get_divide_result_divisor();719 foreach($test_results as $x => &$test_result)720 {721 self::strip_result_cleaner($test_result, $e);722 // Expand validity checking here723 if($is_numeric_check == true && is_numeric($test_result) == false)724 {725 // E.g. if output time as 06:12.32 (as in blender)726 if(substr_count($test_result, ':') == 1 && substr_count($test_result, '.') == 1 && strpos($test_result, '.') > strpos($test_result, ':'))727 {728 $minutes = substr($test_result, 0, strpos($test_result, ':'));729 $seconds = ' ' . substr($test_result, strpos($test_result, ':') + 1);730 $test_result = ($minutes * 60) + $seconds;731 }732 }733 if($is_numeric_check == true && is_numeric($test_result) == false)734 {735 unset($test_results[$x]);736 continue;737 }738 if($divide_by != null && is_numeric($divide_by) && $divide_by != 0)739 {740 $test_result = $test_result / $divide_by;741 }742 if($divide_divisor != null && is_numeric($divide_divisor) && $divide_divisor != 0 && $test_result != 0)743 {744 $test_result = $divide_divisor / $test_result;745 }746 if($multiply_by != null && is_numeric($multiply_by) && $multiply_by != 0)747 {748 $test_result = $test_result * $multiply_by;749 }750 }751 if(empty($test_results))752 {753 pts_test_result_parser::debug_message('No Test Results #2');754 return false;755 }756 $test_results_group_precision = pts_math::get_precision($test_results);757 switch($multi_match)758 {759 case 'REPORT_ALL':760 $test_result = implode(',', $test_results);761 $e->set_display_format('LINE_GRAPH');762 $is_numeric_check = false;763 break;764 case 'GEOMETRIC_MEAN':765 if($is_numeric_check)766 {767 $test_result = round(pts_math::geometric_mean($test_results), $test_results_group_precision);768 if(count($test_results) > 1)769 {770 $min_test_result = min($test_results);771 $max_test_result = max($test_results);772 }773 break;774 }775 case 'HARMONIC_MEAN':776 if($is_numeric_check)777 {778 $test_result = round(pts_math::harmonic_mean($test_results), $test_results_group_precision);779 if(count($test_results) > 1)780 {781 $min_test_result = min($test_results);782 $max_test_result = max($test_results);783 }784 break;785 }786 case 'AVERAGE':787 case 'MEAN':788 default:789 if($is_numeric_check)790 {791 $test_result = round(pts_math::arithmetic_mean($test_results), $test_results_group_precision);792 if(count($test_results) > 1)793 {794 $min_test_result = min($test_results);795 $max_test_result = max($test_results);796 }797 }798 break;799 }800 if($is_pass_fail_test)801 {802 if(str_replace(array('PASS', 'FAIL', ','), null, $test_result) == null)803 {804 // already a properly formatted multi-pass fail805 }806 else if($test_result == 'TRUE' || $test_result == 'PASSED')807 {808 // pass809 $test_result = 'PASS';810 }811 else812 {813 // fail814 $test_result = 'FAIL';815 }816 }817 else if($is_numeric_check && !is_numeric($test_result))818 {819 // Final check to ensure valid data820 $test_result = false;821 }822 if($test_result != false)823 {824 if($e->get_result_scale() != null)825 {826 $test_run_request->test_profile->set_result_scale($e->get_result_scale());827 }828 if($e->get_result_proportion() != null)829 {830 $test_run_request->test_profile->set_result_proportion($e->get_result_proportion());831 }832 if($e->get_display_format() != null)833 {834 $test_run_request->test_profile->set_display_format($e->get_display_format());835 }836 if($e->get_result_precision() != null)837 {838 $test_run_request->set_result_precision($e->get_result_precision());839 }840 if($e->get_arguments_description() != null)841 {842 $test_run_request->set_used_arguments_description($e->get_arguments_description());843 }844 if($e->get_append_to_arguments_description() != null)845 {846 foreach($all_parser_entries as $parser_entry)847 {848 if($parser_entry->get_append_to_arguments_description() != null)849 {850 $test_run_request->remove_from_used_arguments_description(' - ' . $parser_entry->get_append_to_arguments_description());851 }852 }853 $test_run_request->append_to_arguments_description(' - ' . $e->get_append_to_arguments_description());854 }855 }856 pts_test_result_parser::debug_message('Test Result Parser Returning: ' . $test_result);857 return $test_result;858 }859 protected static function valid_numeric_input_handler(&$numeric_input, $line)860 {861 if(is_numeric($numeric_input))862 {863 return true;864 }865 else if(is_numeric(str_ireplace(array('m', 'h', 's'), '', $numeric_input)))866 {867 // XXhXXmXXs format868 $vtime = 0;869 $ni = $numeric_input;870 foreach(array(3600 => 'h', 60 => 'm', 1 => 's') as $m => $u)871 {872 if(($x = stripos($ni, $u)) !== false)873 {874 $extracted = substr($ni, 0, $x);875 $ni = substr($ni, ($x + 1));876 if(is_numeric($extracted))877 {878 $vtime += $extracted * $m;879 }880 else881 {882 return false;883 }884 }885 }886 if($vtime > 0 && is_numeric($vtime))887 {888 $numeric_input = $vtime;889 return true;890 }891 }892 else if(strpos($numeric_input, ':') !== false && strpos($numeric_input, '.') !== false && is_numeric(str_replace(array(':', '.'), null, $numeric_input)) && stripos($line, 'time') !== false)893 {894 // Convert e.g. 03:03.17 to seconds, relevant for at least pts/blender895 $seconds = 0;896 $formatted_time = $numeric_input;897 if(($c = strpos($formatted_time, ':')) !== false && strrpos($formatted_time, ':') == $c && is_numeric(substr($formatted_time, 0, $c)))898 {899 $seconds = (substr($formatted_time, 0, $c) * 60) + substr($formatted_time, ($c + 1));900 }901 if(!empty($seconds))902 {903 $numeric_input = $seconds;904 return true;905 }906 }907 else if(strpos($numeric_input, ':') !== false && strtolower(substr($numeric_input, -1)) == 's')908 {909 // e.g. 01h:04m:33s910 $seconds = 0;911 $invalid = false;912 foreach(explode(':', $numeric_input) as $time_segment)913 {914 $postfix = strtolower(substr($time_segment, -1));915 $value = substr($time_segment, 0, -1);916 if($value == 0 || !is_numeric($value))917 {918 continue;919 }920 switch($postfix)921 {922 case 'h':923 $seconds += ($value * 3600);924 break;925 case 'm':926 $seconds += ($value * 60);927 break;928 case 's':929 $seconds += $value;930 break;931 default:932 $invalid = true;933 break;934 }935 }936 if(!empty($seconds) && $seconds > 0 && !$invalid)937 {938 $numeric_input = $seconds;939 return true;940 }941 }942 return false;943 }944 protected static function strip_result_cleaner(&$test_result, &$e)945 {946 if($e->get_strip_from_result() != null)947 {948 $test_result = str_replace($e->get_strip_from_result(), null, $test_result);949 }950 if($e->get_strip_result_postfix() != null && substr($test_result, 0 - strlen($e->get_strip_result_postfix())) == $e->get_strip_result_postfix())951 {952 $test_result = substr($test_result, 0, 0 - strlen($e->get_strip_result_postfix()));953 }954 if(!is_numeric($test_result) && is_numeric(substr($test_result, 0, -1)))955 {956 // The test_result is numeric except for the last character, possible k/M prefix or so957 // Or do any other format conversion here958 // Made in PTS 9.4, this shouldn't break any existing result-definitions since it would have been non-numeric here already959 $result_without_last_char = substr($test_result, 0, -1);960 switch(strtolower(substr($test_result, -1)))961 {962 case 'k':963 $test_result = $result_without_last_char * 1000;964 break;965 case 'm':966 $test_result = $result_without_last_char * 1000000;967 break;968 }969 }970 }971 protected static function determine_search_key(&$output, $line_hint, $line_before_hint, $line_after_hint, $template_line, $template, $template_r, $key)972 {973 // Determine the search key to use974 $search_key = null;975 if(isset($line_hint) && $line_hint != null && strpos($template_line, $line_hint) !== false)976 {977 $search_key = $line_hint;978 }979 else if($line_before_hint != null && $line_hint != null && strpos($template, $line_hint) !== false)980 {981 $search_key = null; // doesn't really matter what this value is982 }983 else if($line_after_hint != null && $line_hint != null && strpos($template, $line_hint) !== false)984 {985 $search_key = null; // doesn't really matter what this value is986 }987 else988 {989 $first_portion_of_line = substr($template_line, 0, strpos($template_line, $key));990 if($first_portion_of_line != null && strpos($output, $first_portion_of_line) !== false)991 {992 $search_key = $first_portion_of_line;993 }994 if($search_key == null)995 {996 foreach($template_r as $line_part)997 {998 if(strpos($line_part, ':') !== false && strlen($line_part) > 1)999 {1000 // add some sort of && strrpos($template, $line_part) to make sure there isn't two of the same $search_key1001 $search_key = $line_part;1002 break;1003 }1004 }1005 }1006 if($search_key == null && $key != null)1007 {1008 // Just try searching for the first part of the string1009 /*1010 for($i = 0; $i < $template_r_pos; $i++)1011 {1012 $search_key .= $template_r . ' ';1013 }1014 */1015 // This way if there are ) or other characters stripped, the below method will work where the above one will not1016 $search_key = substr($template_line, 0, strpos($template_line, $key));1017 }1018 }1019 return $search_key;1020 }1021 protected static function check_for_frame_time_parsing(&$test_results, $template, $output, $prefix)1022 {1023 $frame_time_values = null;1024 $returns = false;1025 if($template == 'libframetime-output' || $template == 'libframetime-output-no-limit')1026 {1027 $returns = true;1028 $frame_time_values = array();1029 $line_values = explode(PHP_EOL, $output);1030 if(!empty($line_values) && isset($line_values[3]))1031 {1032 foreach($line_values as &$v)1033 {1034 if(substr($v, -3) == ' us' && substr($v, 0, 10) == 'Frametime ')1035 {...

Full Screen

Full Screen

check_for_frame_time_parsing

Using AI Code Generation

copy

Full Screen

1require_once('pts-test-result-parser.php');2$test_result_parser = new pts_test_result_parser();3$test_result_parser->check_for_frame_time_parsing('2.txt');4require_once('pts-test-result-parser.php');5$test_result_parser = new pts_test_result_parser();6$test_result_parser->check_for_frame_time_parsing('3.txt');7require_once('pts-test-result-parser.php');8$test_result_parser = new pts_test_result_parser();9$test_result_parser->check_for_frame_time_parsing('4.txt');10require_once('pts-test-result-parser.php');11$test_result_parser = new pts_test_result_parser();12$test_result_parser->check_for_frame_time_parsing('5.txt');13require_once('pts-test-result-parser.php');14$test_result_parser = new pts_test_result_parser();15$test_result_parser->check_for_frame_time_parsing('6.txt');16require_once('pts-test-result-parser.php');17$test_result_parser = new pts_test_result_parser();18$test_result_parser->check_for_frame_time_parsing('7.txt');19require_once('pts-test-result-parser.php');20$test_result_parser = new pts_test_result_parser();21$test_result_parser->check_for_frame_time_parsing('8.txt');22require_once('pts-test-result-parser.php');23$test_result_parser = new pts_test_result_parser();24$test_result_parser->check_for_frame_time_parsing('9.txt');25require_once('pts-test-result-parser.php');

Full Screen

Full Screen

check_for_frame_time_parsing

Using AI Code Generation

copy

Full Screen

1$test_result_parser = new pts_test_result_parser();2$test_result_parser->check_for_frame_time_parsing('2.php', 'frame_times');3$test_result_parser = new pts_test_result_parser();4$test_result_parser->check_for_frame_time_parsing('3.php', 'frame_times');5$test_result_parser = new pts_test_result_parser();6$test_result_parser->check_for_frame_time_parsing('4.php', 'frame_times');7$test_result_parser = new pts_test_result_parser();8$test_result_parser->check_for_frame_time_parsing('5.php', 'frame_times');9$test_result_parser = new pts_test_result_parser();10$test_result_parser->check_for_frame_time_parsing('6.php', 'frame_times');11$test_result_parser = new pts_test_result_parser();12$test_result_parser->check_for_frame_time_parsing('7.php', 'frame_times');13$test_result_parser = new pts_test_result_parser();14$test_result_parser->check_for_frame_time_parsing('8.php', 'frame_times');15$test_result_parser = new pts_test_result_parser();16$test_result_parser->check_for_frame_time_parsing('9.php', 'frame_times');17$test_result_parser = new pts_test_result_parser();18$test_result_parser->check_for_frame_time_parsing('10.php', 'frame_times');

Full Screen

Full Screen

check_for_frame_time_parsing

Using AI Code Generation

copy

Full Screen

1$test_result_parser = new pts_test_result_parser();2$test_result_parser->check_for_frame_time_parsing($test_result_parser->get_test_result($test_result_file));3$test_result_parser = new pts_test_result_parser();4$test_result_parser->check_for_frame_time_parsing($test_result_parser->get_test_result($test_result_file));5$test_result_parser = new pts_test_result_parser();6$test_result_parser->check_for_frame_time_parsing($test_result_parser->get_test_result($test_result_file));7$test_result_parser = new pts_test_result_parser();8$test_result_parser->check_for_frame_time_parsing($test_result_parser->get_test_result($test_result_file));9$test_result_parser = new pts_test_result_parser();10$test_result_parser->check_for_frame_time_parsing($test_result_parser->get_test_result($test_result_file));11$test_result_parser = new pts_test_result_parser();12$test_result_parser->check_for_frame_time_parsing($test_result_parser->get_test_result($test_result_file));13$test_result_parser = new pts_test_result_parser();14$test_result_parser->check_for_frame_time_parsing($test_result_parser->get_test_result($test_result_file));15$test_result_parser = new pts_test_result_parser();16$test_result_parser->check_for_frame_time_parsing($test_result_parser->get_test_result($test_result_file));17$test_result_parser = new pts_test_result_parser();18$test_result_parser->check_for_frame_time_parsing($test_result_parser->get_test_result($test_result_file));

Full Screen

Full Screen

check_for_frame_time_parsing

Using AI Code Generation

copy

Full Screen

1$test_result_file = new pts_test_result_file('result_file.xml');2$test_result_file->test_result_buffer->test_result_objects[0]->test_profile->check_for_frame_time_parsing();3$test_result_file = new pts_test_result_file('result_file.xml');4$test_result_file->test_result_buffer->test_result_objects[0]->test_profile->check_for_frame_time_parsing();5$test_result_file = new pts_test_result_file('result_file2.xml');6$test_result_file->test_result_buffer->test_result_objects[0]->test_profile->check_for_frame_time_parsing();

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 check_for_frame_time_parsing code on LambdaTest Cloud Grid

Execute automation tests with check_for_frame_time_parsing 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