3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values = range(1, 10000); $c = 0; $start = microtime(true); $l = count($values); $i = 0; while ($i < $l) { $c++; $i++; } $end = microtime(true); printf('while $i++ %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $l = count($values); for ($i = 0; $i < $l; $i++) { $c++; } $end = microtime(true); printf('for $i++ %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); foreach ($values as $val) { $c++; } $end = microtime(true); printf('foreach %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $value = reset($values); while ($value) { $c++; $value = next($values); } $end = microtime(true); printf('while reset, next %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); while ($val = current($values)) { $c++; next($values); } $end = microtime(true); printf('while current, next %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $value = current($values); do{ $c++; }while($value = next($values)); $end = microtime(true); printf('do while next %d iterations in %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); while ($values) { $c++; array_shift($values); } $end = microtime(true); printf('while array_shift %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $values = array_reverse($values); while ($values) { $c++; array_pop($values); } $end = microtime(true); printf('while array_pop %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL;
Output for git.master
while $i++ 10000 iterations in: 0.000041 sec for $i++ 10000 iterations in: 0.000040 sec foreach 10000 iterations in: 0.000054 sec while reset, next 10000 iterations in: 0.000328 sec while current, next 10000 iterations in: 0.000429 sec do while next 10000 iterations in 0.000328 sec while array_shift 10000 iterations in: 0.083187 sec while array_pop 10000 iterations in: 0.000335 sec
Output for git.master_jit
while $i++ 10000 iterations in: 0.000040 sec for $i++ 10000 iterations in: 0.000044 sec foreach 10000 iterations in: 0.000061 sec while reset, next 10000 iterations in: 0.000320 sec while current, next 10000 iterations in: 0.000472 sec do while next 10000 iterations in 0.000344 sec while array_shift 10000 iterations in: 0.083250 sec while array_pop 10000 iterations in: 0.000369 sec

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.38 ms | 401 KiB | 7 Q