3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getBigArray($n){ $arr = []; for ($i=0; $i<$n; $i++) { $arr[] = $i; } return $arr; } function testSpeed1($n){ $array1 = getBigArray($n); $array2 = getBigArray($n); $new = []; $start = microtime(true); testArrayManipulation1($array1, $array2); $new[] = $array1; $end = microtime(true); return $end-$start; } function testSpeed2($n){ $array1 = getBigArray($n); $array2 = getBigArray($n); $new = []; $start = microtime(true); $new[] = testArrayManipulation2($array1, $array2); $end = microtime(true); return $end-$start; } function testSpeed3($n){ $array1 = getBigArray($n); $array2 = getBigArray($n); $new = []; $start = microtime(true); $new[] = testArrayManipulation3($array1, $array2); $end = microtime(true); return $end-$start; } function testArrayManipulation1(&$array1, $array2){ foreach($array2 as $v){ $array1[] = $v; } } function testArrayManipulation2(&$array1, $array2){ foreach($array2 as $v){ $array1[] = $v; } return $array1; } function testArrayManipulation3($array1, $array2){ foreach($array2 as $v){ $array1[] = $v; } return $array1; } $n = 10; $test1 = []; $test2 = []; $test3 = []; for ($i=0; $i<$n; $i++) { $length = 100000; $test1[] = testSpeed1($length); $test2[] = testSpeed2($length); $test3[] = testSpeed3($length); } echo array_sum($test1)/count($test1); echo '<br>'; echo array_sum($test2)/count($test2); echo '<br>'; echo array_sum($test3)/count($test3);

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.4.110.3600.41531.42
7.4.100.3850.39531.55
7.4.90.4000.38731.58
7.4.80.3150.43431.52
7.4.70.5320.48231.33
7.4.60.4820.50131.57
7.4.50.3630.45231.50
7.4.40.3700.41331.59
7.4.30.3150.44131.51
7.4.20.3790.39631.54
7.4.10.4520.48831.52
7.4.00.4040.38831.47
7.3.230.4180.37931.34
7.3.220.4160.36631.29
7.3.210.3620.44131.25
7.3.200.3590.38530.99
7.3.190.4060.46531.46
7.3.180.4260.42331.05
7.3.170.4040.39231.22
7.3.160.3600.44431.19
7.3.150.3650.44631.15
7.3.140.3480.42831.17
7.3.130.3610.37831.25
7.3.120.3620.40631.29
7.3.110.3730.41031.15
7.3.100.4100.37631.41
7.3.90.3450.42231.24
7.3.80.3300.43231.15
7.3.70.3430.41231.18
7.3.60.3740.39231.36
7.3.50.3360.41431.34
7.3.40.3450.41231.21
7.3.30.3860.37331.18
7.3.20.4630.41831.20
7.3.10.4810.38831.29
7.3.00.5930.38331.21
7.2.340.3860.42331.44
7.2.330.3670.46431.50
7.2.320.4070.45731.58
7.2.310.3650.49731.35
7.2.300.3610.49031.52
7.2.290.3650.42231.41
7.2.280.3740.40931.66
7.2.270.3380.50031.53
7.2.260.3730.53631.61
7.2.250.4410.52431.73
7.2.240.3570.47031.50
7.2.230.3640.44431.27
7.2.220.3920.43931.62
7.2.210.3670.43731.37
7.2.200.4090.45031.58
7.2.190.3360.46931.47
7.2.180.3780.43831.62
7.2.170.3170.53131.23
7.2.160.3890.37931.50
7.2.150.5900.43731.58
7.2.140.4910.44531.40
7.2.130.4390.46231.47
7.2.120.5370.51031.34
7.2.110.5040.43731.62
7.2.100.5930.45631.59
7.2.90.5780.47931.41
7.2.80.4750.48531.61
7.2.70.5370.44831.55
7.2.60.5050.46031.54
7.2.50.5830.38831.57
7.2.40.6240.48931.35
7.2.30.4660.44531.60
7.2.20.5290.45531.45
7.2.10.4580.44831.63
7.2.00.4570.44331.55

preferences:
43.07 ms | 403 KiB | 5 Q