- microtime: documentation ( source)
- ceil: documentation ( source)
- log: documentation ( source)
<?php
$x = 129;
$i = 1;
$y = 1;
$m = microtime(true);
for ($i = 1; $i <= 1000; ++$i){
$y = 1 << ceil(log($x, 2));
echo (microtime(true) - $m), "\n\r";
}
$y = 1;
$m = microtime(true);
for ($i = 1; $i <= 1000; ++$i){
while ($y < $x) {
$y = $y <<1;
}
}
echo microtime(true) - $m;