3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo '<pre>'; // Setup input array $input = []; for ($i = 0; $i < 100000; $i++) { $input[] = rand(~PHP_INT_MAX, PHP_INT_MAX); } $foreach_if_times = []; $array_filter_times = []; for ($i = 0; $i < 100; $i++) { $start = microtime(true); array_filter($input, function ($item) { return ($item > 0); }); $array_filter_times[] = microtime(true) - $start; } for ($i = 0; $i < 100; $i++) { $start = microtime(true); $result = []; foreach ($input as $item) { if ($item > 0) { $result[] = $item; } } $foreach_if_times[] = microtime(true) - $start; } echo sprintf("Avg time: %.8f\n", $array_filter_avg = array_sum($array_filter_times) / count($array_filter_times)); echo sprintf("Avg time: %.8f\n", $foreach_if_avg = array_sum($foreach_if_times) / count($foreach_if_times)); echo sprintf("Difference: %.8f\nRatio: %.8f\n", $array_filter_avg - $foreach_if_avg, $array_filter_avg / $foreach_if_avg);

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.0400.81827.59
7.1.70.2900.81624.79
7.1.60.0330.77325.16
7.1.50.5590.73224.97
7.1.00.0230.81330.34
7.0.200.0030.59122.82
7.0.140.0070.83728.11
7.0.60.0130.74024.90
7.0.50.0030.65022.72
7.0.40.0100.74323.73
7.0.30.0470.73323.66
7.0.20.0370.71723.55
7.0.10.0070.71723.67
7.0.00.0030.74323.70
5.6.280.0031.54735.13
5.6.210.0201.52034.69
5.6.200.0071.56332.16
5.6.190.0171.58334.53
5.6.180.0371.56334.33
5.6.170.0371.51334.40
5.6.160.0101.58734.43
5.6.150.0131.47332.26
5.6.140.0101.58032.25
5.6.130.0131.57732.15
5.6.120.0071.58035.01
5.6.110.0271.60034.92
5.6.100.0071.51035.04
5.6.90.0071.73035.00
5.6.80.0071.64334.46
5.5.350.0301.29734.48
5.5.340.0071.47032.07
5.5.330.0331.46334.20
5.5.320.0131.38734.23
5.5.310.0371.41034.27
5.5.300.0231.47031.98
5.5.290.0031.38331.96
5.5.280.0101.73034.91
5.5.270.0131.37034.99
5.5.260.0001.43735.00
5.5.250.0071.41734.53
5.5.240.0131.55734.21
5.4.450.0331.49333.52
5.4.440.0301.48033.24
5.4.430.3901.67333.17
5.4.420.0401.49333.15
5.4.410.0271.73733.16
5.4.400.0401.43332.94
5.4.390.0331.52332.92
5.4.380.3931.51332.83
5.4.370.0231.41732.85
5.4.360.0131.45732.92
5.4.350.0201.93033.08
5.4.340.0271.48333.28
5.4.320.0231.44032.96
5.4.310.0401.40733.29
5.4.300.0301.53032.91
5.4.290.0301.98332.98
5.4.280.0201.38332.91
5.4.270.0331.36333.06
5.4.260.0371.43033.09
5.4.250.0331.47733.20
5.4.240.0271.47332.84
5.4.230.0231.46732.97
5.4.220.0271.42033.18
5.4.210.0331.48032.85
5.4.200.0301.42332.96
5.4.190.0131.43333.00
5.4.180.0271.51032.91
5.4.170.0331.42732.84
5.4.160.0302.11333.07
5.4.150.0201.50032.94
5.4.140.0301.48330.38
5.4.130.0171.93330.29
5.4.120.0231.47030.33
5.4.110.0201.42330.57
5.4.100.0271.45030.46
5.4.90.0271.48330.46
5.4.80.0271.48730.29
5.4.70.0231.49330.44
5.4.60.0371.40730.44
5.4.50.0231.35730.55
5.4.40.0301.43030.40
5.4.30.3831.46330.17
5.4.20.0301.46030.38
5.4.10.0331.46330.43
5.4.00.0471.44729.82
5.3.290.0330.07314.60
5.3.280.0230.04714.57
5.3.270.0200.05014.54
5.3.260.0370.06314.45
5.3.250.0270.06714.46
5.3.240.0170.04314.59
5.3.230.0270.04014.58
5.3.220.0200.06714.47
5.3.210.0230.03714.56
5.3.200.0170.07714.60
5.3.190.0270.07314.48
5.3.180.0230.04014.38
5.3.170.0170.03714.61
5.3.160.0230.04314.51
5.3.150.0370.05714.41
5.3.140.0270.06314.49
5.3.130.0300.07314.39
5.3.120.0300.04714.39
5.3.110.0300.05714.39
5.3.100.0170.05714.07
5.3.90.0270.06714.07
5.3.80.0270.05313.89
5.3.70.0230.05313.87
5.3.60.0200.05314.04
5.3.50.0370.05313.80
5.3.40.0270.07313.82
5.3.30.0370.06713.74
5.3.20.0430.05713.48
5.3.10.0330.06013.50
5.3.00.0270.05013.51
5.2.170.0270.04713.45
5.2.160.0200.06013.45
5.2.150.0330.04313.45
5.2.140.0230.05013.45
5.2.130.0200.05313.45
5.2.120.0200.06313.45
5.2.110.0400.02313.45
5.2.100.0170.03313.45
5.2.90.0300.05313.45
5.2.80.0200.06013.45
5.2.70.0270.05713.45
5.2.60.0230.05013.45
5.2.50.0200.06313.45
5.2.40.0200.04713.45
5.2.30.0200.03713.45
5.2.20.0170.03013.45
5.2.10.0200.04313.45
5.2.00.0170.05313.45
5.1.60.0170.04313.45
5.1.50.0200.03313.45
5.1.40.0270.04313.45
5.1.30.0170.03013.45
5.1.20.0200.02013.45
5.1.10.0230.04713.45
5.1.00.0230.03313.45
5.0.50.0130.04313.45
5.0.40.0130.03713.45
5.0.30.0130.05713.45
5.0.20.0070.02713.45
5.0.10.0130.02713.45
5.0.00.0070.04713.45
4.4.90.0130.03313.45
4.4.80.0100.03713.45
4.4.70.0070.01713.45
4.4.60.0100.01313.45
4.4.50.0100.01313.45
4.4.40.0170.05313.45
4.4.30.0100.03713.45
4.4.20.0130.03313.45
4.4.10.0070.03013.45
4.4.00.0100.05713.45
4.3.110.0070.03313.45
4.3.100.0100.01713.45
4.3.90.0030.02013.45
4.3.80.0070.02713.45
4.3.70.0070.03713.45
4.3.60.0100.03013.45
4.3.50.0100.02013.45
4.3.40.0130.03013.45
4.3.30.0070.02313.45
4.3.20.0030.02313.45
4.3.10.0070.03313.45
4.3.00.0070.03313.45

preferences:
31.51 ms | 401 KiB | 5 Q