3v4l.org

run code in 300+ PHP versions simultaneously
<?php function add($overflowsTimes, $augend, $addend){ $sum = $augend + $addend; if(is_float($sum)){ $sum = $addend - (PHP_INT_MAX - $augend); $overflowsTimes++; }elseif($sum < 0){ $sum = PHP_INT_MAX + $sum; $overflowsTimes--; } if($overflowsTimes < 0){ throw new Error(); } return [ $overflowsTimes, $sum ]; } assert(add(0, 0, 0) === [0, 0]); assert(add(0, 100, 200) === [0, 300]); assert(add(0, PHP_INT_MAX - 100, 100) === [0, PHP_INT_MAX]); assert(add(0, PHP_INT_MAX, 100) === [1, 100]); assert(add(0, PHP_INT_MAX, 1000) === [1, 1000]); assert(add(0, PHP_INT_MAX, PHP_INT_MAX) === [1, PHP_INT_MAX]); assert(add(1, 0, 0) === [1, 0]); assert(add(1, 100, 200) === [1, 300]); assert(add(1, PHP_INT_MAX - 100, 100) === [1, PHP_INT_MAX]); assert(add(1, PHP_INT_MAX, 100) === [2, 100]); assert(add(1, PHP_INT_MAX, 1000) === [2, 1000]); assert(add(1, PHP_INT_MAX, PHP_INT_MAX) === [2, PHP_INT_MAX]); assert(add(2, 0, 0) === [2, 0]); assert(add(2, 100, 200) === [2, 300]); assert(add(2, PHP_INT_MAX - 100, 100) === [2, PHP_INT_MAX]); assert(add(2, PHP_INT_MAX, 100) === [3, 100]); assert(add(2, PHP_INT_MAX, 1000) === [3, 1000]); assert(add(2, PHP_INT_MAX, PHP_INT_MAX) === [3, PHP_INT_MAX]); try{ add(0, PHP_INT_MAX, PHP_INT_MIN); }catch(Throwable $e){} print_r(add(1, PHP_INT_MAX, PHP_INT_MIN));

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.70.0100.00618.56
8.3.60.0110.00318.56
8.3.50.0150.00721.15
8.3.40.0040.01219.02
8.3.30.0090.00618.86
8.3.20.0080.00019.02
8.3.10.0000.00821.99
8.3.00.0030.00520.84
8.2.190.0110.00718.41
8.2.180.0120.00318.41
8.2.170.0080.00819.13
8.2.160.0030.01022.96
8.2.150.0050.00325.66
8.2.140.0110.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00019.67
8.2.110.0030.00622.25
8.2.100.0080.00417.97
8.2.90.0040.00420.71
8.2.80.0060.00318.17
8.2.70.0050.00317.93
8.2.60.0040.00718.34
8.2.50.0080.00018.10
8.2.40.0040.00420.30
8.2.30.0000.00919.45
8.2.20.0000.00818.19
8.2.10.0050.00218.16
8.2.00.0080.00017.83
8.1.280.0120.00325.92
8.1.270.0080.00022.32
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0040.00422.48
8.1.230.0000.01221.02
8.1.220.0000.00817.91
8.1.210.0040.00418.91
8.1.200.0040.00417.35
8.1.190.0080.00017.35
8.1.180.0040.00418.10
8.1.170.0040.00418.63
8.1.160.0040.00418.89
8.1.150.0040.00420.35
8.1.140.0000.00819.54
8.1.130.0030.00317.85
8.1.120.0030.00617.46
8.1.110.0000.00817.43
8.1.100.0030.00617.46
8.1.90.0050.00317.45
8.1.80.0000.00717.48
8.1.70.0070.00017.59
8.1.60.0000.00817.68
8.1.50.0030.00617.52
8.1.40.0090.00017.65
8.1.30.0040.00417.63
8.1.20.0040.00417.70
8.1.10.0000.00917.65
8.1.00.0040.00417.54
8.0.300.0050.00320.01
8.0.290.0030.00616.88
8.0.280.0000.00718.44
8.0.270.0000.00716.97
8.0.260.0030.00317.34
8.0.250.0000.00717.09
8.0.240.0000.00717.11
8.0.230.0070.00317.08
8.0.220.0070.00016.98
8.0.210.0030.00316.93
8.0.200.0040.00417.14
8.0.190.0030.00516.99
8.0.180.0000.00717.13
8.0.170.0040.00417.05
8.0.160.0040.00416.94
8.0.150.0000.00816.99
8.0.140.0040.00417.03
8.0.130.0060.00013.55
8.0.120.0000.00817.03
8.0.110.0070.00016.93
8.0.100.0040.00417.11
8.0.90.0030.00517.05
8.0.80.0060.00916.99
8.0.70.0050.00216.93
8.0.60.0050.00216.96
8.0.50.0000.00717.11
8.0.30.0080.01017.16
8.0.20.0110.00917.40
8.0.10.0080.00017.04
8.0.00.0000.01817.00
7.4.330.0000.00515.55
7.4.320.0020.00516.56
7.4.300.0030.00316.70
7.4.290.0080.00016.57
7.4.280.0060.00316.59
7.4.270.0070.00016.55
7.4.260.0000.00716.62
7.4.250.0040.00416.70
7.4.240.0000.01016.59
7.4.230.0040.00416.72
7.4.220.0040.01216.52
7.4.210.0030.01216.69
7.4.200.0080.00016.80
7.4.160.0090.00716.54
7.4.150.0070.01117.40
7.4.140.0100.00917.86
7.4.130.0060.01116.69
7.4.120.0090.00916.70
7.4.110.0110.00716.76
7.4.100.0120.00616.56
7.4.90.0090.00916.80
7.4.80.0040.01319.39
7.4.70.0030.01316.64
7.4.60.0030.01316.87
7.4.50.0100.00016.58
7.4.40.0080.00816.45
7.4.30.0100.00716.49
7.4.00.0100.00615.04
7.3.330.0050.00013.32
7.3.320.0030.00313.43
7.3.310.0050.00316.45
7.3.300.0070.00016.45
7.3.290.0100.00616.43
7.3.280.0070.01016.44
7.3.270.0130.01017.40
7.3.260.0120.00916.53
7.3.250.0140.00616.48
7.3.240.0090.00816.49
7.3.230.0060.01516.47
7.3.210.0070.01016.46
7.3.200.0160.00616.59
7.3.190.0080.00816.49
7.3.180.0100.00716.61
7.3.170.0090.00616.62
7.3.160.0060.01216.58
7.3.120.0130.00315.09
7.3.110.0100.01015.05
7.3.100.0040.01514.90
7.3.90.0040.01214.84
7.3.80.0090.00614.74
7.3.70.0110.00815.00
7.3.60.0000.01815.04
7.3.50.0030.01014.73
7.3.40.0030.01314.95
7.3.30.0000.01414.84
7.3.20.0040.01416.72
7.3.10.0040.00716.68
7.3.00.0030.00916.71
7.2.330.0070.01116.56
7.2.320.0150.00616.88
7.2.310.0030.01316.71
7.2.300.0170.00416.81
7.2.290.0000.01716.52
7.2.250.0160.00314.93
7.2.240.0030.01715.23
7.2.230.0030.01314.98
7.2.220.0070.00715.34
7.2.210.0030.00915.02
7.2.200.0150.00415.06
7.2.190.0040.01114.74
7.2.180.0060.00314.90
7.2.170.0070.01115.04
7.2.160.0110.00714.93
7.2.150.0000.01416.88
7.2.140.0060.00916.98
7.2.130.0070.00716.98
7.2.120.0040.00716.96
7.2.110.0030.00916.80
7.2.100.0060.00616.78
7.2.90.0030.01116.98
7.2.80.0060.00817.04
7.2.70.0040.00816.78
7.2.60.0030.01116.87
7.2.50.0070.00716.82
7.2.40.0080.00816.70
7.2.30.0120.00317.05
7.2.20.0060.00316.87
7.2.10.0030.01516.95
7.2.00.0030.01118.22
7.1.330.0100.00715.79
7.1.320.0070.00315.89
7.1.310.0140.00415.50
7.1.300.0130.00315.47
7.1.290.0100.00615.82
7.1.280.0030.00715.71
7.1.270.0090.00615.62
7.1.260.0070.00715.77
7.1.250.0040.01115.82
7.1.240.0070.00715.65
7.1.230.0040.00815.85
7.1.220.0040.00815.61
7.1.210.0000.01215.57
7.1.200.0020.01015.67
7.1.190.0040.00415.88
7.1.180.0030.01015.93
7.1.170.0040.00715.44
7.1.160.0080.00415.80
7.1.150.0120.00315.81
7.1.140.0040.00815.85
7.1.130.0040.01215.87
7.1.120.0070.00715.81
7.1.110.0000.01315.82
7.1.100.0070.01117.05
7.1.90.0090.00615.73
7.1.80.0070.00715.40
7.1.70.0040.00616.38
7.1.60.0060.00616.48
7.1.50.0060.00916.36
7.1.40.0060.00915.55
7.1.30.0040.00415.57
7.1.20.0030.01315.84
7.1.10.0030.01315.82
7.1.00.0130.03218.98
7.0.330.0040.00915.14
7.0.320.0060.00715.35
7.0.310.0040.01115.41
7.0.300.0040.00415.42
7.0.290.0080.00815.32
7.0.280.0070.00315.44
7.0.270.0000.01415.42
7.0.260.0080.00315.45
7.0.250.0040.00815.27
7.0.240.0000.01415.20
7.0.230.0110.00415.56
7.0.220.0000.01115.42
7.0.210.0100.00315.34
7.0.200.0040.00716.08
7.0.190.0100.00315.29
7.0.180.0060.00615.54
7.0.170.0000.01015.22
7.0.160.0100.00315.33
7.0.150.0030.01015.48
7.0.140.0030.01315.38
7.0.130.0030.03618.72
7.0.120.0120.03218.72
7.0.110.0100.03518.83
7.0.100.0100.03218.68
7.0.90.0140.02818.67
7.0.80.0120.03418.60
7.0.70.0110.03818.73
7.0.60.0100.03018.84
7.0.50.0090.03618.82
7.0.40.0070.04617.76
7.0.30.0050.03817.68
7.0.20.0050.04517.72
7.0.10.0110.03117.78
7.0.00.0100.03317.78
5.6.400.0000.01314.20
5.6.390.0120.00314.57
5.6.380.0000.01614.17
5.6.370.0080.00314.54
5.6.360.0000.00914.10
5.6.350.0040.01114.11
5.6.340.0030.00914.51
5.6.330.0060.00914.43
5.6.320.0040.00414.10
5.6.310.0030.01014.59
5.6.300.0040.01114.09
5.6.290.0000.01714.48
5.6.280.0100.03317.59
5.6.270.0040.04117.74
5.6.260.0030.03517.77
5.6.250.0070.03317.63
5.6.240.0080.03317.77
5.6.230.0130.03017.55
5.6.220.0170.04017.62
5.6.210.0080.04817.55
5.6.200.0150.03217.64
5.6.190.0100.04517.67
5.6.180.0100.03317.75
5.6.170.0180.03917.83
5.6.160.0140.03617.53
5.6.150.0070.04217.72
5.6.140.0080.03417.53
5.6.130.0100.04017.59
5.6.120.0120.03317.53
5.6.110.0100.03217.78
5.6.100.0080.03617.73
5.6.90.0080.03717.63
5.6.80.0070.03817.22
5.6.70.0120.03617.20
5.6.60.0110.03417.31
5.6.50.0130.02717.26
5.6.40.0100.03317.29
5.6.30.0110.03417.23
5.6.20.0060.03817.19
5.6.10.0100.03217.13
5.6.00.0090.04417.26

preferences:
34.75 ms | 401 KiB | 5 Q