Best Phoronix-test-suite code snippet using pts_test_result_parser.parse_result_process
pts_test_result_parser.php
Source:pts_test_result_parser.php
...181 case 'PASS_FAIL':182 case 'MULTI_PASS_FAIL':183 case 'BAR_GRAPH':184 default:185 $produced_result = self::parse_result_process($test_run_request, $test_log_file, $pts_test_arguments, $extra_arguments);186 break;187 }188 return $produced_result;189 }190 public static function generate_extra_data(&$test_result, &$test_log_file = null)191 {192 $definitions = $test_result->test_profile->get_results_definition('ExtraData');193 foreach($definitions->get_system_monitor_definitions() as $entry)194 {195 $frame_all_times = array();196 switch(($eid = $entry->get_identifier()))197 {198 case 'libframetime-output':199 case 'libframetime-output-no-limit':200 // libframetime output201 $line_values = explode(PHP_EOL, file_get_contents($test_log_file));202 if(!empty($line_values) && isset($line_values[3]))203 {204 foreach($line_values as &$v)205 {206 if(substr($v, -3) == ' us' && substr($v, 0, 10) == 'Frametime ')207 {208 $frametime = substr($v, 10);209 $frametime = substr($frametime, 0, -3);210 if($eid == 'libframetime-output-no-limit' || $frametime > 2000)211 {212 $frametime = $frametime / 1000;213 $frame_all_times[] = $frametime;214 }215 }216 }217 $frame_all_times = pts_math::remove_outliers($frame_all_times);218 }219 break;220 case 'csv-dump-frame-latencies':221 // Civ Beyond Earth222 $csv_values = explode(',', pts_file_io::file_get_contents($test_log_file));223 if(!isset($csv_values[10]))224 {225 $csv_values = explode(PHP_EOL, pts_file_io::file_get_contents($test_log_file));226 }227 if(!empty($csv_values) && isset($csv_values[3]))228 {229 foreach($csv_values as $i => &$v)230 {231 if(!is_numeric($v))232 {233 unset($csv_values[$i]);234 continue;235 }236 $frame_all_times[] = $v;237 }238 }239 break;240 case 'com-speeds-frame-latency-totals':241 // id Tech Games242 $log_file = pts_file_io::file_get_contents($test_log_file);243 $frame_all_times = array();244 while(($log_file = strstr($log_file, 'frame:')))245 {246 if(($a = strpos($log_file, ' all: ')) !== false && $a < strpos($log_file, "\n"))247 {248 $all = ltrim(substr($log_file, $a + 6));249 $all = substr($all, 0, strpos($all, ' '));250 if(is_numeric($all) && $all > 0)251 {252 $frame_all_times[] = $all;253 }254 }255 $log_file = strstr($log_file, 'bk:');256 }257 break;258 case 'cpu-frames-space-delimited':259 // HITMAN on Linux uses at least this method260 $log_file = pts_file_io::file_get_contents($test_log_file);261 $frame_all_times = array();262 if(($x = strpos($log_file, '---- CPU FRAMES ----')) !== false)263 {264 $log_file = trim(str_replace(PHP_EOL, ' ', substr($log_file, $x + strlen('---- CPU FRAMES ----'))));265 foreach(explode(' ', $log_file) as $inp)266 {267 if(is_numeric($inp) && $inp > 0)268 {269 $frame_all_times[] = round(1000 / $inp, 3); // since its reporting current frame270 }271 }272 }273 break;274 case 'gpu-frames-space-delimited':275 // HITMAN 2 uses at least this method276 $log_file = pts_file_io::file_get_contents($test_log_file);277 $frame_all_times = array();278 if(($x = strpos($log_file, '---- GPU FRAMES ----')) !== false)279 {280 $log_file = trim(str_replace(PHP_EOL, ' ', substr($log_file, $x + strlen('---- GPU FRAMES ----'))));281 foreach(explode(' ', $log_file) as $inp)282 {283 if(is_numeric($inp) && $inp > 0)284 {285 $frame_all_times[] = round(1000 / $inp, 3); // since its reporting current frame286 }287 }288 }289 break;290 case 'valve-source-frame-times':291 // Counter-Strike: GO At least292 $log_file = pts_file_io::file_get_contents($test_log_file);293 $frame_all_times = array();294 if(($x = strpos($log_file, 'demo tick,frame start time,frame start delta')) !== false)295 {296 $log_file = substr($log_file, $x);297 foreach(explode(PHP_EOL, $log_file) as $line)298 {299 $line = explode(',', $line);300 if(isset($line[2]) && is_numeric($line[2]) && $line[2] > 0)301 {302 $frame_all_times[] = $line[2] * 1000;303 }304 }305 }306 break;307 case 'csv-f1-frame-times':308 // F1 2018309 $log_file = pts_file_io::file_get_contents($test_log_file);310 $frame_all_times = array();311 if(($x = strpos($log_file, 'Frame,Time (ms)')) !== false)312 {313 $log_file = substr($log_file, $x);314 foreach(explode(PHP_EOL, $log_file) as $line)315 {316 $line = explode(',', $line);317 if(isset($line[1]) && is_numeric($line[1]) && $line[1] > 0)318 {319 $frame_all_times[] = $line[1];320 }321 }322 }323 break;324 case 'csv-individual-frame-times':325 // Thrones of Britannia on Linux uses at least this method326 $log_file = pts_file_io::file_get_contents($test_log_file);327 $frame_all_times = array();328 if(($x = strpos($log_file, 'individual frame times (ms):')) !== false)329 {330 $log_file = trim(str_replace(PHP_EOL, ' ', substr($log_file, $x + strlen('individual frame times (ms): '))));331 foreach(explode(', ', $log_file) as $inp)332 {333 if(is_numeric($inp) && $inp > 0)334 {335 $frame_all_times[] = $inp;336 }337 else338 {339 // hitting the end340 break;341 }342 }343 }344 break;345 }346 if(isset($frame_all_times[60]))347 {348 // Take off the first frame as it's likely to have taken much longer when game just starting off...349 // array_shift($frame_all_times);350 $tp = clone $test_result->test_profile;351 $tp->set_result_scale('Milliseconds');352 $tp->set_result_proportion('LIB');353 $tp->set_display_format('LINE_GRAPH');354 $tp->set_identifier(null);355 $extra_result = new pts_test_result($tp);356 $extra_result->active = new pts_test_result_buffer_active();357 $extra_result->set_used_arguments_description($test_result->get_arguments_description() . ' - Total Frame Time');358 $extra_result->set_used_arguments($test_result->get_arguments() . ' - ' . $extra_result->get_arguments_description()); // this formatting is weird but to preserve pre-PTS7 comparsions of extra results359 $extra_result->active->set_result(implode(',', $frame_all_times));360 self::gen_result_active_handle($test_result, $extra_result)->add_trial_run_result(implode(',', $frame_all_times));361 //$extra_result->set_used_arguments(phodevi::sensor_name($sensor) . ' ' . $test_result->get_arguments());362 }363 }364 }365 protected static function parse_iqc_result(&$test_run_request, $log_file, $pts_test_arguments, $extra_arguments)366 {367 if(!extension_loaded('gd'))368 {369 // Needs GD library to work370 return false;371 }372 $returns = false;373 $definitions = $test_run_request->test_profile->get_results_definition('ImageParser');374 foreach($definitions->get_system_monitor_definitions() as $entry)375 {376 $match_test_arguments = $entry->get_match_to_image_args();377 if(!empty($match_test_arguments) && strpos($pts_test_arguments, $match_test_arguments) === false)378 {379 // This is not the ResultsParser XML section to use as the MatchToTestArguments does not match the PTS test arguments380 continue;381 }382 $iqc_source_file = $entry->get_source_image();383 if(is_file($test_run_request->test_profile->get_install_dir() . $iqc_source_file))384 {385 $iqc_source_file = $test_run_request->test_profile->get_install_dir() . $iqc_source_file;386 }387 else388 {389 // No image file found390 continue;391 }392 $img = pts_image::image_file_to_gd($iqc_source_file);393 if($img == false)394 {395 return;396 }397 $img_sliced = imagecreatetruecolor($entry->get_image_width(), $entry->get_image_height());398 imagecopyresampled($img_sliced, $img, 0, 0, $entry->get_image_x(), $entry->get_image_y(), $entry->get_image_width(), $entry->get_image_height(), $entry->get_image_width(), $entry->get_image_height());399 $test_result = $test_run_request->test_profile->get_install_dir() . 'iqc.png';400 imagepng($img_sliced, $test_result);401 if($test_result != false)402 {403 self::gen_result_active_handle($test_run_request)->add_trial_run_result($test_result);404 $returns = true;405 }406 }407 return $returns;408 }409 protected static function parse_result_process(&$test_run_request, $log_file, $pts_test_arguments, $extra_arguments, $prefix = null)410 {411 $produced_result = false;412 if($prefix != null && substr($prefix, -1) != '_')413 {414 $prefix .= '_';415 }416 $definitions = $test_run_request->test_profile->get_results_definition('ResultsParser');417 $all_parser_entries = $definitions->get_result_parser_definitions();418 $avoid_duplicates = array();419 foreach($all_parser_entries as $entry)420 {421 $tr = clone $test_run_request;422 if($entry->get_display_format() != null)423 {424 $tr->test_profile->set_display_format($entry->get_display_format());425 }426 $is_pass_fail_test = in_array($tr->test_profile->get_display_format(), array('PASS_FAIL', 'MULTI_PASS_FAIL'));427 $is_numeric_check = !$is_pass_fail_test;428 $min_result = null;429 $max_result = null;430 $min_test_result = false;431 $max_test_result = false;432 $test_result = self::parse_result_process_entry($tr, $log_file, $pts_test_arguments, $extra_arguments, $prefix, $entry, $is_pass_fail_test, $is_numeric_check, $all_parser_entries, $min_test_result, $max_test_result);433 if($test_result != false)434 {435 // Result found436 if(in_array($test_result, $avoid_duplicates))437 {438 // Workaround for some tests like FIO that have test result parsers that could generate duplicates in handling old PTS versions while newer ones have K conversion, etc439 continue;440 }441 $avoid_duplicates[] = $test_result;442 if($is_numeric_check)443 {444 // Check if this test reports a min result value445 $min_result = $min_test_result !== false && is_numeric($min_test_result) ? $min_test_result : self::parse_result_process_entry($tr, $log_file, $pts_test_arguments, $extra_arguments, 'MIN_', $entry, $is_pass_fail_test, $is_numeric_check, $all_parser_entries);446 // Check if this test reports a max result value447 $max_result = $max_test_result !== false && is_numeric($max_test_result) ? $max_test_result : self::parse_result_process_entry($tr, $log_file, $pts_test_arguments, $extra_arguments, 'MAX_', $entry, $is_pass_fail_test, $is_numeric_check, $all_parser_entries);448 }449 self::gen_result_active_handle($test_run_request, $tr)->add_trial_run_result($test_result, $min_result, $max_result);450 $produced_result = true;451 }452 }453 return $produced_result;454 }455 protected static function parse_result_process_entry(&$test_run_request, $log_file, $pts_test_arguments, $extra_arguments, $prefix, &$e, $is_pass_fail_test, $is_numeric_check, &$all_parser_entries, &$min_test_result = false, &$max_test_result = false)456 {457 $test_result = false;458 $match_test_arguments = $e->get_match_to_test_args();459 $template = $e->get_output_template();460 $multi_match = $e->get_multi_match();461 if(!empty($match_test_arguments) && strpos($pts_test_arguments, $match_test_arguments) === false)462 {463 // This is not the ResultsParser XML section to use as the MatchToTestArguments does not match the PTS test arguments464 pts_test_result_parser::debug_message('Failed Initial Check For Matching: ' . $pts_test_arguments . ' not in ' . $match_test_arguments);465 return false;466 }467 switch($e->get_result_key())468 {469 case 'PTS_TEST_ARGUMENTS':...
parse_result_process
Using AI Code Generation
1$parser = new pts_test_result_parser();2$parser->parse_result_process($result_file);3$parser = new pts_test_result_parser();4$parser->parse_result_file($result_file);5$parser = new pts_test_result_parser();6$parser->parse_result_file($result_file, true);7$parser = new pts_test_result_parser();8$parser->parse_result_file($result_file, false, true);9$parser = new pts_test_result_parser();10$parser->parse_result_file($result_file, true, true);11$parser = new pts_test_result_parser();12$parser->parse_result_file($result_file, true, true, true);13$parser = new pts_test_result_parser();14$parser->parse_result_file($result_file, true, true, true, true);15$parser = new pts_test_result_parser();16$parser->parse_result_file($result_file, true, true, true, true, true);
parse_result_process
Using AI Code Generation
1$parser = new pts_test_result_parser();2$parser->parse_result_process($result);3$parser = new pts_test_result_parser();4$parser->parse_result_process($result);5$parser = new pts_test_result_parser();6$parser->parse_result_process($result);7$parser = new pts_test_result_parser();8$parser->parse_result_process($result);9$parser = new pts_test_result_parser();10$parser->parse_result_process($result);11$parser = new pts_test_result_parser();12$parser->parse_result_process($result);13$parser = new pts_test_result_parser();14$parser->parse_result_process($result);15$parser = new pts_test_result_parser();16$parser->parse_result_process($result);17$parser = new pts_test_result_parser();18$parser->parse_result_process($result);19$parser = new pts_test_result_parser();20$parser->parse_result_process($result);21$parser = new pts_test_result_parser();22$parser->parse_result_process($result);23$parser = new pts_test_result_parser();
parse_result_process
Using AI Code Generation
1require_once('pts_test_result_parser.php');2$test_parser = new pts_test_result_parser();3$test_parser->parse_result_process('test_result.txt');4require_once('pts_test_result_parser.php');5$test_parser = new pts_test_result_parser();6$test_parser->parse_result_process('test_result.txt');7require_once('pts_test_result_parser.php');8$test_parser = new pts_test_result_parser();9$test_parser->parse_result_process('test_result.txt');10require_once('pts_test_result_parser.php');11$test_parser = new pts_test_result_parser();12$test_parser->parse_result_process('test_result.txt');13require_once('pts_test_result_parser.php');14$test_parser = new pts_test_result_parser();15$test_parser->parse_result_process('test_result.txt');16require_once('pts_test_result_parser.php');17$test_parser = new pts_test_result_parser();18$test_parser->parse_result_process('test_result.txt');19require_once('pts_test_result_parser.php');20$test_parser = new pts_test_result_parser();21$test_parser->parse_result_process('test_result.txt');22require_once('pts_test_result_parser.php');23$test_parser = new pts_test_result_parser();24$test_parser->parse_result_process('test_result.txt');25require_once('pts_test_result_parser.php');26$test_parser = new pts_test_result_parser();27$test_parser->parse_result_process('test_result.txt');28require_once('pts_test_result_parser.php');29$test_parser = new pts_test_result_parser();
parse_result_process
Using AI Code Generation
1$parser = new pts_test_result_parser();2$parser->parse_result_process('2.php');3$parser = new pts_test_result_parser();4$parser->parse_result_process('3.php');5 (6 (7 (8 (9 (10 (11 (12 (13 (14 (15 (16 (
parse_result_process
Using AI Code Generation
1require_once('pts_test_result_parser.php');2$parser = new pts_test_result_parser();3$parser->parse_result_process('result.txt', 'result.xml');4require_once('pts_test_result_parser.php');5$parser = new pts_test_result_parser();6$parser->parse_result_process('result.txt', 'result.xml', 'result.csv');7require_once('pts_test_result_parser.php');8$parser = new pts_test_result_parser();9$parser->parse_result_process('result.txt', 'result.xml', 'result.csv', 'result.txt');10require_once('pts_test_result_parser.php');11$parser = new pts_test_result_parser();12$parser->parse_result_process('result.txt', 'result.xml', 'result.csv', 'result.txt', 'result.json');13require_once('pts_test_result_parser.php');14$parser = new pts_test_result_parser();15$parser->parse_result_process('result.txt', 'result.xml', 'result.csv', 'result.txt', 'result.json', 'result.html');
parse_result_process
Using AI Code Generation
1require_once('pts_test_result_parser.php');2$parser = new pts_test_result_parser();3$parser->parse_result_process('2.php');4require_once('pts_test_result_parser.php');5$parser = new pts_test_result_parser();6$parser->get_result('2.php');
parse_result_process
Using AI Code Generation
1require_once('pts_test_result_parser.php');2$parser = new pts_test_result_parser();3$parser->parse_result_process('result.xml');4require_once('pts_test_result_parser.php');5$parser = new pts_test_result_parser();6$parser->parse_result_process('result.xml');
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with parse_result_process on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!