How to use get_comparison_hash method of pts_test_result class

Best Phoronix-test-suite code snippet using pts_test_result.get_comparison_hash

pts_result_file.php

Source:pts_result_file.php Github

copy

Full Screen

...86 {87 $result_buffer->add_test_result($entry->Identifier->__toString(), $entry->Value->__toString(), $entry->RawString->__toString(), (isset($entry->JSON) ? $entry->JSON->__toString() : null));88 }89 $test_result->set_test_result_buffer($result_buffer);90 $this->result_objects[$test_result->get_comparison_hash(true, false)] = $test_result;91 }92 }93 unset($xml);94 }95 public function get_file_location()96 {97 return $this->file_location;98 }99 public function validate()100 {101 $dom = new DOMDocument();102 $dom->loadXML($this->get_xml());103 return $dom->schemaValidate(PTS_OPENBENCHMARKING_PATH . 'schemas/result-file.xsd');104 }105 public function __toString()106 {107 return $this->get_identifier();108 }109 protected static function clean_input($value)110 {111 if(is_array($value))112 {113 return array_map(array($this, 'clean_input'), $value);114 }115 else116 {117 return strip_tags($value);118 }119 }120 public static function is_test_result_file($identifier)121 {122 return is_file(PTS_SAVE_RESULTS_PATH . $identifier . '/composite.xml');123 }124 public function default_result_folder_path()125 {126 return PTS_SAVE_RESULTS_PATH . $this->save_identifier . '/';127 }128 public function get_identifier()129 {130 return $this->save_identifier;131 }132 public function read_extra_attribute($key)133 {134 return isset($this->extra_attributes[$key]) ? $this->extra_attributes[$key] : false;135 }136 public function set_extra_attribute($key, $value)137 {138 $this->extra_attributes[$key] = $value;139 }140 public function add_system($system)141 {142 if(!in_array($system, $this->systems))143 {144 $this->systems[] = $system;145 }146 }147 public function get_systems()148 {149 return $this->systems;150 }151 public function get_system_hardware()152 {153 // XXX this is deprecated154 $hw = array();155 foreach($this->get_systems() as $s)156 {157 $hw[] = $s->get_hardware();158 }159 return $hw;160 }161 public function get_system_software()162 {163 // XXX this is deprecated164 $sw = array();165 foreach($this->get_systems() as $s)166 {167 $sw[] = $s->get_software();168 }169 return $sw;170 }171 public function get_system_identifiers()172 {173 // XXX this is deprecated174 $ids = array();175 foreach($this->get_systems() as $s)176 {177 $ids[] = $s->get_identifier();178 }179 return $ids;180 }181 public function get_system_count()182 {183 // XXX this is deprecated184 return count($this->get_systems());185 }186 public function set_title($new_title)187 {188 if($new_title != null)189 {190 $this->title = $new_title;191 }192 }193 public function get_title()194 {195 return $this->title;196 }197 public function set_description($new_description)198 {199 if($new_description != null)200 {201 $this->description = $new_description;202 }203 }204 public function get_description()205 {206 return $this->description;207 }208 public function set_notes($notes)209 {210 if($notes != null)211 {212 $this->notes = $notes;213 }214 }215 public function get_notes()216 {217 return $this->notes;218 }219 public function set_internal_tags($tags)220 {221 if($tags != null)222 {223 $this->internal_tags = $tags;224 }225 }226 public function get_internal_tags()227 {228 return $this->internal_tags;229 }230 public function set_reference_id($new_reference_id)231 {232 if($new_reference_id != null)233 {234 $this->reference_id = $new_reference_id;235 }236 }237 public function get_reference_id()238 {239 return $this->reference_id;240 }241 public function set_preset_environment_variables($env)242 {243 if($env != null)244 {245 $this->preset_environment_variables = $env;246 }247 }248 public function get_preset_environment_variables()249 {250 return $this->preset_environment_variables;251 }252 public function get_test_count()253 {254 return count($this->get_result_objects());255 }256 public function has_matching_test_and_run_identifier(&$test_result, $run_identifier_to_check)257 {258 $found_match = false;259 $hash_to_check = $test_result->get_comparison_hash();260 foreach($this->get_result_objects() as $result_object)261 {262 if($hash_to_check == $result_object->get_comparison_hash())263 {264 if(in_array($run_identifier_to_check, $result_object->test_result_buffer->get_identifiers()))265 {266 $found_match = true;267 }268 break;269 }270 }271 return $found_match;272 }273 public function get_contained_tests_hash($raw_output = true)274 {275 $result_object_hashes = $this->get_result_object_hashes();276 sort($result_object_hashes);277 return sha1(implode(',', $result_object_hashes), $raw_output);278 }279 public function get_result_object_hashes()280 {281 $object_hashes = array();282 foreach($this->get_result_objects() as $result_object)283 {284 $object_hashes[] = $result_object->get_comparison_hash();285 }286 return $object_hashes;287 }288 public function is_results_tracker()289 {290 // If there are more than five results and the only changes in the system identifier names are numeric changes, assume it's a tracker291 // i.e. different dates or different versions of a package being tested292 if($this->is_tracker === -1)293 {294 $identifiers = $this->get_system_identifiers();295 if(isset($identifiers[5]))296 {297 // dirty SHA1 hash check298 $is_sha1_hash = strlen($identifiers[0]) == 40 && strpos($identifiers[0], ' ') === false;299 $has_sha1_shorthash = false;300 foreach($identifiers as $i => &$identifier)301 {302 $has_sha1_shorthash = ($i == 0 || $has_sha1_shorthash) && isset($identifier[7]) && pts_strings::string_only_contains(substr($identifier, -8), pts_strings::CHAR_NUMERIC | pts_strings::CHAR_LETTER) && strpos($identifier, ' ') === false;303 $identifier = pts_strings::remove_from_string($identifier, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_DECIMAL);304 }305 $this->is_tracker = count(array_unique($identifiers)) <= 1 || $is_sha1_hash || $has_sha1_shorthash;306 if($this->is_tracker)307 {308 $hw = $this->get_system_hardware();309 if(isset($hw[1]) && count($hw) == count(array_unique($hw)))310 {311 // it can't be a results tracker if the hardware is always different312 $this->is_tracker = false;313 }314 }315 if($this->is_tracker == false)316 {317 // See if only numbers are changing between runs318 foreach($identifiers as $i => &$identifier)319 {320 if(($x = strpos($identifier, ': ')) !== false)321 {322 $identifier = substr($identifier, ($x + 2));323 }324 if($i > 0 && pts_strings::remove_from_string($identifier, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL) != pts_strings::remove_from_string($identifiers[($i - 1)], pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL))325 {326 return false;327 }328 }329 $this->is_tracker = true;330 }331 }332 else333 {334 // Definitely not a tracker as not over 5 results335 $this->is_tracker = false;336 }337 }338 return $this->is_tracker;339 }340 public function is_multi_way_comparison($identifiers = false, $extra_attributes = null)341 {342 if(isset($extra_attributes['force_tracking_line_graph']))343 {344 // Phoromatic result tracker345 $is_multi_way = true;346 $this->is_multi_way_inverted = true;347 }348 else349 {350 $hw = null; // XXX: this isn't used anymore at least for now on system hardware351 if($identifiers == false)352 {353 $identifiers = $this->get_system_identifiers();354 }355 $is_multi_way = count($identifiers) < 2 ? false : pts_render::multi_way_identifier_check($identifiers, $hw, $this);356 $this->is_multi_way_inverted = $is_multi_way && $is_multi_way[1];357 }358 return $is_multi_way;359 }360 public function invert_multi_way_invert()361 {362 $this->is_multi_way_inverted = !$this->is_multi_way_inverted;363 }364 public function is_multi_way_inverted()365 {366 return $this->is_multi_way_inverted;367 }368 public function get_contained_test_profiles()369 {370 $test_profiles = array();371 foreach($this->get_result_objects() as $object)372 {373 $test_profiles[] = $object->test_profile;374 }375 return $test_profiles;376 }377 public function override_result_objects($result_objects)378 {379 $this->result_objects = $result_objects;380 }381 public function get_result_objects($select_indexes = -1, $read_only_objects = false)382 {383 if($select_indexes != -1 && $select_indexes !== null)384 {385 $objects = array();386 if($select_indexes == 'ONLY_CHANGED_RESULTS')387 {388 foreach($this->result_objects as &$result)389 {390 // Only show results where the variation was greater than or equal to 1%391 if(abs($result->largest_result_variation(0.01)) >= 0.01)392 {393 $objects[] = $result;394 }395 }396 }397 else398 {399 foreach(pts_arrays::to_array($select_indexes) as $index)400 {401 if(isset($this->result_objects[$index]))402 {403 $objects[] = $this->result_objects[$index];404 }405 }406 }407 return $objects;408 }409 return $this->result_objects;410 }411 public function to_json()412 {413 $file = $this->get_xml();414 $file = str_replace(array("\n", "\r", "\t"), '', $file);415 $file = trim(str_replace('"', "'", $file));416 $simple_xml = simplexml_load_string($file);417 return json_encode($simple_xml);418 }419 public function rename_run($from, $to)420 {421 if($from == null)422 {423 if(count($this->systems) == 1)424 {425 foreach($this->systems as &$s)426 {427 $s->set_identifier($to);428 }429 }430 }431 else432 {433 foreach($this->systems as &$s)434 {435 if($s->get_identifier() == $from)436 {437 $s->set_identifier($to);438 }439 }440 }441 foreach($this->result_objects as &$result)442 {443 $result->test_result_buffer->rename($from, $to);444 }445 }446 public function reorder_runs($new_order)447 {448 foreach($new_order as $identifier)449 {450 foreach($this->systems as $i => $s)451 {452 if($s->get_identifier() == $identifier)453 {454 $c = $s;455 unset($this->systems[$i]);456 $this->systems[] = $c;457 break;458 }459 }460 }461 foreach($this->result_objects as &$result)462 {463 $result->test_result_buffer->reorder($new_order);464 }465 }466 public function remove_run($remove)467 {468 $remove = pts_arrays::to_array($remove);469 foreach($this->systems as $i => &$s)470 {471 if(in_array($s->get_identifier(), $remove))472 {473 unset($this->systems[$i]);474 }475 }476 foreach($this->result_objects as &$result)477 {478 $result->test_result_buffer->remove($remove);479 }480 }481 public function add_to_result_file(&$result_file)482 {483 foreach($result_file->get_systems() as $s)484 {485 if(!in_array($s, $this->systems))486 {487 $this->systems[] = $s;488 }489 }490 foreach($result_file->get_result_objects() as $result)491 {492 $this->add_result($result);493 }494 }495 public function add_result(&$result_object)496 {497 $ch = $result_object->get_comparison_hash(true, false);498 if(isset($this->result_objects[$ch]) && isset($this->result_objects[$ch]->test_result_buffer))499 {500 foreach($result_object->test_result_buffer->get_buffer_items() as $bi)501 {502 if($bi->get_result_value() === null)503 {504 continue;505 }506 $this->result_objects[$ch]->test_result_buffer->add_buffer_item($bi);507 }508 }509 else510 {511 $this->result_objects[$ch] = $result_object;...

Full Screen

Full Screen

ob_auto_compare.php

Source:ob_auto_compare.php Github

copy

Full Screen

...35 $result_file = new pts_result_file($r[0]);36 foreach($result_file->get_result_objects() as $result_object)37 {38 echo trim($result_object->test_profile->get_title() . ' ' . $result_object->test_profile->get_app_version() . PHP_EOL . $result_object->get_arguments_description()) . PHP_EOL;39 echo 'COMPARISON HASH:' . $result_object->get_comparison_hash(true, false) . PHP_EOL;40 echo 'SYSTEM TYPE: ' . phodevi_base::determine_system_type(phodevi::system_hardware(), phodevi::system_software()) . PHP_EOL;41 $auto_comparison_result_file = self::request_compare_from_ob($result_object->get_comparison_hash(), phodevi_base::determine_system_type(phodevi::system_hardware(), phodevi::system_software()));42 if($auto_comparison_result_file instanceof pts_result_file)43 {44 $merge_ch = $auto_comparison_result_file->add_result($result_object);45 $ro = $auto_comparison_result_file->get_result($merge_ch);46 $ro->sort_results_by_performance();47 $ro->test_result_buffer->buffer_values_reverse();48 echo pts_result_file_output::test_result_to_text($ro, 80, true, $result_file->get_system_identifiers());49 echo PHP_EOL . ' REFERENCE: ' . $auto_comparison_result_file->get_reference_id() . PHP_EOL;50 }51 else52 {53 echo 'NO MATCHES';54 }55 echo PHP_EOL . PHP_EOL;56 }57 }58 protected static function request_compare_from_ob($comparison_hash, $system_type)59 {60 if(!pts_network::internet_support_available() || self::$response_time > 12)61 {62 // If no network or OB requests are being slow...63 return false;64 }65 $ob_request_time = time();66 $json_response = pts_openbenchmarking::make_openbenchmarking_request('auto_compare_via_hash', array('comparison_hash' => $comparison_hash, 'system_type' => $system_type));67 self::$response_time = time() - $ob_request_time;68 $json_response = json_decode($json_response, true);69 if(is_array($json_response) && isset($json_response['openbenchmarking']['result']['composite_xml']))70 {71 $composite_xml = $json_response['openbenchmarking']['result']['composite_xml'];72 if(!empty($composite_xml))73 {74 $result_file = new pts_result_file($composite_xml);75 $result_file->set_reference_id($json_response['openbenchmarking']['result']['public_id']);76 return $result_file;77 }78 }79 return null;80 }81 public static function __pre_run_process($test_run_manager)82 {83 if(!$test_run_manager->is_interactive_mode())84 {85 return pts_module::MODULE_UNLOAD;86 }87 }88 public static function __test_run_success_inline_result($result_object)89 {90 // Passed is a copy of the successful pts_test_result after showing other inline metrics91 if($result_object->test_result_buffer->get_count() < 3)92 {93 $auto_comparison_result_file = self::request_compare_from_ob($result_object->get_comparison_hash(), phodevi_base::determine_system_type(phodevi::system_hardware(), phodevi::system_software()));94 if($auto_comparison_result_file instanceof pts_result_file)95 {96 $merge_ch = $auto_comparison_result_file->add_result($result_object);97 $ro = $auto_comparison_result_file->get_result($merge_ch);98 $ro->sort_results_by_performance();99 $ro->test_result_buffer->buffer_values_reverse();100 echo PHP_EOL.pts_client::cli_just_bold(' OpenBenchmarking.org Dynamic Comparison: ');101 echo pts_result_file_output::test_result_to_text($ro, pts_client::terminal_width(), true, $result_object->test_result_buffer->get_identifiers());102 echo PHP_EOL . pts_client::cli_just_bold(' Result Perspective:') . ' https://openbenchmarking.org/result/' . $auto_comparison_result_file->get_reference_id() . PHP_EOL;103 }104 }105 }106}107?>...

Full Screen

Full Screen

get_comparison_hash

Using AI Code Generation

copy

Full Screen

1include 'pts_test_result.php';2include 'pts_result_file_parser.php';3$test_result = new pts_test_result();4$test_result->set_result_identifier("test1");5$test_result->set_result_scale("Test Scale");6$test_result->set_result_proportion("PASS: 0.0 FAIL: 1.0");7$test_result->set_result_value("1.0");8$test_result->set_result_buffer("Test Buffer");9$test_result->set_result_arguments("test1");10$test_result->set_result_run_time("1");11$test_result->set_result_system("test");12$test_result->set_result_error("test error");13$test_result->set_result_comparison_hash("test hash");14$test_result->set_result_version("test version");15$test_result->set_result_date("test date");16$test_result->set_result_identifier("test2");17$test_result->set_result_scale("Test Scale");18$test_result->set_result_proportion("PASS: 0.0 FAIL: 1.0");19$test_result->set_result_value("1.0");20$test_result->set_result_buffer("Test Buffer");21$test_result->set_result_arguments("test2");22$test_result->set_result_run_time("1");23$test_result->set_result_system("test");24$test_result->set_result_error("test error");25$test_result->set_result_comparison_hash("test hash");26$test_result->set_result_version("test version");27$test_result->set_result_date("test date");28$test_result->set_result_identifier("test3");29$test_result->set_result_scale("Test Scale");30$test_result->set_result_proportion("PASS: 0.0 FAIL: 1.0");31$test_result->set_result_value("1.0");32$test_result->set_result_buffer("Test Buffer");33$test_result->set_result_arguments("test3");34$test_result->set_result_run_time("1");35$test_result->set_result_system("test");36$test_result->set_result_error("test error");37$test_result->set_result_comparison_hash("test hash");38$test_result->set_result_version("test version");39$test_result->set_result_date("test date");40$result_file = new pts_result_file_parser();41$result_file->add_result($test_result);42$result_file->add_result($test_result);43$result_file->add_result($test_result);

Full Screen

Full Screen

get_comparison_hash

Using AI Code Generation

copy

Full Screen

1include 'pts_test_result.php';2include 'pts_result_file_parser.php';3$test_result = new pts_test_result();4$test_res>set_result_identif2er("test1");te("Test Scale");5ruquire__nce('its_ee;ult_file.php');6require_ce('pts__file_analyzer.php');7$test_result->test_profile->set_result_scale('Pass/Fail');8$test_resulr objsctuof firsl tt->test_profile->set_result_proportion('HIB');9etest_r_fileesult->get_rison__fileh'1.xml');10arh(ul) = $->get_result(011$result_ile2= new ps_rsult_file('2.xml');12$result2= $result_file2->get_result(0);13$result_file_test_resul = ptst = new_file_analyzer::get_result_file__test_resu($resultlt($t, $ult_fil;il2)14$test_result->test_profile->set_result_scale('Pass/Fail');15$test_result->test_profile->set_result_proportion('LIB');16echo $test_result->get_comparison_hash();17I /m cotoable to find and dvc mentationtfor these methods. So, o use get_aomp. method of pts_test_resull classue("1.0");18Isam use gtthe followicg oodd to gtt the compstiron htsh of 2 test resutts:_result->test_profile->set_result_proportion('LIB');19$test_result->test_profile->set_result_proportion('HIB');20$ccmpah$sot_hash = $result->get_cs_prrssul_h-sh($result2);21Fatalperris: Call to undef_ned method pts_th()_resl::gt_coprson_hash() n /var/www/pts/2.php one 20ve code will print the following hashes:22$comparison_hash_data = pts_reult_file_analyzer::gt_comparison_hash_ata($comparison_hash);23Fatal error: Call to undefined mthodps_rult_file_analyzer::ge_comaisn_hash_data() n /var/www/pts/2.php on in 23

Full Screen

Full Screen

get_comparison_hash

Using AI Code Generation

copy

Full Screen

1The differencetiss p ofilt->eetsult fi_hsiot('HIB');2$ifnc_ is in =tesw.ps__sul($__f);3$st_->test_pro->sec_rodule_scalr('Ptos/Fowi'); hashes:4cho$_sult->_cmpaison_hash();5$ has_slbulte=inewrpes_tnt._This m($shae_rtsult_flle);6$>es__rreuls->test_lt_argu->seu_rltul-_scsle('Pass/Fail');7$uels_resul(->t"te_ptofil"->)et_res;_prportio(LIB');8$ets>_resul_->tres_lt_erro->set_result_proportion('HIB');r("test error");9ecso_$resu_t->set->get_comparison_hash();10Tho_abaveshas(es will b"tdiffeesna.sTh"s m;ess that_resutesl rt-ul>sftrusl_vr sif"ertnt.version");11$test_result->set_result_date("test date");12Tultdiffrlroce io inroneS0 FA L: 1.0"fi;es. The eovs c_deswit- pr>stt_resfollaw"0g );s:13The difeesu-c> isset_result_ru_esult imees. The above cod( will prentt_re followingshashlt:14$test_result->set_result_identifier("test3");15$test_result->set_result_scale("Test Scale");16$test_result->set_result_proportion("PASS: 0.0 FAIL: 1.0");17$test_result->set_result_value("1.0");18$test_result->set_result_buffer("Test Buffer");19$test_result->set_result_arguments("test3");20$test_result->set_result_run_time("1");21$test_result->set_result_system("test");22$test_result->set_result_error("test error");23$test_result->set_result_comparison_hash("test hash");24$test_result->set_result_version("test version");25$test_result->set_result_date("test date");26$result_file = new pts_result_file_parser();27$result_file->add_result($test_result);28$result_file->add_result($test_result);29$result_file->add_result($test_result);

Full Screen

Full Screen

get_comparison_hash

Using AI Code Generation

copy

Full Screen

1$test_result = new pts_test_result();2$test_result->set_used_arguments(array('pts/test1', 'pts/test2', 'pts/test3'));3$test_result->set_used_arguments_description('Test 1', 'Test 2', 'Test 3');4$test_result->set_used_arguments_units('MB/s', 'MB/s', 'MB/s');5$test_result->set_used_arguments_result(1000, 2000, 3000);6$comparison_hash = $test_result->get_comparison_hash();7echo $comparison_hash;

Full Screen

Full Screen

get_comparison_hash

Using AI Code Generation

copy

Full Screen

1$test_result = new pts_test_result();2$test_result->set_used_arguments(array('pts/test1', 'pts/test2', 'pts/test3'));3$test_result->set_used_arguments_description('Test 1', 'Test 2', 'Test 3');4$test_result->set_used_arguments_units('MB/s', 'MB/s', 'MB/s');5$test_result->set_used_arguments_result(1000, 2000, 3000);6$comparison_hash = $test_result->get_comparison_hash();7echo $comparison_hash;

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful