3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Test results $array1 = test('array_walk'); $array2 = test('array_walk_list_each'); $array3 = test('array_walk_foreach1'); $array4 = test('array_walk_foreach2'); // Check arrays for equal var_dump($array1 == $array2, $array1 == $array3, $array1 == $array4); // Test function 1 function array_walk_list_each(&$array, $function, $userData = null) { while ( list($key, $value) = each($array) ) $function($array[$key], $key, $userData); } // Test function 2 function array_walk_foreach1(&$array, $function, $userData = null) { foreach ($array as $key => &$value ) $function($value, $key, $userData); } // Test function 3 function array_walk_foreach2(&$array, $function, $userData = null) { foreach ($array as $key => $value ) $function($array[$key], $key, $userData); } function some_function(&$value, $key, $userData) { $value = "$key => $userData"; } function test($function, $count = 10000, $arrayElements = 1000) { echo $function, ' ... '; $array = array_fill(0, $arrayElements, "some text value"); $timer = microtime(true); for( $i = 0; ++$i < $count; ) $function($array, 'some_function', 'some user data'); printf("%.3f sec\n", microtime(true) - $timer); return $array; }

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.0072.49419.51
7.1.70.0002.50117.17
7.1.60.0132.48819.46
7.1.50.0072.49516.84
7.1.00.0132.48722.18
7.0.200.0032.49816.91
7.0.140.0032.49722.11
7.0.60.0072.49320.38
7.0.50.0032.49718.27
7.0.40.0072.49319.71
7.0.30.0202.48019.95
7.0.20.0272.47319.91
7.0.10.0072.49319.72
7.0.00.0102.49019.87
5.6.280.0132.48720.98
5.6.210.0172.48320.84
5.6.200.0002.50018.29
5.6.190.0002.50020.55
5.6.180.0532.44720.58
5.6.170.0272.47320.58
5.6.160.0002.50020.42
5.6.150.0002.50018.18
5.6.140.0072.49318.27
5.6.130.0072.49318.41
5.6.120.0102.46721.11
5.6.110.0172.48321.32
5.6.100.0102.49021.15
5.6.90.0132.48721.07
5.6.80.0072.49320.57
5.5.350.0172.48320.57
5.5.340.0002.50018.14
5.5.330.0072.49320.38
5.5.320.0302.47020.42
5.5.310.0302.47020.30
5.5.300.0072.49318.13
5.5.290.0002.50018.05
5.5.280.0032.49721.07
5.5.270.0172.48320.97
5.5.260.0072.49321.08
5.5.250.0102.49020.98
5.5.240.0172.48320.53
5.4.450.0230.90719.54
5.4.440.0272.22319.54
5.4.430.0431.58719.57
5.4.420.0171.51019.75
5.4.410.1101.38019.27
5.4.400.1902.06019.20
5.4.390.0231.92319.25
5.4.380.0402.45318.64
5.4.370.0372.46018.68
5.4.360.0432.43318.74
5.4.350.0402.43018.67
5.4.340.0302.45018.90
5.4.320.0081.99912.69
5.4.310.0211.98212.69
5.4.300.0091.99312.69
5.4.290.0091.99312.68
5.4.280.0091.99712.58
5.4.270.0121.99312.58
5.4.260.0041.99912.58
5.4.250.0091.99512.59
5.4.240.0161.98412.58
5.4.230.0151.98812.57
5.4.220.0031.99812.57
5.4.210.0161.99512.58
5.4.200.0182.01412.57
5.4.190.0161.98812.57
5.4.180.0081.99712.57
5.4.170.0101.99512.58
5.4.160.0181.98312.57
5.4.150.0091.99612.57
5.4.140.0141.98912.25
5.4.130.0071.99812.24
5.4.120.0101.99212.20
5.4.110.0121.99212.20
5.4.100.0091.99412.20
5.4.90.0091.99412.20
5.4.80.0121.98912.20
5.4.70.0161.98612.19
5.4.60.0081.99512.19
5.4.50.0091.99312.20
5.4.40.0111.99212.18
5.4.30.0151.98612.18
5.4.20.0121.99012.18
5.4.10.0091.99312.18
5.4.00.0102.00311.66
5.3.290.0111.99112.89
5.3.280.0141.99012.82
5.3.270.0081.99312.83
5.3.260.0131.99112.83
5.3.250.0141.99512.83
5.3.240.0141.99212.83
5.3.230.0121.99112.83
5.3.220.0141.98612.79
5.3.210.0091.99512.79
5.3.200.0121.99312.79
5.3.190.0141.98912.80
5.3.180.0081.99412.79
5.3.170.0081.99312.79
5.3.160.0101.99112.79
5.3.150.0131.98812.79
5.3.140.0101.99212.78
5.3.130.0121.99012.77
5.3.120.0081.99712.77
5.3.110.0121.99112.78
5.3.100.0091.99312.26
5.3.90.0061.99512.24
5.3.80.0111.99112.23
5.3.70.0071.99512.23
5.3.60.0121.99012.21
5.3.50.0111.99012.16
5.3.40.0111.99012.16
5.3.30.0081.99212.13
5.3.20.0111.99111.90
5.3.10.0111.99111.87
5.3.00.0081.99411.86
5.2.170.0061.9959.34
5.2.160.0061.9949.34
5.2.150.0061.9959.34
5.2.140.0061.9949.34
5.2.130.0081.9939.30
5.2.120.0071.9959.30
5.2.110.0101.9919.30
5.2.100.0061.9959.30
5.2.90.0061.9969.30
5.2.80.0141.9919.29
5.2.70.0081.9949.29
5.2.60.0111.9919.25
5.2.50.0081.9949.21
5.2.40.0141.9889.19
5.2.30.0031.9979.17
5.2.20.0091.9999.16
5.2.10.0091.9929.07
5.2.00.0061.9968.93
5.1.60.0071.9948.29
5.1.50.0051.9968.29
5.1.40.0051.9958.27
5.1.30.0081.9948.62
5.1.20.0101.9928.64
5.1.10.0121.9888.37
5.1.00.0071.9948.37
5.0.50.0041.9986.86
5.0.40.0081.9956.71
5.0.30.0091.9926.53
5.0.20.0071.9956.50
5.0.10.0061.9946.47
5.0.00.0071.9956.46
4.4.90.0040.0144.77
4.4.80.0040.0144.76
4.4.70.0040.0144.75
4.4.60.0020.0164.75
4.4.50.0020.0154.77
4.4.40.0030.0244.71
4.4.30.0020.0164.76
4.4.20.0020.0164.84
4.4.10.0020.0204.85
4.4.00.0000.0314.76
4.3.110.0030.0154.67
4.3.100.0030.0154.66
4.3.90.0000.0174.63
4.3.80.0040.0234.58
4.3.70.0020.0154.63
4.3.60.0030.0144.63
4.3.50.0020.0164.63
4.3.40.0040.0224.54
4.3.30.0030.0153.32
4.3.20.0010.0163.29
4.3.10.0020.0193.25
4.3.00.0000.02014.87

preferences:
41.19 ms | 401 KiB | 5 Q