Best Phoronix-test-suite code snippet using pts_test_result_buffer.recalculate_buffer_items_min_max
pts_test_result_buffer.php
Source:pts_test_result_buffer.php
...87 }88 }89 return false;90 }91 public function recalculate_buffer_items_min_max()92 {93 $this->min_value = 0;94 $this->max_value = 0;95 foreach($this->buffer_items as &$buffer_item)96 {97 $this->check_buffer_item_for_min_max($buffer_item);98 }99 }100 protected function check_buffer_item_for_min_max(&$buffer_item)101 {102 $value = $buffer_item->get_result_value();103 if(!is_numeric($value))104 {105 $values = !is_array($value) ? explode(',', $value) : $value;106 $min_value = min($values);107 $max_value = max($values);108 if(!is_numeric($min_value))109 {110 return;111 }112 }113 else114 {115 $min_value = $value;116 $max_value = $value;117 }118 if($min_value < $this->min_value || $this->min_value == 0)119 {120 $this->min_value = $min_value;121 $this->min_bi = $buffer_item;122 }123 if($max_value > $this->max_value)124 {125 $this->max_value = $max_value;126 $this->max_bi = $buffer_item;127 }128 // Also check precision129 $this->max_precision = max($this->max_precision, pts_math::get_precision($buffer_item->get_result_value()));130 }131 public function __clone()132 {133 foreach($this->buffer_items as $i => $v)134 {135 $this->buffer_items[$i] = clone $this->buffer_items[$i];136 }137 }138 public function get_buffer_items()139 {140 return $this->buffer_items;141 }142 public function sort_buffer_items()143 {144 sort($this->buffer_items);145 }146 public function sort_buffer_values($asc = true)147 {148 usort($this->buffer_items, array('pts_test_result_buffer', 'buffer_value_comparison'));149 if($asc == false)150 {151 $this->buffer_items = array_reverse($this->buffer_items);152 }153 }154 public static function buffer_value_comparison($a, $b)155 {156 return strcmp($a->get_result_value(), $b->get_result_value());157 }158 public function find_buffer_item($identifier)159 {160 foreach($this->buffer_items as &$buf)161 {162 if($buf->get_result_identifier() == $identifier)163 {164 return $buf;165 }166 }167 return false;168 }169 public function get_result_from_identifier($identifier)170 {171 foreach($this->buffer_items as &$buf)172 {173 if($buf->get_result_identifier() == $identifier)174 {175 return $buf->get_result_value();176 }177 }178 return false;179 }180 public function buffer_contained(&$buffer_item)181 {182 return isset($this->buffer_contains[$buffer_item->get_result_identifier() . $buffer_item->get_result_value()]);183 }184 public function get_buffer_item($i)185 {186 return isset($this->buffer_items[$i]) ? $this->buffer_items[$i] : false;187 }188 public function detected_multi_sample_result()189 {190 return $this->added_multi_sample_result;191 }192 public function clear_outlier_results($value_below)193 {194 $cleared = false;195 foreach($this->buffer_items as $key => &$buffer_item)196 {197 if($buffer_item->get_result_value() < $value_below)198 {199 $other_value += $buffer_item->get_result_value();200 unset($this->buffer_items[$key]);201 $cleared = true;202 }203 }204 if($cleared)205 {206 $this->recalculate_buffer_items_min_max();207 }208 }209 public function rename($from, $to)210 {211 if($from == 'PREFIX')212 {213 foreach($this->buffer_items as &$buffer_item)214 {215 $buffer_item->reset_result_identifier($to . ': ' . $buffer_item->get_result_identifier());216 }217 }218 else if($from == null && count($this->buffer_items) == 1)219 {220 foreach($this->buffer_items as &$buffer_item)221 {222 $buffer_item->reset_result_identifier($to);223 }224 return true;225 }226 else227 {228 foreach($this->buffer_items as &$buffer_item)229 {230 if($buffer_item->get_result_identifier() == $from)231 {232 $buffer_item->reset_result_identifier($to);233 return true;234 }235 }236 }237 return false;238 }239 public function reorder($new_order)240 {241 foreach($new_order as $identifier)242 {243 foreach($this->buffer_items as $i => &$buffer_item)244 {245 if($buffer_item->get_result_identifier() == $identifier)246 {247 $c = $buffer_item;248 unset($this->buffer_items[$i]);249 $this->buffer_items[] = $c;250 break;251 }252 }253 }254 }255 public function remove($remove)256 {257 $remove = pts_arrays::to_array($remove);258 $removed = false;259 foreach($this->buffer_items as $i => &$buffer_item)260 {261 if(in_array($buffer_item->get_result_identifier(), $remove))262 {263 unset($this->buffer_by_identifier[$this->buffer_items[$i]->get_result_identifier()]);264 unset($this->buffer_contains[$this->buffer_items[$i]->get_result_identifier() . $this->buffer_items[$i]->get_result_value()]);265 unset($this->buffer_items[$i]);266 $removed = true;267 }268 }269 if($removed)270 {271 $this->recalculate_buffer_items_min_max();272 }273 return $removed;274 }275 public function auto_shorten_buffer_identifiers($identifier_shorten_index = false)276 {277 // If there's a lot to plot, try to auto-shorten the identifiers278 // e.g. if each identifier contains like 'GeForce 6800', 'GeForce GT 220', etc..279 // then remove the 'GeForce' part of the name.280 if($identifier_shorten_index == false)281 {282 $identifier_shorten_index = pts_render::evaluate_redundant_identifier_words($this->get_identifiers());283 }284 if(empty($identifier_shorten_index))285 {286 return false;287 }288 foreach($this->buffer_items as &$buffer_item)289 {290 $identifier = explode(' ', $buffer_item->get_result_identifier());291 foreach($identifier_shorten_index as $pos => $value)292 {293 if($identifier[$pos] == $value)294 {295 unset($identifier[$pos]);296 }297 }298 $buffer_item->reset_result_identifier(implode(' ', $identifier));299 }300 return true;301 }302 public function clear_iqr_outlier_results()303 {304 $is_multi_way = pts_render::multi_way_identifier_check($this->get_identifiers());305 $cleared = false;306 if($is_multi_way)307 {308 $group_values = array();309 $group_keys = array();310 foreach($this->buffer_items as $key => &$buffer_item)311 {312 $identifier_r = pts_strings::trim_explode(': ', $buffer_item->get_result_identifier());313 if(!isset($group_values[$identifier_r[1]]))314 {315 $group_values[$identifier_r[1]] = array();316 $group_keys[$identifier_r[1]] = array();317 }318 $group_values[$identifier_r[1]][] = $buffer_item->get_result_value();319 $group_keys[$identifier_r[1]][] = $key;320 }321 foreach($group_values as $group_key => $values)322 {323 // From: http://www.mathwords.com/o/outlier.htm324 $fqr = pts_math::first_quartile($values);325 $tqr = pts_math::third_quartile($values);326 $iqr_cut = ($tqr - $fqr) * 1.5;327 $bottom_cut = $fqr - $iqr_cut;328 $top_cut = $tqr + $iqr_cut;329 foreach($group_keys[$group_key] as $key)330 {331 $value = $this->buffer_items[$key]->get_result_value();332 if($value > $top_cut || $value < $bottom_cut)333 {334 unset($this->buffer_items[$key]);335 $cleared = true;336 }337 }338 }339 }340 else341 {342 // From: http://www.mathwords.com/o/outlier.htm343 $values = $this->get_values();344 $fqr = pts_math::first_quartile($values);345 $tqr = pts_math::third_quartile($values);346 $iqr_cut = ($tqr - $fqr) * 1.5;347 $bottom_cut = $fqr - $iqr_cut;348 $top_cut = $tqr + $iqr_cut;349 foreach($this->buffer_items as $key => &$buffer_item)350 {351 $value = $buffer_item->get_result_value();352 if($value > $top_cut || $value < $bottom_cut)353 {354 unset($this->buffer_items[$key]);355 $cleared = true;356 }357 }358 }359 if($cleared)360 {361 $this->recalculate_buffer_items_min_max();362 }363 }364 public function buffer_values_sort()365 {366 usort($this->buffer_items, array('pts_test_result_buffer_item', 'compare_value'));367 }368 public function buffer_values_reverse()369 {370 $this->buffer_items = array_reverse($this->buffer_items);371 }372 public function get_count()373 {374 return count($this->buffer_items);375 }...
recalculate_buffer_items_min_max
Using AI Code Generation
1require_once('pts-core.php');2$buffer = new pts_test_result_buffer();3$buffer->recalculate_buffer_items_min_max();4$buffer->save_to_file('test_buffer.xml');5require_once('pts-core.php');6$buffer = new pts_test_result_buffer();7$buffer->load_from_file('test_buffer.xml');8print_r($buffer->get_array());9require_once('pts-core.php');10$buffer = new pts_test_result_buffer();11$buffer->load_from_file('test_buffer.xml');12$buffer->recalculate_buffer_items_min_max();13$buffer->save_to_file('test_buffer.xml');14require_once('pts-core.php');15$buffer = new pts_test_result_buffer();16$buffer->load_from_file('test_buffer.xml');17print_r($buffer->get_array());18require_once('pts-core.php');19$buffer = new pts_test_result_buffer();20$buffer->load_from_file('test_buffer.xml');21$buffer->recalculate_buffer_items_min_max();22$buffer->save_to_file('test_buffer.xml');23require_once('pts-core.php');24$buffer = new pts_test_result_buffer();25$buffer->load_from_file('test_buffer.xml');26print_r($buffer->get_array());27require_once('pts-core.php');28$buffer = new pts_test_result_buffer();29$buffer->load_from_file('test_buffer.xml');30$buffer->recalculate_buffer_items_min_max();31$buffer->save_to_file('test_buffer.xml');32require_once('pts-core.php');33$buffer = new pts_test_result_buffer();34$buffer->load_from_file('test_buffer.xml');35print_r($buffer->get_array());36require_once('pts-core.php');
recalculate_buffer_items_min_max
Using AI Code Generation
1require_once 'pts_test_result_buffer.php';2$buffer = new pts_test_result_buffer( 'buffer.json' );3$buffer->recalculate_buffer_items_min_max();4$buffer->save_to_file();5require_once 'pts_test_result_buffer.php';6$buffer = new pts_test_result_buffer( 'buffer.json' );7$buffer->get_buffer_item_min_max();8$buffer->save_to_file();
recalculate_buffer_items_min_max
Using AI Code Generation
1require_once('pts-core.php');2require_once('pts-core/objects/pts_test_result_buffer.php');3$buffer = new pts_test_result_buffer();4$buffer->load_buffer_from_file('buffer.xml');5$buffer->recalculate_buffer_items_min_max();6$buffer->save_buffer_to_file('buffer.xml');7$buffer->save_buffer_to_file('buffer_new.xml');8$buffer->save_buffer_to_file();9$buffer->save_buffer_to_file('buffer_new.xml');10$buffer->save_buffer_to_file();11$buffer->save_buffer_to_file('buffer_new.xml');12$buffer->save_buffer_to_file();
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 recalculate_buffer_items_min_max 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!!