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'; } echo "\nfor:" . microtime(true) - $start; $copy = $array; $start = microtime(true); foreach ($copy as $i => $item) { $copy[$i] = $item . ' x'; } echo "\nforeach (ohne ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); foreach ($copy as &$item) { $item .= ' x'; } echo "\nforeach (mit ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); array_walk($copy, function (&$item, $i) { $item .= ' x'; }); echo "\narray_walk (mit ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); $copy = array_map(function ($item) { $item .= ' x'; 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)
7.2.00.0130.06641.02
7.1.70.0030.07639.07
7.1.60.0070.12839.11
7.1.50.0870.10838.98
7.1.00.0030.09744.22
7.0.200.0130.08638.80
7.0.140.0070.16744.01
7.0.100.0400.17740.42
7.0.90.0300.14040.43
7.0.80.3270.16740.36
7.0.70.0230.16340.41
7.0.60.0200.20740.40
7.0.50.2830.14040.83
7.0.40.2500.15325.95
7.0.30.0130.16725.84
7.0.20.0130.17025.96
7.0.10.0500.14325.96
7.0.00.2230.13725.96
5.6.280.0170.29769.41
5.6.250.0500.27769.19
5.6.240.0430.26369.07
5.6.230.0430.27769.23
5.6.220.0330.30069.05
5.6.210.0570.30069.24
5.6.200.0500.25769.64
5.6.190.0270.28069.61
5.6.180.0500.27369.60
5.6.170.0330.26369.63
5.6.160.0230.28069.57
5.6.150.0200.27769.64
5.6.140.0230.28069.47
5.6.130.0370.24069.65
5.6.120.0330.26769.59
5.6.110.0370.26769.69
5.6.100.0500.25069.71
5.6.90.0370.30369.57
5.6.80.0430.25369.00
5.6.70.0370.26069.02
5.6.60.0370.23068.95
5.6.50.0270.26368.96
5.6.40.0230.22769.05
5.6.30.0330.25369.03
5.6.20.0330.27369.03
5.6.10.0370.27068.85
5.6.00.0200.23068.95
5.5.380.0370.32369.01
5.5.370.0370.30069.06
5.5.360.0470.26769.00
5.5.350.0270.29069.01
5.5.340.0430.25769.48
5.5.330.0470.25369.47
5.5.320.0170.28369.47
5.5.310.0270.28769.48
5.5.300.0330.29069.46
5.5.290.0470.25769.44
5.5.280.0330.28369.48
5.5.270.0300.28069.44
5.5.260.0230.28769.33
5.5.250.0500.29069.30
5.5.240.0330.24368.86
5.5.230.0370.24368.81
5.5.220.0330.23068.82
5.5.210.0400.27768.54
5.5.200.0300.29368.71
5.5.190.0400.26768.55
5.5.180.0370.25368.71
5.5.160.0370.20368.83
5.5.150.0370.21068.79
5.5.140.0230.18068.74
5.5.130.0370.21768.77
5.5.120.0130.24768.80
5.5.110.0300.28068.83
5.5.100.0100.25768.63
5.5.90.0300.20768.67
5.5.80.0330.22368.65
5.5.70.0430.20068.71
5.5.60.0230.25768.61
5.5.50.0170.28768.61
5.5.40.0330.24068.49
5.5.30.0500.25068.58
5.5.20.0470.23768.65
5.5.10.0400.25068.69
5.5.00.0270.30068.64
5.4.450.0430.26067.87
5.4.440.0430.23068.00
5.4.430.0470.25367.84
5.4.420.0330.23767.71
5.4.410.0570.27367.66
5.4.400.0270.25767.36
5.4.390.0300.28367.52
5.4.380.0330.25367.39
5.4.370.0400.26767.37
5.4.360.0430.26067.46
5.4.350.0300.27067.54
5.4.340.0470.24067.52
5.4.320.0270.18067.52
5.4.310.0230.22367.60
5.4.300.0270.19067.60
5.4.290.0270.21067.59
5.4.280.0300.21067.38
5.4.270.0400.22067.45
5.4.260.0170.22067.67
5.4.250.0170.23767.58
5.4.240.0470.19367.54
5.4.230.0430.26767.58
5.4.220.0270.28767.59
5.4.210.0370.26767.55
5.4.200.0230.31367.55
5.4.190.0270.24367.45
5.4.180.0330.28067.49
5.4.170.0170.35067.53
5.4.160.0170.24067.57
5.4.150.0430.24767.33
5.4.140.0330.26064.89
5.4.130.0300.25064.79
5.4.120.0600.29364.80
5.4.110.0300.26064.84
5.4.100.0370.23364.78
5.4.90.0300.24764.94
5.4.80.0230.30064.78
5.4.70.0370.25364.83
5.4.60.0330.22364.80
5.4.50.0330.28364.82
5.4.40.0170.27064.93
5.4.30.0370.24364.80
5.4.20.0370.21064.88
5.4.10.0370.20764.86
5.4.00.0400.24364.47
5.3.290.0270.22063.08
5.3.280.0170.23062.82
5.3.270.0130.27762.98
5.3.260.0130.27362.84
5.3.250.0070.28762.97
5.3.240.0270.28762.90
5.3.230.0330.29363.01
5.3.220.0230.25762.91
5.3.210.0300.22362.89
5.3.200.0630.24062.93
5.3.190.0300.28062.85
5.3.180.0230.28363.02
5.3.170.0330.30762.83
5.3.160.0130.25362.87
5.3.150.0130.32062.80
5.3.140.0370.31062.93
5.3.130.0200.25362.84
5.3.120.0170.26062.78
5.3.110.0230.28362.93
5.3.100.0330.25762.52
5.3.90.0330.27362.29
5.3.80.0130.24362.22
5.3.70.0230.22062.24
5.3.60.0200.25062.17
5.3.50.0470.26762.12
5.3.40.0170.25362.15
5.3.30.0430.23362.17
5.3.20.0270.29062.00
5.3.10.0200.28361.90
5.3.00.0200.25361.85
5.2.170.0030.06311.07
5.2.160.0030.02710.98
5.2.150.0070.05711.18
5.2.140.0130.04311.18
5.2.130.0070.05311.15
5.2.120.0000.05711.10
5.2.110.0070.06011.10
5.2.100.0000.03710.92
5.2.90.0030.03311.11
5.2.80.0030.03011.12
5.2.70.0100.04311.18
5.2.60.0070.06011.12
5.2.50.0130.04310.82
5.2.40.0000.05710.86
5.2.30.0030.06010.99
5.2.20.0070.05011.02
5.2.10.0100.04710.89
5.2.00.0030.06310.59
5.1.60.0030.05010.00
5.1.50.0030.02010.04
5.1.40.0030.05010.02
5.1.30.0000.03710.41
5.1.20.0070.04710.38
5.1.10.0070.05310.14
5.1.00.0130.03710.16
5.0.50.0000.0478.38
5.0.40.0030.0178.42
5.0.30.0030.0378.32
5.0.20.0030.0178.22
5.0.10.0070.0408.13
5.0.00.0030.0608.13
4.4.90.0000.0208.13
4.4.80.0000.0278.13
4.4.70.0000.0408.13
4.4.60.0000.0378.13
4.4.50.0000.0208.13
4.4.40.0000.0538.13
4.4.30.0000.0238.13
4.4.20.0030.0378.13
4.4.10.0030.0338.13
4.4.00.0000.0408.13
4.3.110.0030.0238.13
4.3.100.0030.0338.13
4.3.90.0000.0378.13
4.3.80.0030.0238.13
4.3.70.0000.0308.13
4.3.60.0000.0138.13
4.3.50.0030.0378.13
4.3.40.0100.0378.13
4.3.30.0000.0178.13
4.3.20.0000.0208.13
4.3.10.0030.0338.13
4.3.00.0000.0278.13

preferences:
34 ms | 400 KiB | 5 Q