Best Phoronix-test-suite code snippet using pts_test_result_buffer.get_buffer_items
pts_result_file_analyzer.php
Source:pts_result_file_analyzer.php
...74 list($comparing, $arg) = explode(': ', $arg);75 }76 if(($ro = $result_file->get_result_object_by_hash($ro_index)))77 {78 foreach($ro->test_result_buffer->get_buffer_items() as $old_bi)79 {80 $test_result->test_result_buffer->add_test_result(($system_count > 1 ? $old_bi->get_result_identifier() . ': ' : null) . $arg, $old_bi->get_result_value(), $old_bi->get_result_raw(), $old_bi->get_result_json_raw(), $old_bi->get_min_result_value(), $old_bi->get_max_result_value());81 }82 $results_to_drop[] = $ro_index;83 }84 }85 $tc = trim(trim(trim($test_combo), '-'));86 $test_result->set_used_arguments_description($comparing . ' Comparison' . ($tc ? ' (' . $tc . ')' : null));87 $test_result->test_profile->set_test_title($ro->test_profile->get_title());88 $test_result->test_profile->set_result_proportion($ro->test_profile->get_result_proportion());89 $test_result->test_profile->set_version($ro->test_profile->get_app_version());90 if($test_result->test_result_buffer->get_count() > 1)91 {92 $test_result->dynamically_generated = true;93 $new_result_objects[] = $test_result;94 $global_results_to_drop = array_merge($global_results_to_drop, $results_to_drop);95 }96 }97 }98 }99 if(count($new_result_objects) > 0)100 {101 $result_file->remove_result_object_by_id($global_results_to_drop);102 foreach($new_result_objects as $new_ro)103 {104 $result_file->add_result($new_ro);105 }106 }107 }108 }109 public static function condense_result_file_by_multi_version_tests(&$result_file)110 {111 $pmap = array();112 $do_proceed = false;113 foreach($result_file->get_result_objects() as $index => $ro)114 {115 if($ro->test_profile->get_identifier() == null || $ro->test_profile->get_display_format() != 'BAR_GRAPH')116 {117 continue;118 }119 $args = $ro->get_arguments_description();120 $scale = $ro->test_profile->get_result_scale();121 $test_identifier_no_version = $ro->test_profile->get_identifier(false);122 if(!isset($pmap[$test_identifier_no_version][$args]))123 {124 $pmap[$test_identifier_no_version][$args] = array();125 }126 if(!isset($pmap[$test_identifier_no_version][$args][$scale]))127 {128 $pmap[$test_identifier_no_version][$args][$scale] = array();129 }130 $pmap[$test_identifier_no_version][$args][$scale][$ro->test_profile->get_app_version()] = $index;131 if(!$do_proceed && count($pmap[$test_identifier_no_version][$args][$scale]) > 1)132 {133 $do_proceed = true;134 }135 }136 if($do_proceed)137 {138 $system_count = $result_file->get_system_count();139 $new_result_objects = array();140 $global_results_to_drop = array();141 foreach(array_keys($pmap) as $distinct_test)142 {143 foreach(array_keys($pmap[$distinct_test]) as $test_combo)144 {145 foreach(array_keys($pmap[$distinct_test][$test_combo]) as $scale)146 {147 $test_profile = new pts_test_profile($distinct_test);148 $test_result = new pts_test_result($test_profile);149 $test_result->test_profile->set_identifier(null);150 $test_result->test_profile->set_display_format('BAR_GRAPH');151 $test_result->test_profile->set_result_scale($scale);152 $test_result->set_used_arguments($test_combo);153 $test_result->test_result_buffer = new pts_test_result_buffer();154 $comparing = null;155 $results_to_drop = array();156 foreach($pmap[$distinct_test][$test_combo][$scale] as $version => $ro_index)157 {158 if(($ro = $result_file->get_result_object_by_hash($ro_index)))159 {160 foreach($ro->test_result_buffer->get_buffer_items() as $old_bi)161 {162 $test_result->test_result_buffer->add_test_result(($system_count > 1 ? $old_bi->get_result_identifier() . ': ' : null) . $version, $old_bi->get_result_value(), $old_bi->get_result_raw(), $old_bi->get_result_json_raw(), $old_bi->get_min_result_value(), $old_bi->get_max_result_value());163 }164 $results_to_drop[] = $ro_index;165 }166 }167 $tc = trim(trim(trim($test_combo), '-'));168 $test_result->set_used_arguments_description('Version Comparison' . ($tc ? ' (' . $tc . ')' : null));169 $test_result->test_profile->set_test_title($ro->test_profile->get_title());170 $test_result->test_profile->set_result_proportion($ro->test_profile->get_result_proportion());171 $test_result->test_profile->set_version('');172 if($test_result->test_result_buffer->get_count() > 1)173 {174 $test_result->dynamically_generated = true;175 $new_result_objects[] = $test_result;176 $global_results_to_drop = array_merge($global_results_to_drop, $results_to_drop);177 }178 }179 }180 }181 if(count($new_result_objects) > 0)182 {183 $result_file->remove_result_object_by_id($global_results_to_drop);184 foreach($new_result_objects as $new_ro)185 {186 $result_file->add_result($new_ro);187 }188 }189 }190 }191 public static function get_result_object_custom(&$result_file, $result_object, $identifier_mapping, $title_prepend = '', $unit = '')192 {193 if($result_object->test_profile->get_identifier() != null && $result_object->test_profile->get_display_format() == 'BAR_GRAPH')194 {195 $added_count = 0;196 $test_result = clone $result_object;197 $test_result->test_profile->set_identifier(null);198 $test_result->set_used_arguments_description($title_prepend . ($test_result->get_arguments_description() != null ? ' - ' . $test_result->get_arguments_description() : ''));199 $test_result->set_used_arguments($title_prepend . ' ' . $test_result->get_arguments());200 $test_result->test_result_buffer = new pts_test_result_buffer();201 $iv_map = $result_object->test_result_buffer->get_identifier_value_map();202 foreach($identifier_mapping as $identifier => $value)203 {204 if(!isset($iv_map[$identifier]))205 {206 continue;207 }208 $result = $iv_map[$identifier];209 if(!is_numeric($result) || !is_numeric($value))210 {211 continue;212 }213 if($result_object->test_profile->get_result_proportion() == 'HIB')214 {215 $result = $result / $value;216 $result = round($result, ($result < 1 ? 4 : 2));217 $scale = $result_object->test_profile->get_result_scale() . ' Per ' . $unit;218 }219 else if($result_object->test_profile->get_result_proportion() == 'LIB')220 {221 $result = round($result * $value, 3);222 $scale = $result_object->test_profile->get_result_scale() . ' x ' . $unit;223 }224 if($result != 0)225 {226 if($title_prepend == 'Performance Per Clock')227 {228 $d = 'GHz base clock speed (use PTS sensors for real-time frequency/sensor reporting)';229 }230 else231 {232 $d = strtolower($unit);233 }234 $test_result->test_result_buffer->add_test_result($identifier, $result, null, array('install-footnote' => 'Detected ' . $d . ' count of ' . $value));235 $added_count++;236 }237 }238 if($added_count > 1)239 {240 $test_result->test_profile->set_result_scale($scale);241 return $test_result;242 }243 }244 return false;245 }246 public static function generate_perf_per_dollar(&$input, $generate, $unit = 'Dollar', $yield_on_unqualified_ros = false, $per_hour = false)247 {248 if($input instanceof pts_result_file)249 {250 $result_file = &$input;251 $ros = $input->get_result_objects();252 }253 else if($input instanceof pts_test_result)254 {255 $result_file = false;256 $ros = array($input);257 }258 foreach($ros as &$result_object)259 {260 if((!$yield_on_unqualified_ros && $result_object->test_profile->get_identifier() == null) || $result_object->test_profile->get_display_format() != 'BAR_GRAPH')261 {262 continue;263 }264 $computed = array();265 $footnotes = array();266 $bi_map = $result_object->test_result_buffer->get_map_by_identifier();267 foreach($generate as $identifier => $value)268 {269 if(!isset($bi_map[$identifier]))270 {271 continue;272 }273 $result = $bi_map[$identifier]->get_result_value();274 if(is_numeric($result) && $result > 0)275 {276 if($per_hour)277 {278 $test_run_times = $bi_map[$identifier]->get_run_times();279 if(!empty($test_run_times))280 {281 $avg_time = round(array_sum($test_run_times) / count($test_run_times));282 // Cost-perf-per-hour calculation, e.g. cloud costs...283 $cost_to_run_test = round(($value / 60 / 60) * $avg_time, 3);284 if($cost_to_run_test < 0.001)285 {286 continue;287 }288 $footnotes[$identifier] = '$' . $value . ' reported cost per hour, test took average of ' . ($avg_time < 240 ? $avg_time . ' seconds ' : strtolower(pts_strings::format_time($avg_time))) . ' per run: cost approximately ' . $cost_to_run_test . ' ' . strtolower($unit) . 's.';289 $value = $cost_to_run_test;290 }291 }292 if($result_object->test_profile->get_result_proportion() == 'HIB')293 {294 $result = $result / $value;295 $result = pts_math::set_precision($result, ($result > 0.1 ? 3 : 8));296 $scale = $result_object->test_profile->get_result_scale() . ' Per ' . $unit;297 }298 else if($result_object->test_profile->get_result_proportion() == 'LIB')299 {300 $result = pts_math::set_precision($result * $value, 3);301 $scale = $result_object->test_profile->get_result_scale() . ' x ' . $unit;302 }303 else304 {305 continue;306 }307 if($result != 0)308 {309 $computed[$identifier] = $result;310 if(!isset($footnotes[$identifier]))311 {312 $footnotes[$identifier] = '$' . $value . ' reported cost.';313 }314 }315 }316 }317 if(!empty($computed))318 {319 $ret = pts_result_file_analyzer::add_perf_per_graph($result_file, $result_object, $computed, $scale, $footnotes);320 if($result_file == false && $ret)321 {322 return $ret;323 }324 }325 }326 }327 public static function add_perf_per_graph(&$result_file, $test_result, $results, $scale, $footnote = null)328 {329 if(empty($results))330 {331 return false;332 }333 // This copy isn't needed but it's shorter and from port from system_monitor where there can be multiple items tracked334 $original_parent_hash = $test_result->get_comparison_hash(true, false);335 $test_result = clone $test_result;336 $test_result->test_profile->set_identifier(null);337 $test_result->set_used_arguments_description('Performance / Cost' . ($test_result->get_arguments_description() != null ? ' - ' . $test_result->get_arguments_description() : ''));338 $test_result->set_used_arguments('dollar comparison ' . $test_result->get_arguments());339 $test_result->test_profile->set_result_scale($scale);340 $test_result->test_result_buffer = new pts_test_result_buffer();341 foreach($results as $result_identifier => $result)342 {343 $test_result->test_result_buffer->add_test_result($result_identifier, $result, null, array('install-footnote' => (isset($footnote[$result_identifier]) ? $footnote[$result_identifier] : null)));344 }345 $test_result->set_parent_hash($original_parent_hash);346 if($result_file)347 {348 $result_file->add_result($test_result);349 }350 else351 {352 return $test_result;353 }354 }355 public static function generate_executive_summary($result_file, $selected_result = null, &$error = null, $separator = PHP_EOL, $do_html = false)356 {357 $summary = array();358 if($result_file->get_test_count() < 6)359 {360 $error = 'Not enough tests to analyze...';361 return $summary;362 }363 if($result_file->get_system_count() < 2)364 {365 $error = 'Not enough results to analyze...';366 return $summary;367 }368 $wins_result = pts_result_file_analyzer::generate_wins_losses_results($result_file, true);369 $first_place_buffer = $wins_result->test_result_buffer->get_max_value(2);370 if($selected_result && ($sw = $wins_result->test_result_buffer->find_buffer_item($selected_result)))371 {372 if($do_html)373 {374 $selected_result = '<strong>' . $selected_result . '</strong>';375 }376 $summary[] = $selected_result . ' came in first place for ' . floor($sw->get_result_value() / $wins_result->test_result_buffer->get_total_value_sum() * 100) . '% of the tests.';377 }378 else if($first_place_buffer->get_result_identifier() != $selected_result)379 {380 // Most wins381 $selected_result = $first_place_buffer->get_result_identifier();382 if($do_html)383 {384 $selected_result = '<strong>' . $selected_result . '</strong>';385 }386 $summary[] = $first_place_buffer->get_result_identifier() . ' had the most wins, coming in first place for ' . floor($first_place_buffer->get_result_value() / $wins_result->test_result_buffer->get_total_value_sum() * 100) . '% of the tests.';387 }388 $geo_mean_result = pts_result_file_analyzer::generate_geometric_mean_result($result_file, true);389 if($geo_mean_result)390 {391 $first_place_buffer = $geo_mean_result->test_result_buffer->get_max_value(2);392 $last_place_buffer = $geo_mean_result->test_result_buffer->get_min_value(2);393 $geo_bits = array();394 if($result_file->get_system_count() >= 3)395 {396 $prev_buffer = null;397 foreach($geo_mean_result->test_result_buffer->get_buffer_items() as $bi)398 {399 if(!is_numeric($bi->get_result_value()))400 {401 continue;402 }403 if($prev_buffer == null)404 {405 $prev_buffer = $bi;406 continue;407 }408 $rounded = round($bi->get_result_value() / $prev_buffer->get_result_value(), 3) . 'x';409 if($rounded === '1.000x')410 {411 continue;412 }413 $geo_bits[] = $bi->get_result_identifier() . ' was ' . $rounded . ' the speed of ' . $prev_buffer->get_result_identifier();414 $prev_buffer = $bi;415 }416 }417 switch(count($geo_bits))418 {419 case 0:420 $geo_bits = null;421 break;422 case 1:423 $geo_bits = array_pop($geo_bits) . '.';424 break;425 case 2:426 $geo_bits = implode(' and ', $geo_bits) . '.';427 break;428 default:429 if(count($geo_bits) > 10)430 {431 $geo_bits = null;432 break;433 }434 $geo_bits = implode(', ', $geo_bits) . '.';435 break;436 }437 $summary[] = trim('Based on the geometric mean of all complete results, the fastest (' . $first_place_buffer->get_result_identifier() . ') was ' . round($first_place_buffer->get_result_value() / $last_place_buffer->get_result_value(), 3) . 'x the speed of the slowest (' . $last_place_buffer->get_result_identifier() . '). ' . $geo_bits);438 }439 if($result_file->get_test_count() > 16)440 {441 $results = $result_file->get_result_objects();442 $spreads = array();443 foreach($results as $i => &$result_object)444 {445 $spreads[$i] = $result_object->get_spread();446 }447 arsort($spreads);448 $spreads = array_slice($spreads, 0, 10, true);449 if(!empty($spreads))450 {451 $spread_text = array();452 foreach($spreads as $result_key => $spread)453 {454 $ro = $result_file->get_result_objects($result_key);455 if(!is_object($ro[0]))456 {457 continue;458 }459 if($do_html)460 {461 $spread_text[] = '<strong>' . $ro[0]->test_profile->get_title() . '</strong>' . ($ro[0]->get_arguments_description() != null ? ' (<em>' . $ro[0]->get_arguments_description() . '</em>)' : null) . ' at ' . round($spread, 3) . 'x';462 }463 else464 {465 $spread_text[] = $ro[0]->test_profile->get_title() . ($ro[0]->get_arguments_description() != null ? ' (' . $ro[0]->get_arguments_description() . ')' : null) . ' at ' . round($spread, 3) . 'x';466 }467 }468 if(!empty($spread_text))469 {470 $summary[] = 'The results with the greatest spread from best to worst included: ' . PHP_EOL . PHP_EOL . implode($separator, $spread_text) . '.';471 }472 }473 }474 return $summary;475 }476 public static function generate_wins_losses_results($result_file, $only_wins = false)477 {478 $results = array();479 $result_file_identifiers_count = $result_file->get_system_count();480 $wins = array();481 $losses = array();482 $tests_counted = 0;483 $possible_evaluate_result_count = 0;484 foreach($result_file->get_result_objects() as $result)485 {486 if($result->test_profile->get_identifier() == null)487 {488 continue;489 }490 $possible_evaluate_result_count++;491 if($result->test_result_buffer->get_count() < 2 || $result->test_result_buffer->get_count() < floor($result_file_identifiers_count / 2))492 {493 continue;494 }495 $winner = $result->get_result_first();496 $loser = $result->get_result_last();497 if($winner == null || $loser == null)498 {499 continue;500 }501 $tests_counted++;502 if(!isset($wins[$winner]))503 {504 $wins[$winner] = 1;505 }506 else507 {508 $wins[$winner]++;509 }510 if(!isset($losses[$loser]))511 {512 $losses[$loser] = 1;513 }514 else515 {516 $losses[$loser]++;517 }518 }519 if(empty($wins) || empty($losses))520 {521 return array();522 }523 arsort($wins);524 arsort($losses);525 $test_profile = new pts_test_profile();526 $test_result = new pts_test_result($test_profile);527 $test_result->test_profile->set_test_title('Number Of First Place Finishes');528 $test_result->test_profile->set_identifier(null);529 $test_result->test_profile->set_version(null);530 $test_result->test_profile->set_result_proportion(null);531 $test_result->test_profile->set_display_format('PIE_CHART');532 $test_result->test_profile->set_result_scale('Wins');533 ///$test_result->test_profile->set_result_proportion('HIB');534 $test_result->set_used_arguments_description('Wins - ' . $tests_counted . ' Tests');535 //$test_result->set_used_arguments('Geometric-Mean');536 $test_result->test_result_buffer = new pts_test_result_buffer();537 $test_result->dynamically_generated = true;538 foreach($wins as $identifier => $count)539 {540 $test_result->test_result_buffer->add_test_result($identifier, $count);541 }542 if($only_wins)543 {544 return count($wins) > 1 ? $test_result : null;545 }546 if(count($wins) > 1)547 {548 $results[] = $test_result;549 }550 $test_profile = new pts_test_profile();551 $test_result = new pts_test_result($test_profile);552 $test_result->test_profile->set_test_title('Number Of Last Place Finishes');553 $test_result->test_profile->set_identifier(null);554 $test_result->test_profile->set_version(null);555 $test_result->test_profile->set_result_proportion(null);556 $test_result->test_profile->set_display_format('PIE_CHART');557 $test_result->test_profile->set_result_scale('Losses');558 ///$test_result->test_profile->set_result_proportion('HIB');559 $test_result->set_used_arguments_description('Losses - ' . $tests_counted . ' Tests');560 //$test_result->set_used_arguments('Geometric-Mean');561 $test_result->test_result_buffer = new pts_test_result_buffer();562 $test_result->dynamically_generated = true;563 foreach($losses as $identifier => $count)564 {565 $test_result->test_result_buffer->add_test_result($identifier, $count);566 }567 if(count($losses) > 1)568 {569 $results[] = $test_result;570 }571 return $results;572 }573 public static function generate_geometric_mean_result_for_suites_in_result_file(&$result_file, $allow_partial = true, $upper_limit = 0)574 {575 if($result_file->get_system_count() < 2)576 {577 return array();578 }579 $geo_mean_results = array();580 $suites_in_result_file = pts_test_suites::suites_in_result_file($result_file, $allow_partial, $upper_limit);581 if(empty($suites_in_result_file))582 {583 return array();584 }585 ksort($suites_in_result_file);586 foreach($suites_in_result_file as $suite_identifier => &$s)587 {588 list($suite, $contained_tests) = $s;589 $geo_mean = pts_result_file_analyzer::generate_geometric_mean_result($result_file, true, $contained_tests);590 if($geo_mean)591 {592 $geo_mean->test_profile->set_test_title('Geometric Mean Of ' . $suite->get_title() . (stripos($suite->get_title(), 'Test') === false ? ' Tests' : null));593 $geo_mean->normalize_buffer_values();594 $geo_mean->set_annotation('Geometric mean based upon tests: ' . pts_arrays::implode_list($contained_tests));595 $geo_mean_results[] = $geo_mean;596 }597 }598 return $geo_mean_results;599 }600 public static function generate_geometric_mean_result($result_file, $do_sort = false, $limit_to = false, $best_is_last = false)601 {602 $results = array();603 $system_count = $result_file->get_system_count();604 foreach($result_file->get_result_objects() as $result_hash => $result)605 {606 if($result->test_profile->get_identifier() == null || $result->test_profile->get_display_format() != 'BAR_GRAPH' || $system_count > $result->test_result_buffer->get_count())607 {608 // Skip data where it's not a proper test, not a singular data value, or not all systems ran within the result file609 continue;610 }611 if($limit_to)612 {613 if(is_array($limit_to))614 {615 if(!in_array($result->test_profile->get_identifier(), $limit_to) && !in_array($result->test_profile->get_identifier(false), $limit_to))616 {617 continue;618 }619 }620 else621 {622 if($limit_to != $result->test_profile->get_identifier())623 {624 continue;625 }626 }627 }628 $skip_this = false;629 foreach($result->test_result_buffer->get_buffer_items() as $buffer_item)630 {631 $r = $buffer_item->get_result_value();632 if(!is_numeric($r) || $r == 0)633 {634 $skip_this = true;635 break;636 }637 }638 if($skip_this)639 {640 continue;641 }642 foreach($result->test_result_buffer->get_buffer_items() as $buffer_item)643 {644 $r = $buffer_item->get_result_value();645 if($result->test_profile->get_result_proportion() == 'LIB')646 {647 // convert to HIB648 $r = (1 / $r) * 100;649 }650 $ri = $buffer_item->get_result_identifier();651 if(!isset($results[$ri]))652 {653 $results[$ri] = array();654 }655 $results[$ri][$result_hash] = $r;656 }657 }658 foreach($results as $identifier => $values)659 {660 if(count($values) < 2)661 {662 // If small result file with not a lot of data, don't bother showing...663 unset($results[$identifier]);664 }665 }666 if(!empty($results))667 {668 $test_profile = new pts_test_profile();669 $test_result = new pts_test_result($test_profile);670 $test_result->test_profile->set_test_title('Geometric Mean Of ' . ($limit_to && !is_array($limit_to) ? $limit_to : 'All Test Results'));671 $test_result->test_profile->set_identifier(null);672 $test_result->test_profile->set_version(null);673 $test_result->test_profile->set_result_proportion(null);674 $test_result->test_profile->set_display_format('BAR_GRAPH');675 $test_result->test_profile->set_result_scale('Geometric Mean');676 $test_result->test_profile->set_result_proportion('HIB');677 $test_result->set_used_arguments_description('Result Composite' . ($result_file->get_title() != null ? ' - ' . $result_file->get_title() : null));678 $test_result->set_used_arguments('Geometric-Mean');679 $test_result->test_result_buffer = new pts_test_result_buffer();680 foreach($results as $identifier => $values)681 {682 if(count($values) < 2)683 {684 return false;685 }686 $values = pts_math::geometric_mean($values);687 $test_result->test_result_buffer->add_test_result($identifier, pts_math::set_precision($values, 3));688 }689 if(!$result_file->is_multi_way_comparison() && $do_sort)690 {691 $test_result->sort_results_by_performance();692 if($best_is_last)693 {694 $test_result->test_result_buffer->buffer_values_reverse();695 }696 }697 $test_result->dynamically_generated = true;698 return $test_result;699 }700 return false;701 }702 public static function generate_geometric_mean_result_per_test($result_file, $do_sort = false, $selector = null, $best_is_last = false)703 {704 $geo_results = array();705 $results = array();706 $system_count = $result_file->get_system_count();707 foreach($result_file->get_result_objects() as $result_hash => $result)708 {709 if(($selector == null && $result->test_profile->get_identifier() == null) || $result->test_profile->get_display_format() != 'BAR_GRAPH' || $system_count > $result->test_result_buffer->get_count())710 {711 // Skip data where it's not a proper test, not a singular data value, or not all systems ran within the result file712 continue;713 }714 if($selector != null && strpos($result->get_arguments_description(), $selector) === false && strpos($result->test_profile->get_title(), $selector) === false && strpos($result->test_profile->get_result_scale(), $selector) === false)715 {716 continue;717 }718 foreach($result->test_result_buffer->get_buffer_items() as $buffer_item)719 {720 $r = $buffer_item->get_result_value();721 if(!is_numeric($r) || $r == 0)722 {723 continue;724 }725 if($result->test_profile->get_result_proportion() == 'LIB')726 {727 // convert to HIB728 $r = (1 / $r) * 100;729 }730 $ri = $buffer_item->get_result_identifier();731 if(!isset($results[$result->test_profile->get_title()]))732 {733 $results[$result->test_profile->get_title()] = array();734 }735 if(!isset($results[$result->test_profile->get_title()][$ri]))736 {737 $results[$result->test_profile->get_title()][$ri] = array();738 }739 $results[$result->test_profile->get_title()][$ri][$result_hash] = $r;740 }741 }742 if(count($results) < 2)743 {744 return array();745 }746 foreach($results as $test => $test_results)747 {748 foreach($test_results as $identifier => $values)749 {750 if(false && count($values) < 4)751 {752 // If small result file with not a lot of data, don't bother showing...753 unset($results[$test][$identifier]);754 }755 }756 if(empty($results[$test]))757 {758 unset($results[$test]);759 }760 }761 foreach($results as $test_title => $test_results)762 {763 if(count($test_results) != $system_count)764 {765 continue;766 }767 $test_profile = new pts_test_profile();768 $test_result = new pts_test_result($test_profile);769 $test_result->test_profile->set_test_title($test_title);770 $test_result->test_profile->set_identifier(null);771 $test_result->test_profile->set_version(null);772 $test_result->test_profile->set_result_proportion(null);773 $test_result->test_profile->set_display_format('BAR_GRAPH');774 $test_result->test_profile->set_result_scale('Geometric Mean');775 $test_result->test_profile->set_result_proportion('HIB');776 $test_result->set_used_arguments_description(($selector ? $selector . ' ' : null) . 'Geometric Mean');777 $test_result->set_used_arguments('Geometric-Mean');778 $test_result->test_result_buffer = new pts_test_result_buffer();779 foreach($test_results as $identifier => $values)780 {781 $values = pts_math::geometric_mean($values);782 $precised = pts_math::set_precision($values, 3);783 if($values != 0 && $precised == 0)784 {785 // Don't use precision if it ends up rounding result too small in certain situations786 $precised = $values;787 }788 $test_result->test_result_buffer->add_test_result($identifier, $precised);789 }790 if(!$result_file->is_multi_way_comparison() || $do_sort)791 {792 $test_result->sort_results_by_performance();793 if($best_is_last)794 {795 $test_result->test_result_buffer->buffer_values_reverse();796 }797 }798 $test_result->dynamically_generated = true;799 $geo_results[] = $test_result;800 }801 return $geo_results;802 }803 public static function generate_harmonic_mean_result($result_file, $do_sort = false, $best_is_last = false)804 {805 $results = array();806 $system_count = $result_file->get_system_count();807 foreach($result_file->get_result_objects() as $result)808 {809 if($result->test_profile->get_identifier() == null || $result->test_profile->get_display_format() != 'BAR_GRAPH' || $result->test_profile->get_result_proportion() == 'LIB' || $system_count > $result->test_result_buffer->get_count())810 {811 // Skip data where it's not a proper test, not a singular data value, or not all systems ran within the result file, or lower is better for results812 continue;813 }814 $rs = $result->test_profile->get_result_scale();815 if(strpos($rs, '/') === false && stripos($rs, ' per ') === false && stripos($rs, 'FPS') === false && stripos($rs, 'bps') === false && stripos($rs, 'iops') === false)816 {817 // Harmonic mean is relevant for tests of rates, MB/s, FPS, ns/day, etc.818 continue;819 }820 $skip_this_result = false;821 foreach($result->test_result_buffer->get_buffer_items() as $buffer_item)822 {823 $rv = $buffer_item->get_result_value();824 if(!is_numeric($rv))825 {826 $skip_this_result = true;827 break;828 }829 }830 if($skip_this_result)831 {832 continue;833 }834 foreach($result->test_result_buffer->get_buffer_items() as $buffer_item)835 {836 $ri = $buffer_item->get_result_identifier();837 if(!isset($results[$rs][$ri]))838 {839 $results[$rs][$ri] = array();840 }841 $results[$rs][$ri][] = $buffer_item->get_result_value();842 }843 }844 foreach($results as $result_scale => $group)845 {846 foreach($group as $identifier => $values)847 {848 if(count($values) < 4)...
get_buffer_items
Using AI Code Generation
1require_once('pts_test_result_buffer.php');2$test_result_buffer = new pts_test_result_buffer();3$test_result_buffer->load_buffer();4$buffer_items = $test_result_buffer->get_buffer_items();5print_r($buffer_items);6 (7 (8 (9 (10 (11 (12 (13 (
get_buffer_items
Using AI Code Generation
1$buffer = new pts_test_result_buffer();2$buffer->add_result_file('1.xml');3$buffer->add_result_file('2.xml');4$buffer->add_result_file('3.xml');5$buffer->add_result_file('4.xml');6$buffer->add_result_file('5.xml');7$buffer->add_result_file('6.xml');8$buffer->add_result_file('7.xml');9$buffer->add_result_file('8.xml');10$buffer->add_result_file('9.xml');11$buffer->add_result_file('10.xml');12$buffer->add_result_file('11.xml');13$buffer->add_result_file('12.xml');14$buffer->add_result_file('13.xml');15$buffer->add_result_file('14.xml');16$buffer->add_result_file('15.xml');17$buffer->add_result_file('16.xml');18$buffer->add_result_file('17.xml');19$buffer->add_result_file('18.xml');20$buffer->add_result_file('19.xml');21$buffer->add_result_file('20.xml');22$buffer->add_result_file('21.xml');23$buffer->add_result_file('22.xml');24$buffer->add_result_file('23.xml');25$buffer->add_result_file('24.xml');26$buffer->add_result_file('25.xml');27$buffer->add_result_file('26.xml');28$buffer->add_result_file('27.xml');29$buffer->add_result_file('28.xml');30$buffer->add_result_file('29.xml');31$buffer->add_result_file('30.xml');32$buffer->add_result_file('31.xml');33$buffer->add_result_file('32.xml');34$buffer->add_result_file('33.xml');35$buffer->add_result_file('34.xml');36$buffer->add_result_file('35.xml');37$buffer->add_result_file('36.xml');38$buffer->add_result_file('37.xml');39$buffer->add_result_file('38.xml');40$buffer->add_result_file('39.xml');41$buffer->add_result_file('40.xml');
get_buffer_items
Using AI Code Generation
1include 'pts_test_result_buffer.php';2$test_profile_name = "phpbench";3$test_result_buffer = new pts_test_result_buffer();4$test_result_buffer->load_buffer_items();5$test_result_buffer_items = $test_result_buffer->get_buffer_items($test_profile_name);6foreach($test_result_buffer_items as $test_result_buffer_item)7{8echo $test_result_buffer_item->get_result_identifier();9";10}11include 'pts_test_result_buffer.php';12$test_profile_name = "phpbench";13$test_result_buffer = new pts_test_result_buffer();14$test_result_buffer->load_buffer_items();15$test_result_buffer_items = $test_result_buffer->get_buffer_items($test_profile_name);16foreach($test_result_buffer_items as $test_result_buffer_item)17{18echo $test_result_buffer_item->get_result_identifier();19";20}21include 'pts_test_result_buffer.php';22$test_profile_name = "phpbench";23$test_result_buffer = new pts_test_result_buffer();24$test_result_buffer->load_buffer_items();25$test_result_buffer_items = $test_result_buffer->get_buffer_items($test_profile_name);26foreach($test_result_buffer_items as $test_result_buffer_item)27{28echo $test_result_buffer_item->get_result_identifier();29";30}31include 'pts_test_result_buffer.php';32$test_profile_name = "phpbench";33$test_result_buffer = new pts_test_result_buffer();34$test_result_buffer->load_buffer_items();35$test_result_buffer_items = $test_result_buffer->get_buffer_items($test_profile_name);36foreach($test_result_buffer_items as $test_result_buffer_item)37{38echo $test_result_buffer_item->get_result_identifier();39";40}41include 'pts_test_result_buffer.php';
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 get_buffer_items 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!!