Best Phoronix-test-suite code snippet using pts_ae_data.get_results_array_by_comparison_hash
pts_ae_data.php
Source:pts_ae_data.php
...152 $last_appeared = 0;153 $component_results = array();154 $component_dates = array();155 $system_types = array();156 $results = $this->get_results_array_by_comparison_hash($comparison_hash, $first_appeared, $last_appeared, $component_results, $component_dates, $system_types);157 if(count($results) < 12)158 {159 continue;160 }161 $percentiles = array();162 for($i = 0; $i < 100; $i++)163 {164 $percentiles[$i] = pts_math::find_percentile($results, ($i * 0.01));165 }166 $peak = max($results);167 $component_data = array();168 $comparison_components = array();169 foreach($component_results as $component => $d)170 {171 if(stripos($component . ' ', 'device ') !== false || stripos($component, 'unknown') !== false || stripos($component, 'common ') !== false || is_numeric($component))172 {173 continue;174 }175 foreach($d as $related_component => $data)176 {177 if(!isset($comparison_components[$component]))178 {179 $comparison_components[$component] = array();180 }181 $comparison_components[$component] = array_merge($comparison_components[$component], $data);182 if(stripos($related_component . ' ', 'device ') !== false || stripos($related_component, 'unknown') !== false)183 {184 continue;185 }186 if($component_dates[$component][$related_component]['last_appeared'] < (time() - (31536000 * 3)))187 {188 // if no new results in 3 years, likely outdated...189 continue;190 }191 if(count($data) < 6)192 {193 continue;194 }195 $data = pts_math::remove_outliers($data);196 if(count($data) < 6)197 {198 continue;199 }200 $component_data[$component][$related_component]['avg'] = round(pts_math::arithmetic_mean($data), ($peak > 60 ? 0 : 2));201 $component_data[$component][$related_component]['samples'] = count($data);202 $component_data[$component][$related_component]['first_appeared'] = $component_dates[$component][$related_component]['first_appeared'];203 $component_data[$component][$related_component]['last_appeared'] = $component_dates[$component][$related_component]['last_appeared'];204 $component_data[$component][$related_component]['system_type'] = $system_types[$component][$related_component];205 }206 }207 foreach($comparison_components as $component => &$values)208 {209 $values = pts_math::remove_outliers($values);210 if(count($values) < 6)211 {212 unset($comparison_components[$component]);213 continue;214 }215 }216 uasort($comparison_components, array('pts_ae_data', 'sort_array_by_size_of_array_in_value'));217 $comparison_components = array_slice($comparison_components, 0, 60);218 foreach($comparison_components as $component => &$values)219 {220 $values = round(pts_math::arithmetic_mean($values), ($peak > 60 ? 0 : 2));221 }222 if($row['HigherIsBetter'] == '1')223 {224 arsort($comparison_components);225 }226 else227 {228 asort($comparison_components);229 }230 // JSON FILE231 $json = array();232 $json['comparison_hash'] = $comparison_hash;233 $json['test_profile'] = $row['TestProfile'];234 $json['title'] = $row['Title'];235 $json['description'] = $row['ArgumentsDescription'];236 $json['hib'] = $row['HigherIsBetter'];237 $json['samples'] = count($results);238 $json['first_appeared'] = $first_appeared;239 $json['last_appeared'] = $last_appeared;240 $json['percentiles'] = $percentiles;241 $json['components'] = $component_data;242 $json['reference_results'] = $comparison_components;243 $json = json_encode($json);244 if(!empty($json))245 {246 $test_dir = base64_encode($row['TestProfile']);247 pts_file_io::mkdir($this->ae_dir . 'comparison-hashes/' . $test_dir . '/');248 file_put_contents($this->ae_dir . 'comparison-hashes/' . $test_dir . '/' . $comparison_hash . '.json', $json);249 }250 // EO JSON251 $stmt = $this->db->prepare('UPDATE composite SET SampleSize = :ss, Percentiles = :p, FirstAppeared = :fa, LastAppeared = :la WHERE ComparisonHash = :ch');252 $stmt->bindValue(':ss', count($results));253 $stmt->bindValue(':ch', $comparison_hash);254 $stmt->bindValue(':p', implode(',', $percentiles));255 $stmt->bindValue(':fa', $first_appeared);256 $stmt->bindValue(':la', $last_appeared);257 $stmt->execute();258 }259 }260 public function sort_array_by_size_of_array_in_value($a, $b)261 {262 return count($b) - count($a);263 }264 public function get_results_array_by_comparison_hash($ch, &$first_appeared, &$last_appeared, &$component_results, &$component_dates, &$system_types)265 {266 $stmt = $this->db->prepare('SELECT Result, DateTime, Component, RelatedComponent, SystemType, SystemLayer FROM analytics_results WHERE ComparisonHash = :ch');267 $stmt->bindValue(':ch', $ch);268 $result = $stmt ? $stmt->execute() : false;269 $results = array();270 $first_appeared = time();271 $last_appeared = 0;272 while($result && ($row = $result->fetchArray()))273 {274 if(!is_numeric($row['Result']))275 {276 continue;277 }278 $dt = $row['DateTime'];...
get_results_array_by_comparison_hash
Using AI Code Generation
1if (isset($_GET['comparison_hash'])) {2 $comparison_hash = $_GET['comparison_hash'];3 $test_results_array = $ae_data->get_results_array_by_comparison_hash($result_file, $comparison_hash);4 $test_name = $test_results_array[0]['test_name'];5 $test_result = $test_results_array[0]['test_result'];6 $test_units = $test_results_array[0]['test_units'];7 $test_description = $test_results_array[0]['test_description'];8 $test_command = $test_results_array[0]['test_command'];9 $test_environment = $test_results_array[0]['test_environment'];10 $test_profile = $test_results_array[0]['test_profile'];11 $test_parameters = $test_results_array[0]['test_parameters'];12 $test_status = $test_results_array[0]['test_status'];13 $test_timestamp = $test_results_array[0]['test_timestamp'];14 $test_comparison_hash = $test_results_array[0]['test_comparison_hash'];15 $test_result_hash = $test_results_array[0]['test_result_hash'];
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_results_array_by_comparison_hash 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!!