3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = range(0,1000); function closest($arr, $x) { $result = "default"; sort($arr); foreach($arr as $value) { if($value < $x) { $result = $value; } else break; } return $result; } echo closest($arr,17)."\n"; echo closest($arr,20)."\n"; echo closest($arr,6);

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.4.20.0060.00917.90
8.4.10.0070.01317.45
8.3.140.0190.00016.57
8.3.130.0070.00318.34
8.3.120.0100.00020.59
8.3.110.0170.00316.50
8.3.100.0080.01124.06
8.3.90.0050.00326.77
8.3.80.0000.01218.43
8.3.70.0090.00918.05
8.3.60.0060.00916.75
8.3.50.0110.00821.87
8.3.40.0090.00618.66
8.3.30.0060.00918.75
8.3.20.0050.00220.30
8.3.10.0040.00421.67
8.3.00.0000.00817.38
8.2.260.0110.00316.70
8.2.250.0080.00016.92
8.2.240.0100.00017.25
8.2.230.0090.00020.94
8.2.220.0060.00337.54
8.2.210.0050.00326.77
8.2.200.0030.00716.38
8.2.190.0070.01416.58
8.2.180.0110.00416.88
8.2.170.0070.01122.96
8.2.160.0130.00722.10
8.2.150.0120.00324.18
8.2.140.0070.00724.66
8.2.130.0060.00326.16
8.2.120.0080.00417.35
8.2.110.0060.00322.25
8.2.100.0090.00318.05
8.2.90.0000.00819.34
8.2.80.0040.00417.97
8.2.70.0060.00317.48
8.2.60.0040.00418.04
8.2.50.0060.00318.07
8.2.40.0060.00319.46
8.2.30.0000.00720.77
8.2.20.0000.00817.61
8.2.10.0080.00018.25
8.2.00.0040.00418.06
8.1.310.0110.00716.55
8.1.300.0030.00618.05
8.1.290.0060.00330.84
8.1.280.0060.01225.92
8.1.270.0040.00423.95
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0030.00623.97
8.1.230.0070.00419.29
8.1.220.0000.00817.91
8.1.210.0050.00318.77
8.1.200.0030.00717.48
8.1.190.0080.00017.23
8.1.180.0030.00618.10
8.1.170.0080.00019.10
8.1.160.0000.00722.08
8.1.150.0080.00018.96
8.1.140.0030.00519.64
8.1.130.0000.00717.80
8.1.120.0000.00717.52
8.1.110.0060.00317.54
8.1.100.0080.00017.46
8.1.90.0000.00717.45
8.1.80.0000.00717.52
8.1.70.0040.00417.45
8.1.60.0040.00417.66
8.1.50.0040.00417.59
8.1.40.0050.00317.48
8.1.30.0000.00917.61
8.1.20.0060.00317.73
8.1.10.0040.00417.52
8.1.00.0030.00617.38
8.0.300.0040.00418.77
8.0.290.0050.00216.88
8.0.280.0030.00318.47
8.0.270.0040.00416.81
8.0.260.0030.00617.21
8.0.250.0050.00317.03
8.0.240.0000.00816.92
8.0.230.0030.00316.88
8.0.220.0000.00716.95
8.0.210.0030.00516.86
8.0.200.0070.00017.05
8.0.190.0040.00417.03
8.0.180.0110.00016.92
8.0.170.0040.00416.90
8.0.160.0040.00416.98
8.0.150.0040.00416.91
8.0.140.0000.00717.01
8.0.130.0030.00313.45
8.0.120.0040.00416.82
8.0.110.0000.00816.99
8.0.100.0040.00417.07
8.0.90.0040.00416.86
8.0.80.0030.01317.01
8.0.70.0050.00317.03
8.0.60.0000.00816.80
8.0.50.0030.00516.79
8.0.30.0120.00717.13
8.0.20.0080.01017.41
8.0.10.0000.00816.97
8.0.00.0100.01116.84
7.4.330.0030.00315.08
7.4.320.0030.00316.43
7.4.300.0080.00016.48
7.4.290.0030.00316.58
7.4.280.0030.00716.57
7.4.270.0030.00316.63
7.4.260.0040.00416.55
7.4.250.0040.00416.48
7.4.240.0050.00216.63
7.4.230.0000.00716.69
7.4.220.0120.00816.50
7.4.210.0080.01016.70
7.4.200.0000.00716.58
7.4.160.0090.00916.50
7.4.150.0140.01017.40
7.4.140.0080.01717.86
7.4.130.0120.00616.55
7.4.120.0130.00416.53
7.4.110.0140.00516.56
7.4.100.0130.00616.38
7.4.90.0150.00716.48
7.4.80.0160.00619.39
7.4.70.0070.01016.49
7.4.60.0180.00316.72
7.4.50.0050.00316.73
7.4.40.0030.02016.59
7.4.30.0120.00616.48
7.4.00.0030.01315.18
7.3.330.0000.00613.24
7.3.320.0080.00013.26
7.3.310.0030.00316.41
7.3.300.0070.00016.43
7.3.290.0050.00216.44
7.3.280.0110.00816.44
7.3.270.0120.00417.40
7.3.260.0120.00616.35
7.3.250.0100.00816.47
7.3.240.0090.00916.51
7.3.230.0170.00016.42
7.3.210.0140.00616.35
7.3.200.0160.00716.72
7.3.190.0030.01416.44
7.3.180.0080.00816.34
7.3.170.0080.00816.61
7.3.160.0060.01516.55
7.3.10.0120.00316.68
7.3.00.0000.01316.62
7.2.330.0140.01016.66
7.2.320.0090.00916.87
7.2.310.0110.01216.65
7.2.300.0140.01116.59
7.2.290.0150.00916.69
7.2.130.0040.00717.00
7.2.120.0070.00716.78
7.2.110.0060.00816.83
7.2.100.0350.00316.67
7.2.90.0090.00716.80
7.2.80.0200.00516.81
7.2.70.0080.01016.92
7.2.60.0060.01117.04
7.2.50.0120.00216.85
7.2.40.0090.00816.96
7.2.30.0100.00416.92
7.2.20.0090.00817.08
7.2.10.0080.00816.93
7.2.00.0110.00816.82
7.1.250.0030.01015.87
7.1.230.0110.00415.68
7.1.220.0100.00715.87
7.1.210.0120.00315.88
7.1.200.0080.00815.89
7.1.190.0050.01015.93
7.1.180.0140.00315.71
7.1.170.0150.01215.93
7.1.160.0090.00915.70
7.1.150.0100.00715.50
7.1.140.0310.00315.85
7.1.130.0130.00515.85
7.1.120.0280.00615.92
7.1.110.0120.00615.60
7.1.100.0100.00716.07
7.1.90.0100.00815.66
7.1.80.0500.00915.81
7.1.70.0110.01116.41
7.1.60.0050.01717.75
7.1.50.0160.00916.49
7.1.40.0040.01615.88
7.1.30.0100.01016.01
7.1.20.0140.00715.89
7.1.10.0140.00015.55
7.1.00.0070.04219.13
7.0.310.0190.00015.56
7.0.300.0120.00815.25
7.0.290.0100.00715.48
7.0.280.0150.01115.07
7.0.270.0190.01015.23
7.0.260.0280.00315.45
7.0.250.0280.00715.63
7.0.240.0070.00715.58
7.0.230.0240.00315.23
7.0.220.0180.00315.48
7.0.210.0160.00315.40
7.0.200.0230.00515.28
7.0.190.0080.00815.33
7.0.180.0090.00915.60
7.0.170.0090.00615.59
7.0.160.0120.00615.59
7.0.150.0110.00415.50
7.0.140.0050.01015.29
7.0.130.0150.00315.27
7.0.120.0320.00315.60
7.0.110.0160.00615.25
7.0.100.0650.00715.20
7.0.90.0120.00215.23
7.0.80.0060.00615.13
7.0.70.0070.01115.43
7.0.60.0110.04117.71
7.0.50.0160.03216.73
7.0.40.0080.03916.85
7.0.30.0130.03216.84
7.0.20.0190.02716.86
7.0.10.0120.04716.93
7.0.00.0140.03816.89
5.6.380.0110.00814.26
5.6.370.0130.00714.37
5.6.360.0070.01114.29
5.6.350.0110.00314.60
5.6.340.0130.01014.72
5.6.330.0120.00714.38
5.6.320.0060.00614.10
5.6.310.0100.00814.54
5.6.300.0060.01214.21
5.6.290.0100.00714.32
5.6.280.0050.02117.62
5.6.270.0100.00314.45
5.6.260.0120.00814.59
5.6.250.0160.00414.34
5.6.240.0060.01214.54
5.6.230.0110.00714.71
5.6.220.0140.00614.40
5.6.210.0170.03317.54
5.6.200.0060.02516.41
5.6.190.0110.02517.58
5.6.180.2080.02017.51
5.6.170.0180.02517.32
5.6.160.0050.04617.53
5.6.150.0120.03716.24
5.6.140.0140.02016.26
5.6.130.0160.03816.23
5.6.120.0120.04317.87
5.6.110.0090.04617.60
5.6.100.0140.03017.82
5.6.90.0120.03917.78
5.6.80.0090.04417.41
5.6.70.0110.00714.25
5.6.60.0130.00314.13
5.6.50.0030.01014.40
5.6.40.0110.00714.27
5.6.30.0050.01014.04
5.6.20.0120.00314.19
5.6.10.0140.00314.38
5.6.00.0040.01114.30
5.5.380.0040.00812.79
5.5.370.0050.00512.79
5.5.360.0080.00412.79
5.5.350.2050.02316.56
5.5.340.0050.02815.43
5.5.330.0040.03016.49
5.5.320.0180.04116.49
5.5.310.0140.03316.57
5.5.300.0080.02015.38
5.5.290.0100.04215.39
5.5.280.0110.03616.85
5.5.270.0020.03616.73
5.5.260.0090.02216.73
5.5.250.0050.02516.76
5.5.240.0020.04116.50
5.5.230.0040.01112.79
5.5.220.0070.00712.79
5.5.210.0070.00412.79
5.5.200.0060.00612.79
5.5.190.0110.00012.79
5.5.180.0100.00712.79
5.5.170.0130.00314.15
5.5.160.0070.00712.79
5.5.150.0080.00312.79
5.5.140.0080.00512.79
5.5.130.0050.00912.79
5.5.120.0090.00212.79
5.5.110.0070.00612.79
5.5.100.0140.00412.79
5.5.90.0060.00612.79
5.5.80.0080.00512.79
5.5.70.0090.00612.79
5.5.60.0070.01112.79
5.5.50.0110.00312.79
5.5.40.0080.00412.79
5.5.30.0100.00312.79
5.5.20.0030.01012.79
5.5.10.0060.00812.79
5.5.00.0120.00012.79
5.4.450.0210.02916.05
5.4.440.0280.03116.21
5.4.430.0310.02016.19
5.4.420.0380.01816.05
5.4.410.0280.03016.09
5.4.400.0320.03715.83
5.4.390.0310.03015.96
5.4.380.0290.02915.83
5.4.370.0320.02315.89
5.4.360.0330.03415.97
5.4.350.0250.03016.05
5.4.340.0280.03215.96
5.4.330.0080.00512.79
5.4.320.0240.02415.82
5.4.310.0290.03615.96
5.4.300.0300.03716.00
5.4.290.0290.02315.88
5.4.280.0300.03015.83
5.4.270.0320.03516.02
5.4.260.0320.02815.92
5.4.250.0310.01915.87
5.4.240.0290.02715.92
5.4.230.0340.03315.83
5.4.220.0270.04016.02
5.4.210.0310.03216.03
5.4.200.0250.02215.94
5.4.190.0220.02316.00
5.4.180.0220.02616.00
5.4.170.0290.01915.88
5.4.160.0320.02015.82
5.4.150.0240.02415.88
5.4.140.0290.03914.68
5.4.130.0270.03014.75
5.4.120.0250.02014.65
5.4.110.0320.01614.64
5.4.100.0270.02014.78
5.4.90.0280.01914.71
5.4.80.0050.00812.79
5.4.70.0090.00612.79
5.4.60.0090.00612.79
5.4.50.0090.00312.79
5.4.40.0070.01012.79
5.4.30.0100.00712.79
5.4.20.0080.00812.79
5.4.10.0000.00912.79
5.4.00.0100.00312.79

preferences:
33.54 ms | 403 KiB | 5 Q