I remember when PHP 7 was released. The first thing I did was a simple performance test. I don’t remember the script exactly, but it was similar to this:
<?php
$time = microtime(true);
$array = [];
for ($i = 0; $i < 10000; $i++) {
if (!array_key_exists($i, $array)) {
$array[$i] = [];
}
for ($j = 0; $j < 1000; $j++) {
if (!array_key_exists($j, $array[$i])) {
$array[$i][$j] = true;
}
}
}
echo sprintf(
"Execution time: %f seconds\nMemory usage: %f MB\n\n",
microtime(true) - $time,
memory_get_usage(true) / 1024 / 1024
);
The results made me really happy. Continue reading PHP performance increase from 5.6 to 7.2