How to use set_precision method of pts_math class

Best Phoronix-test-suite code snippet using pts_math.set_precision

pts_test_result_buffer.php

Source:pts_test_result_buffer.php Github

copy

Full Screen

...353 return $max_id;354 }355 else356 {357 return pts_math::set_precision($value, $precision);358 }359 }360 public function get_max_precision()361 {362 $max_precision = 0;363 foreach($this->buffer_items as &$buffer_item)364 {365 $max_precision = max($max_precision, pts_math::get_precision($buffer_item->get_result_value()));366 }367 return $max_precision;368 }369 public function reset_precision($precision)370 {371 foreach($this->buffer_items as &$buffer_item)372 {373 $p = pts_math::set_precision($buffer_item->get_result_value(), $precision);374 $buffer_item->reset_result_value($p, false);375 }376 }377 public function reduce_precision()378 {379 $min_value = $this->get_min_value();380 $max_value = $this->get_max_value();381 if($min_value > 20 && ($max_value / $min_value) > 1.25)382 {383 $this->reset_precision(0);384 }385 else386 {387 $max_precision = $this->get_max_precision();388 if($max_precision >= 1)389 {390 if($min_value > 10 && $max_precision > 1)391 {392 $max_precision = 2;393 }394 /*else if($max_precision > 3 && ($max_value / $min_value) > 1.3)395 {396 $max_precision = 3;397 }*/398 else if($max_precision > 3)399 {400 $max_precision = 3;401 }402 $this->reset_precision(($max_precision - 1));403 }404 }405 }406 public function get_min_value($return_identifier = false)407 {408 $bi = null;409 $value = 0;410 $min_id = null;411 $precision = 2;412 foreach($this->buffer_items as &$buffer_item)413 {414 $precision = max($precision, pts_math::get_precision($buffer_item->get_result_value()));415 if($buffer_item->get_result_value() < $value || $value == 0)416 {417 $value = $buffer_item->get_result_value();418 $min_id = $buffer_item->get_result_identifier();419 $bi = $buffer_item;420 }421 }422 if($return_identifier === 2)423 {424 return $bi;425 }426 else if($return_identifier)427 {428 return $min_id;429 }430 else431 {432 return pts_math::set_precision($value, $precision);433 }434 }435 public function has_run_with_multiple_samples()436 {437 foreach($this->buffer_items as &$buffer_item)438 {439 if($buffer_item->get_sample_count() > 1)440 {441 return true;442 }443 }444 return false;445 }446 public function get_value_from_identifier($result_identifier)447 {448 foreach($this->buffer_items as &$buffer_item)449 {450 if($buffer_item->get_result_identifier() == $result_identifier)451 {452 return $buffer_item->get_result_value();453 }454 }455 return false;456 }457 public function buffer_values_to_percent()458 {459 $is_multi_way = pts_render::multi_way_identifier_check($this->get_identifiers());460 if($is_multi_way)461 {462 $group_values = array();463 foreach($this->buffer_items as &$buffer_item)464 {465 $identifier_r = pts_strings::trim_explode(': ', $buffer_item->get_result_identifier());466 if(!isset($group_values[$identifier_r[1]]))467 {468 $group_values[$identifier_r[1]] = 0;469 }470 $group_values[$identifier_r[1]] += $buffer_item->get_result_value();471 }472 foreach($this->buffer_items as &$buffer_item)473 {474 $identifier_r = pts_strings::trim_explode(': ', $buffer_item->get_result_identifier());475 $percent = pts_math::set_precision(($buffer_item->get_result_value() / $group_values[$identifier_r[1]] * 100), 3);476 $buffer_item->reset_result_value($percent);477 }478 }479 else480 {481 $total_value = array_sum($this->get_values());482 foreach($this->buffer_items as &$buffer_item)483 {484 $percent = pts_math::set_precision(($buffer_item->get_result_value() / $total_value * 100), 3);485 $buffer_item->reset_result_value($percent);486 }487 }488 }489 public function adjust_precision($precision = 'auto')490 {491 if($precision == 'auto')492 {493 // For very large results, little point in keeping the precision...494 $min_value = $this->get_min_value();495 $precision = -1;496 if($min_value >= 100)497 {498 $precision = 0;499 }500 if($min_value >= 10)501 {502 $precision = 2;503 }504 $current_precision = 0;505 foreach($this->buffer_items as &$buffer_item)506 {507 if(is_numeric(($val = $buffer_item->get_result_value())))508 {509 $current_precision = max($current_precision, pts_math::get_precision($val));510 }511 }512 $precision = $precision == -1 ? $current_precision : min($precision, $current_precision);513 }514 if(is_numeric($precision))515 {516 foreach($this->buffer_items as &$buffer_item)517 {518 if(is_numeric(($val = $buffer_item->get_result_value())))519 {520 $buffer_item->reset_result_value(pts_math::set_precision($val, $precision), false);521 }522 }523 }524 }525 public function get_values()526 {527 $values = array();528 foreach($this->buffer_items as &$buffer_item)529 {530 $values[] = $buffer_item->get_result_value();531 }532 return $values;533 }534 public function get_median()...

Full Screen

Full Screen

pts_ResultFileTable.php

Source:pts_ResultFileTable.php Github

copy

Full Screen

...158 {159 $identifier = $buffer_item->get_result_identifier();160 $value = $buffer_item->get_result_value();161 $raw_values = pts_strings::colon_explode($buffer_item->get_result_raw());162 $percent_std = pts_math::set_precision(pts_math::percent_standard_deviation($raw_values), 2);163 $std_error = pts_math::set_precision(pts_math::standard_error($raw_values), 2);164 $delta = 0;165 if(defined('PHOROMATIC_TRACKER'))166 {167 $identifier_r = pts_strings::colon_explode($identifier);168 if($identifier_r[0] == $prev_identifier_0 && $prev_value != 0)169 {170 $delta = pts_math::set_precision(abs(1 - ($value / $prev_value)), 4);171 if($delta > 0.02 && $delta > pts_math::standard_deviation($raw_values))172 {173 switch($result_object->test_profile->get_result_proportion())174 {175 case 'HIB':176 if($value < $prev_value)177 {178 $delta = 0 - $delta;179 }180 break;181 case 'LIB':182 if($value > $prev_value)183 {184 $delta = 0 - $delta;185 }186 break;187 }188 }189 else190 {191 $delta = 0;192 }193 }194 $prev_identifier_0 = $identifier_r[0];195 $highlight = false;196 $alert = false;197 }198 else199 {200 if($result_file->is_multi_way_comparison())201 {202 // TODO: make it work better for highlighting multiple winners in multi-way comparisons203 $highlight = false;204 $alert = false;205 // TODO: get this working right206 if(false && $index % 2 == 1 && $prev_value != 0)207 {208 switch($result_object->test_profile->get_result_proportion())209 {210 case 'HIB':211 if($value > $prev_value)212 {213 $highlight = true;214 }215 else216 {217 $result_table[$prev_identifier][$result_counter]->set_attribute('highlight', true);218 $result_table[$prev_identifier][$result_counter]->set_attribute('delta', -1);219 }220 break;221 case 'LIB':222 if($value < $prev_value)223 {224 $highlight = true;225 }226 else227 {228 $result_table[$prev_identifier][$result_counter]->set_attribute('highlight', true);229 $result_table[$prev_identifier][$result_counter]->set_attribute('delta', -1);230 }231 break;232 }233 }234 }235 else236 {237 $alert = $worst_value == $value;238 $highlight = $best_value == $value;239 }240 if($min_value_in_buffer != $max_value_in_buffer)241 {242 switch($result_object->test_profile->get_result_proportion())243 {244 case 'HIB':245 $delta = pts_math::set_precision($value / $min_value_in_buffer, 2);246 break;247 case 'LIB':248 $delta = pts_math::set_precision(1 - ($value / $max_value_in_buffer) + 1, 2);249 break;250 }251 }252 }253 $attributes = array(254 'std_percent' => $percent_std,255 'std_error' => $std_error,256 'delta' => $delta,257 'highlight' => $highlight,258 'alert' => $alert259 );260 if($delta > $percent_std && $flag_delta_results !== false)261 {262 $flag_delta_results[$ri] = $delta;263 }264 $result_table[$identifier][$result_counter] = new pts_graph_ir_value($value, $attributes);265 $prev_identifier = $identifier;266 $prev_value = $value;267 }268 break;269 case 'LINE_GRAPH':270 case 'FILLED_LINE_GRAPH':271 $result_tests[$result_counter] = new pts_graph_ir_value($result_object->test_profile->get_title() . ' (Avg)');272 foreach($result_object->test_result_buffer->get_buffer_items() as $index => $buffer_item)273 {274 $identifier = $buffer_item->get_result_identifier();275 $values = pts_strings::comma_explode($buffer_item->get_result_value());276 $avg_value = pts_math::set_precision(array_sum($values) / count($values), 2);277 $result_table[$identifier][$result_counter] = new pts_graph_ir_value($avg_value);278 }279 break;280 }281 $result_counter++;282 }283 if($result_counter == 1)284 {285 // This should provide some additional information under normal modes286 $has_written_std = false;287 $has_written_diff = false;288 $has_written_error = false;289 foreach($result_table as $identifier => $info)290 {...

Full Screen

Full Screen

set_precision

Using AI Code Generation

copy

Full Screen

1require_once('pts_math.php');2$pts_math = new pts_math();3$pts_math->set_precision(2);4echo $pts_math->pi();5require_once('pts_math.php');6$pts_math = new pts_math();7$pts_math->set_precision(3);8echo $pts_math->pi();9require_once('pts_math.php');10$pts_math = new pts_math();11$pts_math->set_precision(4);12echo $pts_math->pi();13require_once('pts_math.php');14$pts_math = new pts_math();15$pts_math->set_precision(5);16echo $pts_math->pi();17require_once('pts_math.php');18$pts_math = new pts_math();19$pts_math->set_precision(6);20echo $pts_math->pi();21require_once('pts_math.php');22$pts_math = new pts_math();23$pts_math->set_precision(7);24echo $pts_math->pi();25require_once('pts_math.php');26$pts_math = new pts_math();27$pts_math->set_precision(8);28echo $pts_math->pi();29require_once('pts_math.php');30$pts_math = new pts_math();31$pts_math->set_precision(9);32echo $pts_math->pi();33require_once('pts_math.php');34$pts_math = new pts_math();35$pts_math->set_precision(10);36echo $pts_math->pi();37require_once('pts_math.php');38$pts_math = new pts_math();39$pts_math->set_precision(11);40echo $pts_math->pi();

Full Screen

Full Screen

set_precision

Using AI Code Generation

copy

Full Screen

1require_once 'pts_math.php';2$pts_math = new pts_math();3$pts_math->set_precision(2);4echo $pts_math->round(2.123456789);5require_once 'pts_math.php';6$pts_math = new pts_math();7echo $pts_math->round(2.123456789);8require_once 'pts_math.php';9$pts_math = new pts_math();10echo $pts_math->round(2.123456789, 2);11require_once 'pts_math.php';12$pts_math = new pts_math();13echo $pts_math->round(2.123456789, 2, PHP_ROUND_HALF_UP);14require_once 'pts_math.php';15$pts_math = new pts_math();16echo $pts_math->round(2.123456789, 2, PHP_ROUND_HALF_UP, true);17require_once 'pts_math.php';18$pts_math = new pts_math();19echo $pts_math->round(2.123456789, 2, PHP_ROUND_HALF_UP, false);20require_once 'pts_math.php';21$pts_math = new pts_math();22echo $pts_math->round(2.123456789, 2, PHP_ROUND_HALF_UP, false, 'en');23require_once 'pts_math.php';24$pts_math = new pts_math();25echo $pts_math->round(2.123456789, 2, PHP_ROUND_HALF_UP, false, 'fr');26require_once 'pts_math.php';27$pts_math = new pts_math();28echo $pts_math->round(2.123456789, 2, PHP_ROUND_HALF_UP, false, 'de');

Full Screen

Full Screen

set_precision

Using AI Code Generation

copy

Full Screen

1include 'pts_math.php';2$obj = new pts_math();3$obj->set_precision(2);4echo $obj->add(10, 20);5include 'pts_math.php';6$obj = new pts_math();7$obj->set_precision(3);8echo $obj->add(10, 20);9include 'pts_math.php';10$obj = new pts_math();11$obj->set_precision(4);12echo $obj->add(10, 20);13include 'pts_math.php';14$obj = new pts_math();15$obj->set_precision(5);16echo $obj->add(10, 20);17include 'pts_math.php';18$obj = new pts_math();19$obj->set_precision(6);20echo $obj->add(10, 20);21include 'pts_math.php';22$obj = new pts_math();23$obj->set_precision(7);24echo $obj->add(10, 20);25include 'pts_math.php';26$obj = new pts_math();27$obj->set_precision(8);28echo $obj->add(10, 20);29include 'pts_math.php';30$obj = new pts_math();31$obj->set_precision(9);32echo $obj->add(10, 20);

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

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