Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  Supercolliding a PHP array

Did you know that inserting 2^16 = 65536 specially crafted values into a normal PHP array can take 30 seconds? Normally this would take only 0.01 seconds.This is the code to reproduce it:<?php echo '<pre>';$size = pow(2, 16); // 16 is just an example, could also be 15 or 17$startTime = microtime(true);$array = array();for ($key = 0, $maxKey = ($size - 1) * $size; $key <= $maxKey; $key += $size) { $array[$key] = 0;}$endTime = microtime(true);echo 'Inserting ', $size, ' evil elements took ', $endTime - $startTime, ' seconds', "\n";$startTime = microtime(true);$array = arra...

2,549 0       PHP ARRAY HASHTABLE SLOW COLLIDING