3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL & ~E_NOTICE); ini_set('display_errors', '1'); define('S', 15000); // list Size define('N', 10); // Number of iterations (for benchmark accuracy) // Comment the lines above and uncomment the lines below to pass the parameters in the command line //define('S', (int)$argv[1]); //define('N', (int)$argv[2]); printf("Generating %d elements... ", S); $tsStart = microtime(TRUE); $array = []; for ($i = 0; $i < S; $i ++) { $array[] = [ 'a' => rand(0, 100), 'f' => 0, 'f' => 0, 'l' => 61.60 ]; } printf("Done. Time: %f seconds.\n", microtime(TRUE) - $tsStart); $time = 0; for ($l = 0; $l < N; $l ++) { $ts = microtime(TRUE); $min = min(array_filter(array_column($array, 'a'))); $time += microtime(TRUE) - $ts; } printf("array_filter(): %9.2f seconds/%d iterations. %f seconds/iteration.\n", $time, N, $time/N); $time = 0; for ($l = 0; $l < N; $l ++) { $ts = microtime(TRUE); $min = null; foreach ($array as $val) { if ($min === null || ($val['a'] && $val['a'] < $min)) { $min = $val['a']; } } $time += microtime(TRUE) - $ts; } printf("foreach : %9.2f seconds/%d iterations. %f seconds/iteration.\n", $time, N, $time/N); $time = 0; for ($l = 0; $l < N; $l ++) { $ts = microtime(TRUE); $min = array_reduce($array, function ($min, $val) { return $min === null || ($val['a'] && $val['a'] < $min) ? $val['a'] : $min; }); $time += microtime(TRUE) - $ts; } printf("reduce @deceze: %9.2f seconds/%d iterations. %f seconds/iteration.\n", $time, N, $time/N); $time = 0; for ($l = 0; $l < N; $l ++) { $ts = microtime(TRUE); $min = array_reduce( $array, function($acc, array $item) { return min($acc, $item['a'] ?: INF); }, INF ); $time += microtime(TRUE) - $ts; } printf("reduce @axiac : %9.2f seconds/%d iterations. %f seconds/iteration.\n", $time, N, $time/N);

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)
8.3.60.0550.05525.92
8.3.50.0320.04725.92
8.3.40.0330.04325.92
8.3.30.0410.05425.92
8.3.20.0360.05325.92
8.3.10.0300.05625.92
8.3.00.0440.05125.92
8.2.180.0300.06525.92
8.2.170.0430.05125.92
8.2.160.0420.05625.92
8.2.150.0350.04925.92
8.2.140.0370.04425.92
8.2.130.0420.04225.92
8.2.120.0400.05125.92
8.2.110.0470.05925.92
8.2.100.0400.04825.92
8.2.90.0440.05125.92
8.2.80.0480.05325.92
8.2.70.0380.05825.92
8.2.60.0380.04925.92
8.2.50.0360.04225.92
8.2.40.0320.06025.92
8.2.30.0380.05025.92
8.2.20.0320.05725.92
8.2.10.0350.05725.92
8.2.00.0430.06025.92
8.1.280.0390.05825.92
8.1.270.0450.04525.92
8.1.260.0380.04625.92
8.1.250.0330.04625.92
8.1.240.0410.04425.92
8.1.230.0430.05225.92
8.1.220.0370.05225.92
8.1.210.0390.04725.92
8.1.200.0220.05525.92
8.1.190.0400.05025.92
8.1.180.0380.05125.92
8.1.170.0380.04125.92
8.1.160.0340.05125.92
8.1.150.0270.05025.92
8.1.140.0410.04225.92
8.1.130.0390.05625.92
8.1.120.0280.04625.92
8.1.110.0420.05425.92
8.1.100.0400.06025.92
8.1.90.0310.04825.92
8.1.80.0350.06125.92
8.1.70.0450.04925.92
8.1.60.0400.05525.92
8.1.50.0250.05225.92
8.1.40.0440.04425.92
8.1.30.0250.05225.92
8.1.20.0430.04925.92
8.1.10.0440.04225.92
8.1.00.0350.05325.92
8.0.300.0320.05025.92
8.0.290.0250.04925.92
8.0.280.0320.05025.92
8.0.270.0340.04225.92
8.0.260.0310.05925.92
8.0.250.0400.04525.92
8.0.240.0310.05325.92
8.0.230.0390.05125.92
8.0.220.0400.05525.92
8.0.210.0410.05725.92
8.0.200.0400.05325.92
8.0.190.0380.05725.92
8.0.180.0320.05625.92
8.0.170.0350.05625.92
8.0.160.0390.05425.92
8.0.150.0390.05125.92
8.0.140.0420.04825.92
8.0.130.0410.05225.92
8.0.120.0300.04925.92
8.0.110.0370.05125.92
8.0.100.0310.05125.92
8.0.90.0350.05225.92
8.0.80.0270.06025.92
8.0.70.0430.05025.92
8.0.60.0350.05325.92
8.0.50.0300.05525.92
8.0.30.0330.05725.21
8.0.20.0390.06425.21
8.0.10.0400.05325.24
8.0.00.0360.06225.18
7.4.330.0320.05225.92
7.4.320.0270.05925.92
7.4.300.0330.05525.92
7.4.290.0420.06425.92
7.4.280.0350.06625.92
7.4.270.0330.04925.92
7.4.260.0270.05025.92
7.4.250.0380.05225.92
7.4.240.0330.06025.92
7.4.230.0370.04825.92
7.4.220.0250.04925.92
7.4.210.0400.05025.92
7.4.200.0290.05425.92
7.4.190.0370.06025.92
7.4.180.0310.06925.92
7.4.160.0400.06025.10
7.4.150.0360.05725.06
7.4.140.0250.05625.08
7.4.130.0350.06025.02
7.4.120.0330.05425.03
7.4.110.0280.05625.06
7.4.100.0270.05625.07
7.4.90.0370.06625.01
7.4.80.0310.05825.02
7.4.70.0290.05225.03
7.4.60.0310.06525.02
7.4.50.0330.07624.94
7.4.40.0370.06024.99
7.4.30.0380.05825.06
7.4.20.0300.06024.99
7.4.10.0300.07725.05
7.4.00.0330.06625.05
7.3.330.0320.04325.92
7.3.320.0350.05425.92
7.3.310.0400.05325.92
7.3.300.0290.05125.92
7.3.290.0360.06325.92
7.3.280.0220.06725.01
7.3.270.0310.05424.97
7.3.260.0340.05224.98
7.3.250.0340.07424.98
7.3.240.0260.06725.00
7.3.230.0320.06124.99
7.3.220.0380.05824.98
7.3.210.0280.05824.96
7.3.200.0330.05824.98
7.3.190.0330.05824.94
7.3.180.0310.05724.97
7.3.170.0380.07224.98
7.3.160.0360.07424.97
7.3.150.0360.06524.95
7.3.140.0330.08424.98
7.3.130.0430.07824.96
7.3.120.0310.06324.97
7.3.110.0350.06724.96
7.3.100.0310.06924.96
7.3.90.0290.07125.04
7.3.80.0310.06024.98
7.3.70.0250.06125.03
7.3.60.0230.06425.03
7.3.50.0360.06125.00
7.3.40.0260.07025.00
7.3.30.0330.05525.00
7.3.20.0310.06525.04
7.3.10.0270.06424.40
7.3.00.0220.05624.44
7.2.340.0310.09325.11
7.2.330.0240.07925.10
7.2.320.0270.08425.12
7.2.310.0290.08225.09
7.2.300.0330.08525.10
7.2.290.0270.08925.09
7.2.280.0280.08525.12
7.2.270.0330.07825.11
7.2.260.0270.08025.11
7.2.250.0230.10225.10
7.2.240.0380.10825.07
7.2.230.0390.10225.11
7.2.220.0340.10825.11
7.2.210.0320.07625.12
7.2.200.0300.08225.15
7.2.190.0390.08125.13
7.2.180.0330.09425.14
7.2.170.0390.09025.17
7.2.160.0360.09325.16
7.2.150.0440.09925.18
7.2.140.0310.08925.19
7.2.130.0350.08324.69
7.2.120.0210.08824.71
7.2.110.0320.09124.74
7.2.100.0210.08824.71
7.2.90.0240.07224.71
7.2.80.0250.07824.73
7.2.70.0350.08024.70
7.2.60.0280.09024.67
7.2.50.0280.07624.68
7.2.40.0300.08824.63
7.2.30.0240.08124.66
7.2.20.0210.08424.69
7.2.10.0310.08324.55
7.2.00.0220.08324.64
7.1.330.0310.10924.78
7.1.320.0360.10924.76
7.1.310.0310.09324.76
7.1.300.0420.10724.76
7.1.290.0300.09124.72
7.1.280.0260.09224.77
7.1.270.0330.09124.77
7.1.260.0280.09624.75
7.1.250.0260.10024.06
7.1.240.0310.08224.69
7.1.230.0270.10224.76
7.1.220.0300.09224.74
7.1.210.0370.08624.76
7.1.200.0220.10124.74
7.1.190.0240.07724.79
7.1.180.0310.09024.75
7.1.170.0220.09924.74
7.1.160.0310.09924.74
7.1.150.0290.08624.77
7.1.140.0260.08824.72
7.1.130.0310.10224.75
7.1.120.0330.09524.74
7.1.110.0280.10224.74
7.1.100.0260.08924.71
7.1.90.0270.08624.75
7.1.80.0260.09124.74
7.1.70.1160.08924.18
7.1.60.1260.10628.80
7.1.50.0950.09728.71
7.1.40.1110.09628.63
7.1.30.1460.09928.64
7.1.20.0990.10228.70
7.1.10.0910.09524.04
7.1.00.1170.10124.02
7.0.330.0300.11924.69
7.0.320.0350.08124.65
7.0.310.0270.08824.67
7.0.300.0280.10124.68
7.0.290.0240.08924.64
7.0.280.0320.09024.65
7.0.270.0230.09324.61
7.0.260.0350.08024.65
7.0.250.0270.11524.71
7.0.240.0250.10024.73
7.0.230.0310.10024.66
7.0.220.0310.09924.65
7.0.210.0280.09324.68
7.0.200.0950.11224.09
7.0.190.0970.10524.09
7.0.180.1060.09923.96
7.0.170.1110.09824.01
7.0.160.1070.09324.01
7.0.150.0970.09324.00
7.0.140.1150.09623.96
7.0.130.0940.09024.08
7.0.120.1160.09924.09
7.0.110.1220.10123.97
7.0.100.1030.10423.98
7.0.90.1000.09523.99
7.0.80.0250.09223.99
7.0.70.0320.09224.02
7.0.60.1470.12423.97
7.0.50.1000.10723.97
7.0.40.1230.10724.06
7.0.30.1240.11124.08
7.0.20.1130.11523.99
7.0.10.1070.11923.99
7.0.00.0990.10624.02
5.6.400.0500.31628.90
5.6.390.0470.33128.95
5.6.380.0520.28928.91
5.6.370.0550.30928.95
5.6.360.0530.30228.84
5.6.350.0480.29329.01
5.6.340.0520.29728.96
5.6.330.0450.28229.03
5.6.320.0580.28728.81
5.6.310.0480.30629.02
5.6.300.0340.29728.72
5.6.290.0410.28728.97
5.6.280.0450.29628.95
5.6.270.0560.31228.96
5.6.260.0600.29928.98
5.6.250.0440.29929.00
5.6.240.0500.27429.01
5.6.230.0570.28229.13
5.6.220.0600.26828.99
5.6.210.0350.29329.24
5.6.200.0400.27529.24
5.6.190.0530.31829.14
5.6.180.0450.29229.17
5.6.170.0510.27629.21
5.6.160.0490.28129.18
5.6.150.0630.27129.08
5.6.140.0620.27729.09
5.6.130.0590.32929.10
5.6.120.0510.28929.24
5.6.110.0570.29029.06
5.6.100.0520.26629.04
5.6.90.0590.28528.92
5.6.80.0620.30528.74
5.6.70.0580.31128.99
5.6.60.0600.31128.97
5.6.50.0510.29928.86
5.6.40.0540.27628.99
5.6.30.0460.28629.04
5.6.20.0480.29428.76
5.6.10.0490.30228.93
5.6.00.0570.30228.94

preferences:
80.61 ms | 403 KiB | 5 Q