3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(); $l = 100000; for($i = 0; $i< $l; $i++) { $array[$i] = md5($i); } $copy = $array; $start = microtime(true); for($i = 0; $i< $l; $i++) { $copy[$i] = $copy[$i] . ' x'; usleep(1); } echo "\nfor:" . (microtime(true) - $start); $copy = $array; $start = microtime(true); foreach ($copy as $i => $item) { $copy[$i] = $item . ' x'; usleep(1); } echo "\nforeach (ohne ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); foreach ($copy as &$item) { $item .= ' x'; usleep(1); } echo "\nforeach (mit ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); array_walk($copy, function (&$item, $i) { $item .= ' x'; usleep(1); }); echo "\narray_walk (mit ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); $copy = array_map(function ($item) { $item .= ' x'; usleep(1); return $item; }, $copy); echo "\narray_map (ohne ref):" . (microtime(true) - $start);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.210.2070.33751.46
5.4.200.1930.32351.16
5.4.190.2400.32351.52
5.4.180.2230.37751.24
5.4.170.2300.35051.29
5.4.160.2330.30350.98
5.4.150.2100.33351.33
5.4.140.1700.38748.66
5.4.130.2500.30048.73
5.4.120.2170.35748.76
5.4.110.2430.34348.88
5.4.100.2000.36748.57
5.4.90.2530.30348.64
5.4.80.2800.26348.56
5.4.70.1800.35748.43
5.4.60.1900.33048.48
5.4.50.2100.33048.55
5.4.40.2270.36748.52
5.4.30.2270.33748.43
5.4.20.1700.36048.70
5.4.10.2070.36048.62
5.4.00.2400.32748.06
5.3.270.2370.42046.12
5.3.260.2230.37046.23
5.3.250.2330.35046.11
5.3.240.2900.32746.20
5.3.230.2130.38346.17
5.3.220.2100.41046.11
5.3.210.1900.42046.34
5.3.200.2730.32346.36
5.3.190.2130.37046.25
5.3.180.2130.37746.39
5.3.170.1800.36046.12
5.3.160.2070.35046.28
5.3.150.2070.36746.24
5.3.140.1730.42346.14
5.3.130.2030.38346.04
5.3.120.2230.30046.39
5.3.110.2200.38046.13
5.3.100.2100.36345.72
5.3.90.2570.33045.70
5.3.80.2630.35045.79
5.3.70.2270.36745.66
5.3.60.1930.37745.55
5.3.50.2070.37345.61
5.3.40.1800.39345.63

preferences:
33.68 ms | 400 KiB | 5 Q