3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 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);

Abusive script

This script was stopped while abusing our resources

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.00.2131.21822.18
7.3.120.2160.93022.01
7.3.110.2261.29622.16
7.3.100.2231.28022.36
7.3.90.1700.91821.96
7.3.80.1631.27322.23
7.3.70.1631.21822.24
7.3.60.1561.05022.28
7.3.50.1561.23622.16
7.3.40.1790.92722.18
7.3.30.1561.09022.19
7.3.20.0701.19924.36
7.3.10.2400.95724.67
7.3.00.1680.91824.42
7.2.250.2021.40622.07
7.2.240.2130.91422.23
7.2.230.1531.49121.93
7.2.220.1661.39921.89
7.2.210.1861.09921.91
7.2.200.3311.26822.87
7.2.190.1590.99721.91
7.2.180.1101.29022.03
7.2.170.1860.99221.83
7.2.160.2161.41422.09
7.2.150.0681.36524.80
7.2.140.0961.02524.91
7.2.130.2970.92724.88
7.2.120.2091.12824.77
7.2.110.3521.00124.75
7.2.100.2960.83524.79
7.2.90.1570.90524.82
7.2.80.2260.84625.02
7.2.70.2130.91924.88
7.2.60.1720.91924.79
7.2.50.1560.92624.83
7.2.40.2880.86424.77
7.2.30.3000.93324.82
7.2.20.1890.83424.71
7.2.10.2531.01224.67
7.2.00.1200.84425.72
7.1.330.0501.28023.93
7.1.320.0431.54123.46
7.1.310.0531.68523.67
7.1.300.0631.74423.77
7.1.290.0571.72623.84
7.1.280.0531.22923.70
7.1.270.3171.28523.56
7.1.260.0701.67023.80
7.1.250.2081.45523.81
7.1.240.0531.60523.61
7.1.230.0371.43123.66
7.1.220.0471.49623.66
7.1.210.0471.32623.81
7.1.200.0631.36123.77
7.1.190.0431.35423.69
7.1.180.0481.36423.77
7.1.170.0521.26123.86
7.1.160.0651.23723.62
7.1.150.0661.15123.45
7.1.140.0471.36723.86
7.1.130.0431.27123.87
7.1.120.0571.26523.88
7.1.110.0751.21223.95
7.1.100.0471.08923.91
7.1.90.0641.45823.70
7.1.80.0631.44323.98
7.1.70.5510.98124.41
7.1.60.0400.96824.32
7.1.50.0740.88224.48
7.1.40.0431.30623.50
7.1.30.0521.16723.75
7.1.20.0571.21723.76
7.1.10.0301.05923.67
7.1.00.0411.06826.92
7.0.330.0000.83521.14
7.0.320.0100.88721.14
7.0.310.0320.88721.37
7.0.300.0071.29921.41
7.0.290.0151.05621.51
7.0.280.0120.87521.30
7.0.270.0260.95621.35
7.0.260.0070.95321.30
7.0.250.0070.73621.29
7.0.240.0120.82021.06
7.0.230.0060.77221.33
7.0.220.0311.14921.62
7.0.210.0030.77521.37
7.0.200.1060.65722.00
7.0.190.0100.89921.54
7.0.180.0001.12221.39
7.0.170.0100.92621.27
7.0.160.0090.75921.18
7.0.150.0070.76521.38
7.0.140.0150.71024.59
7.0.130.0100.80121.29
7.0.120.0110.76621.59
7.0.110.0100.74421.45
7.0.100.0130.98821.29
7.0.90.0080.74421.14
7.0.80.0080.98621.31
7.0.70.0070.88921.57
7.0.60.0131.14023.14
7.0.50.0060.94622.18
7.0.40.0120.97721.52
7.0.30.0320.98621.39
7.0.20.0231.19121.53
7.0.10.0150.95721.67
7.0.00.0081.14621.66
5.6.400.0172.46728.87
5.6.390.0132.48428.80
5.6.380.0072.07728.48
5.6.370.0142.27028.54
5.6.360.0232.16428.93
5.6.350.0222.36128.90
5.6.340.0191.88528.59
5.6.330.0171.75028.54
5.6.320.0321.31128.80
5.6.310.0081.72928.77
5.6.300.0171.41728.93
5.6.290.0201.54028.37
5.6.280.0171.76331.74
5.6.270.0101.98028.84
5.6.260.0071.71028.48
5.6.250.0151.36728.73
5.6.240.0151.86928.55
5.6.230.0172.09528.71
5.6.220.0212.11728.75
5.6.210.0201.87031.56
5.6.200.0131.72630.41
5.6.190.0231.62131.55
5.6.180.2001.73331.59
5.6.170.0231.78031.60
5.6.160.0181.65031.41
5.6.150.0121.78330.41
5.6.140.0231.64630.42
5.6.130.0111.65430.25
5.6.120.0201.65531.96
5.6.110.0181.76931.73
5.6.100.0271.87231.92
5.6.90.0181.68531.92
5.6.80.0241.82331.63
5.6.70.0072.12528.73
5.6.60.0172.00428.62
5.6.50.0292.07428.58
5.6.40.0302.07228.59
5.6.30.0132.24128.62
5.6.20.0242.14228.50
5.6.10.0191.82528.80
5.6.00.0232.01728.77
5.5.380.0201.91028.83
5.5.370.0272.21128.76
5.5.360.0101.95329.00
5.5.350.0171.71331.61
5.5.340.0161.83030.30
5.5.330.0131.82731.31
5.5.320.0251.82631.48
5.5.310.0251.77231.58
5.5.300.0121.78430.49
5.5.290.0081.62130.29
5.5.280.0151.74731.73
5.5.270.0131.80131.59
5.5.260.0121.77131.73
5.5.250.0161.79331.68
5.5.240.0121.77931.38
5.5.230.0332.09028.84
5.5.220.0132.16528.82
5.5.210.0542.19928.56
5.5.200.0132.17828.62
5.5.190.0102.18328.67
5.5.180.0352.14328.44
5.5.170.0232.19728.66
5.5.160.0332.24528.50
5.5.150.0172.24428.77
5.5.140.0372.16328.48
5.5.130.0142.23528.63
5.5.120.0242.27028.44
5.5.110.0262.19128.63
5.5.100.0232.24828.40
5.5.90.0102.03128.68
5.5.80.0172.23128.22
5.5.70.0372.13328.55
5.5.60.0132.23828.56
5.5.50.0232.18428.10
5.5.40.0112.20528.11
5.5.30.0362.19228.66
5.5.20.0072.20928.55
5.5.10.0172.15428.52
5.5.00.0172.17028.45
5.4.450.0201.88329.32
5.4.440.0211.94629.19
5.4.430.0241.94429.34
5.4.420.1451.98329.43
5.4.410.0211.96029.13
5.4.400.0152.30729.21
5.4.390.2411.88529.24
5.4.380.0331.93429.26
5.4.370.0201.93029.19
5.4.360.0251.95129.21
5.4.350.0231.98429.15
5.4.340.0191.92829.22
5.4.330.0202.41725.32
5.4.320.0162.21026.11
5.4.310.0142.03025.80
5.4.300.0162.03225.96
5.4.290.0202.01925.94
5.4.280.0182.06925.89
5.4.270.0212.06025.86
5.4.260.0262.07326.02
5.4.250.0342.08825.80
5.4.240.0231.94325.98
5.4.230.0081.87829.22
5.4.220.0201.91829.04
5.4.210.0231.93429.00
5.4.200.0271.93329.30
5.4.190.0171.92829.20
5.4.180.0251.89629.07
5.4.170.0162.01229.21
5.4.160.3851.96229.05
5.4.150.0251.94929.18
5.4.140.2231.91428.07
5.4.130.2121.90427.78
5.4.120.0101.95128.02
5.4.110.0151.93627.79
5.4.100.0221.95428.03
5.4.90.0151.94327.77
5.4.80.0181.92827.79
5.4.70.0101.91127.77
5.4.60.0171.90027.84
5.4.50.0201.91527.98
5.4.40.0201.95227.97
5.4.30.0131.91727.98
5.4.20.0241.97527.85
5.4.10.0201.92027.74
5.4.00.2331.91127.57

preferences:
41.55 ms | 400 KiB | 5 Q