How to use component_to_category method of pts_ae_data class

Best Phoronix-test-suite code snippet using pts_ae_data.component_to_category

pts_ae_data.php

Source:pts_ae_data.php Github

copy

Full Screen

...124 $result = $stmt->execute();125 $cache[$component][$category] = $this->db->lastInsertRowid();126 return $cache[$component][$category];127 }128 public function component_to_category($component)129 {130 static $cache;131 if(isset($cache[$component]))132 {133 return $cache[$component];134 }135 $stmt = $this->db->prepare('SELECT Category FROM components WHERE Component = :c LIMIT 1');136 $stmt->bindValue(':c', $component);137 $result = $stmt ? $stmt->execute() : false;138 if($result && ($row = $result->fetchArray()))139 {140 $cache[$component] = $this->category_id_to_category($row['Category']);141 return $row['Category'];142 }143 }144 public function component_id_to_component($component_id)145 {146 static $cache;147 if(isset($cache[$component_id]))148 {149 return $cache[$component_id];150 }151 $stmt = $this->db->prepare('SELECT Component FROM components WHERE ComponentID = :c LIMIT 1');152 $stmt->bindValue(':c', $component_id);153 $result = $stmt ? $stmt->execute() : false;154 if($result && ($row = $result->fetchArray()))155 {156 $cache[$component_id] = $row['Component'];157 return $cache[$component_id];158 }159 }160 public function category_to_category_id($category)161 {162 static $cache;163 if(isset($cache[$category]))164 {165 return $cache[$category];166 }167 $stmt = $this->db->prepare('SELECT CategoryID FROM component_categories WHERE Category = :c LIMIT 1');168 $stmt->bindValue(':c', $category);169 $result = $stmt ? $stmt->execute() : false;170 if($result && ($row = $result->fetchArray()))171 {172 $cache[$category] = $row['CategoryID'];173 return $row['CategoryID'];174 }175 $stmt = $this->db->prepare('INSERT OR IGNORE INTO component_categories (Category) VALUES (:category)');176 $stmt->bindValue(':category', $category);177 $result = $stmt->execute();178 $cache[$category] = $this->db->lastInsertRowid();179 return $cache[$category];180 }181 public function category_id_to_category($category_id)182 {183 static $cache;184 if(isset($cache[$category_id]))185 {186 return $cache[$category_id];187 }188 $stmt = $this->db->prepare('SELECT Category FROM component_categories WHERE CategoryID = :c LIMIT 1');189 $stmt->bindValue(':c', $category_id);190 $result = $stmt ? $stmt->execute() : false;191 if($result && ($row = $result->fetchArray()))192 {193 $cache[$category_id] = $row['Category'];194 return $row['Category'];195 }196 }197 public function rebuild_composite_listing()198 {199 $stmt = $this->db->prepare('SELECT * FROM composite');200 $result = $stmt ? $stmt->execute() : false;201 $json_index_master = array();202 $json_per_version_summary = array();203 $hardware_data['Processor'] = array();204 $hardware_heavy = array();205 while($result && ($row = $result->fetchArray()))206 {207 $comparison_hash = $row['ComparisonHash'];208 $first_appeared = 0;209 $last_appeared = 0;210 $component_results = array();211 $component_dates = array();212 $system_types = array();213 $timing_data = array();214 $stddev_data = array();215 $family_perf = array();216 $results = $this->get_results_array_by_comparison_hash($comparison_hash, $first_appeared, $last_appeared, $component_results, $component_dates, $system_types, $timing_data, $stddev_data);217 if(count($results) < 10)218 {219 continue;220 }221 $percentiles = array();222 for($i = 0; $i < 100; $i++)223 {224 $percentiles[$i] = pts_math::find_percentile($results, ($i * 0.01));225 if($percentiles[$i] > 10)226 {227 $percentiles[$i] = round($percentiles[$i], 5);228 }229 }230 $peak = max($results);231 $component_data = array();232 $comparison_components = array();233 $comparison_components_raw = array();234 foreach($component_results as $component => $d)235 {236 if(stripos($component . ' ', 'device ') !== false || stripos($component, 'unknown') !== false || stripos($component, 'common ') !== false || is_numeric($component))237 {238 continue;239 }240 foreach($d as $related_component => $data)241 {242 if(!isset($comparison_components[$component]))243 {244 $comparison_components[$component] = array();245 }246 $comparison_components[$component] = array_merge($comparison_components[$component], $data);247 if(stripos($related_component . ' ', 'device ') !== false || stripos($related_component, 'unknown') !== false)248 {249 continue;250 }251 if($component_dates[$component][$related_component]['last_appeared'] < (time() - (31536000 * 3)))252 {253 // if no new results in 3 years, likely outdated...254 continue;255 }256 if(count($data) < 3)257 {258 continue;259 }260 $data = pts_math::remove_outliers($data, 3);261 if(count($data) < 3)262 {263 continue;264 }265 $component_data[$component][$related_component]['avg'] = round(pts_math::arithmetic_mean($data), ($peak > 60 ? 0 : 2));266 $component_data[$component][$related_component]['samples'] = count($data);267 $component_data[$component][$related_component]['first_appeared'] = $component_dates[$component][$related_component]['first_appeared'];268 $component_data[$component][$related_component]['last_appeared'] = $component_dates[$component][$related_component]['last_appeared'];269 $component_data[$component][$related_component]['system_type'] = $system_types[$component][$related_component];270 }271 }272 $component_sample_counts = array();273 foreach($comparison_components as $component => &$values)274 {275 $component_sample_counts[$component] = count($values);276 $values = pts_math::remove_outliers($values, 3);277 // FAMILY DATA278 if(isset($this->cpu_index[$component]) && !phodevi::is_fake_device($component))279 {280 // Per Core Calculations281 $brand = false;282 if(stripos($component, 'Intel') !== false)283 {284 $brand = 'Intel';285 }286 else if(stripos($component, 'AMD') !== false)287 {288 $brand = 'AMD';289 }290 if($brand)291 {292 $core_family = $this->cpu_index[$component]['CoreFamily'];293 $series = str_ireplace(array('AMD ', 'Intel ', ), '', $component);294 if(($x = stripos($series, '-Core')) !== false)295 {296 $series = substr($series, 0, $x);297 $series = substr($series, 0, strrpos($series, ' '));298 }299 if(($x = stripos($series, ' x ')) !== false)300 {301 $series = substr($series, ($x + 3));302 }303 $series = str_replace('-', ' ', $series);304 $series = substr($series, 0, strrpos($series, ' '));305 $series = str_replace(array('Dual '), '', $series);306 if(!empty($series))307 {308 $brand_comp_type = phodevi_base::system_type_to_string(phodevi_base::determine_system_type($component));309 $core_family_compare = $brand . ' ' . $core_family . ' ' . $brand_comp_type;310 if(!isset($family_perf[$core_family_compare][$series]))311 {312 $family_perf[$core_family_compare][$series] = array();313 }314 $series_compare = $brand . ' ' . $series . ' ' . $this->cpu_index[$component]['CoreCount'] . '-Core ' . $brand_comp_type;315 if(!isset($family_perf[$series_compare][$core_family]))316 {317 $family_perf[$series_compare][$core_family] = array();318 }319 $value = pts_math::arithmetic_mean($values);320 $always_hib_value = ($row['HigherIsBetter'] == 0 ? (1 / $value) * 1000 : $value) / $this->cpu_index[$component]['CPUClock'];321 $family_perf[$core_family_compare][$series][] = $always_hib_value;322 $family_perf[$series_compare][$core_family][] = $always_hib_value;323 }324 }325 }326 // END OF FAMILY DATA327 if(phodevi::is_fake_device($component) || count($values) < 3 || pts_math::percent_standard_deviation($values) > 15)328 {329 unset($component_sample_counts[$component]);330 unset($comparison_components[$component]);331 continue;332 }333 }334 uasort($comparison_components, array('pts_ae_data', 'sort_array_by_size_of_array_in_value'));335 $comparison_components = array_slice($comparison_components, 0, 300);336 $csc = array();337 $csstd = array();338 $precision = 2;339 foreach($comparison_components as $component => &$values)340 {341 $comparison_components_raw[$component] = $values;342 $csstd[$component] = pts_math::standard_deviation($values);343 $values = pts_math::arithmetic_mean($values);344 if($values < 5)345 {346 $precision = 5;347 }348 else if($values < 20)349 {350 $precision = 3;351 }352 else if($values < 60)353 {354 $precision = 2;355 }356 else if($peak > 100)357 {358 $precision = 0;359 }360 $precision = $precision > 0 ? min($precision, pts_math::get_precision($comparison_components_raw[$component])) : 0;361 $csstd[$component] = round($csstd[$component], $precision);362 $values = round($values, $precision);363 $csc[$component] = $component_sample_counts[$component];364 }365 if($row['HigherIsBetter'] == '1')366 {367 arsort($comparison_components);368 }369 else370 {371 asort($comparison_components);372 }373 // TIMING DATA Assembly374 $td = array();375 $timing_data = pts_math::remove_outliers($timing_data, 3);376 $average_time = round(array_sum($timing_data) / count($timing_data));377 $timing_percentiles = array();378 for($i = 0; $i < 100; $i++)379 {380 $timing_percentiles[$i] = pts_math::find_percentile($timing_data, ($i * 0.01));381 if($timing_percentiles[$i] > 10)382 {383 $timing_percentiles[$i] = round($timing_percentiles[$i]);384 }385 }386 if($average_time > 600)387 {388 $round_to_nearest = 60;389 }390 else if($average_time > 300)391 {392 $round_to_nearest = 30;393 }394 else395 {396 $round_to_nearest = 10;397 }398 foreach($timing_data as $time_consumed)399 {400 $time_consumed = max(1, round($time_consumed / $round_to_nearest)) * $round_to_nearest;401 if($time_consumed > 0)402 {403 if(!isset($td[$time_consumed]))404 {405 $td[$time_consumed] = 0;406 }407 $td[$time_consumed]++;408 }409 }410 // Standard Deviation Percent Data Assembly411 $stddev_data = pts_math::remove_outliers($stddev_data);412 $average_stddev = round(array_sum($stddev_data) / count($stddev_data), 2);413 $std = array();414 foreach($stddev_data as $pdev)415 {416 $pdev = round($pdev, 1);417 if(!isset($std[$pdev]))418 {419 $std[$pdev] = 0;420 }421 $std[$pdev]++;422 }423 // JSON FILE424 $json = array();425 $json['comparison_hash'] = $comparison_hash;426 $json['test_profile'] = $row['TestProfile'];427 $json['title'] = $row['Title'];428 $json['description'] = $row['ArgumentsDescription'];429 $json['test_version'] = substr($row['TestVersion'], 0, strrpos($row['TestVersion'], '.')) . '.x';430 $json['app_version'] = $row['AppVersion'];431 $json['hib'] = $row['HigherIsBetter'];432 $json['unit'] = $row['ResultUnit'];433 $json['samples'] = count($results);434 $json['sample_data'] = implode(',', $results);435 $json['run_time_avg'] = $average_time;436 $json['run_time_data'] = $td;437 $json['stddev_avg'] = $average_stddev;438 $json['stddev_data'] = $std;439 $json['first_appeared'] = $first_appeared;440 $json['last_appeared'] = $last_appeared;441 $json['percentiles'] = $percentiles;442 $json['components'] = $component_data;443 $json['reference_results'] = $comparison_components;444 $json['reference_results_counts'] = $csc;445 $json['reference_results_std_dev'] = $csstd;446 if($json['first_appeared'] < 1298678400)447 {448 // OpenBenchmarking launch date so anything below that would be incorrect timing449 $json['first_appeared'] = strtotime('2011-02-26');450 }451 // FAMILY PERFORMANCE452 foreach($family_perf as $brand => &$data)453 {454 foreach($data as $family => &$sp)455 {456 if(count($sp) < 4)457 {458 // Not enough data to potentially too off...459 unset($family_perf[$brand][$family]);460 continue;461 }462 $sp = array_sum($sp) / count($sp);463 }464 if(count($family_perf[$brand]) < 3)465 {466 unset($family_perf[$brand]);467 }468 }469 foreach($family_perf as $brand => &$data)470 {471 $min_family_perf = min($family_perf[$brand]);472 foreach($data as $family => &$sp)473 {474 $sp = round($sp / $min_family_perf, 2);475 }476 arsort($family_perf[$brand]);477 }478 ksort($family_perf);479 $json['family_perf'] = $family_perf;480 // EO Family Perf481 $json_encoded = json_encode($json);482 if(!empty($json_encoded))483 {484 $test_dir = base64_encode($row['TestProfile']);485 pts_file_io::mkdir($this->ae_dir . 'comparison-hashes/' . $test_dir . '/');486 file_put_contents($this->ae_dir . 'comparison-hashes/' . $test_dir . '/' . $comparison_hash . '.json', $json_encoded);487 if(!isset($json_index_master[$test_dir]))488 {489 $json_index_master[$test_dir] = array();490 }491 $json_index_master[$test_dir][str_replace('.', '', $json['test_version']) . '-' . $json['comparison_hash']] = array(492 'comparison_hash' => $json['comparison_hash'],493 'description' => $json['description'],494 'test_version' => $json['test_version'],495 'app_version' => $json['app_version'],496 'unit' => $json['unit'],497 'samples' => $json['samples'],498 'product_samples' => count($comparison_components),499 );500 if(!isset($json_per_version_summary[$test_dir][$json['test_version']] ))501 {502 $json_per_version_summary[$test_dir][$json['test_version']] = array();503 }504 $json_per_version_summary[$test_dir][$json['test_version']][$json['comparison_hash']] = array(505 //'comparison_hash' => $json['comparison_hash'],506 'description' => $json['description'],507 'test_version' => $json['test_version'],508 'app_version' => $json['app_version'],509 'unit' => $json['unit'],510 'samples' => $json['samples'],511 'timing_samples' => count($timing_data),512 'hib' => $json['hib'],513 'first_appeared' => $json['first_appeared'],514 'last_appeared' => $json['last_appeared'],515 'run_time_avg' => $json['run_time_avg'],516 'stddev_avg' => $json['stddev_avg'],517 'percentiles' => $json['percentiles'],518 'run_time_percentiles' => $timing_percentiles,519 );520 }521 // EO JSON522 $stmt = $this->db->prepare('UPDATE composite SET SampleSize = :ss, Percentiles = :p, FirstAppeared = :fa, LastAppeared = :la WHERE ComparisonHash = :ch');523 $stmt->bindValue(':ss', count($results));524 $stmt->bindValue(':ch', $comparison_hash);525 $stmt->bindValue(':p', implode(',', $percentiles));526 $stmt->bindValue(':fa', $first_appeared);527 $stmt->bindValue(':la', $last_appeared);528 $stmt->execute();529 530 //531 // Update/Create Component JSON532 //533 534 if(count($comparison_components) >= 20 && $json['stddev_avg'] < 3 && $json['run_time_avg'] > 45 && $last_appeared > strtotime('-5 months'))535 {536 foreach($comparison_components as $component => $value)537 {538 $component_category = $this->component_to_category($component);539 $this_percentile = $this->result_to_percentile($value, $percentiles, $json['hib']);540 541 if(!is_numeric($this_percentile) || $this_percentile == 0)542 {543 continue;544 }545 switch($component_category)546 {547 case 'Graphics':548 case 'Disk':549 if(strpos($component, ' x ') !== false)550 {551 // Don't want multi-disk reporting as who knows the RAID setup or if JBOD mixed in, etc552 break;...

Full Screen

Full Screen

component_to_category

Using AI Code Generation

copy

Full Screen

1require_once('pts_ae_data.php');2$data = new pts_ae_data();3$component = 'component';4$category = 'category';5$data->component_to_category($component, $category);6require_once('pts_ae_data.php');7$data = new pts_ae_data();8$component = 'component';9$category = 'category';10$data->category_to_component($component, $category);11require_once('pts_ae_data.php');12$data = new pts_ae_data();13$component = 'component';14$data->get_component_level($component);15require_once('pts_ae_data.php');16$data = new pts_ae_data();17$component = 'component';18$data->get_component_level($component);19require_once('pts_ae_data.php');20$data = new pts_ae_data();21$component = 'component';22$data->get_component_level($component);23require_once('pts_ae_data.php');24$data = new pts_ae_data();25$component = 'component';26$data->get_component_level($component);27require_once('pts_ae_data.php');28$data = new pts_ae_data();29$component = 'component';30$data->get_component_level($component);31require_once('pts_ae_data.php');32$data = new pts_ae_data();33$component = 'component';34$data->get_component_level($component);35require_once('pts_ae_data.php');36$data = new pts_ae_data();37$component = 'component';38$data->get_component_level($component);39require_once('pts_a

Full Screen

Full Screen

component_to_category

Using AI Code Generation

copy

Full Screen

1include_once('pts_ae_data.php');2$obj = new pts_ae_data();3$category = $obj->component_to_category('component1');4echo $category;5include_once('pts_ae_data.php');6$obj = new pts_ae_data();7$category = $obj->component_to_category('component2');8echo $category;9include_once('pts_ae_data.php');10$obj = new pts_ae_data();11$category = $obj->component_to_category('component3');12echo $category;13include_once('pts_ae_data.php');14$obj = new pts_ae_data();15$category = $obj->component_to_category('component4');16echo $category;17include_once('pts_ae_data.php');18$obj = new pts_ae_data();

Full Screen

Full Screen

component_to_category

Using AI Code Generation

copy

Full Screen

1$component = $_REQUEST['component'];2$category = $aeData->component_to_category($component);3echo $category;4$category = $_REQUEST['category'];5$component = $aeData->category_to_component($category);6echo $component;7$category = $_REQUEST['category'];8$components = $aeData->category_to_component($category, true);9print_r($components);10$component = $_REQUEST['component'];11$categories = $aeData->component_to_category($component, true);12print_r($categories);

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

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