3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = '2+3*pi'; // Remove whitespaces $test = preg_replace('/\s+/', '', $test); $number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number $functions = '(?:sinh?|cosh?|tanh?|abs|acosh?|asinh?|atanh?|exp|log10|deg2rad|rad2deg|sqrt|ceil|floor|round)'; // Allowed PHP functions $operators = '[+\/*\^%-]'; // Allowed math operators $regexp = '/^(('.$number.'|'.$functions.'\s*\((?1)+\)|\((?1)+\))(?:'.$operators.'(?2))?)+$/'; // Final regexp, heavily using recursive patterns if (preg_match($regexp, $test)) { $test = preg_replace('!pi|π!', 'pi()', $test); // Replace pi with pi function eval('$result = '.$test.';'); } else { $result = false; }

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.40.0090.00619.11
8.3.30.0030.01020.46
8.3.20.0070.00020.16
8.3.10.0050.00321.97
8.3.00.0080.00022.65
8.2.170.0120.00922.96
8.2.160.0090.00622.25
8.2.150.0030.00624.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0080.00020.91
8.2.110.0100.00022.37
8.2.100.0110.00018.16
8.2.90.0080.00019.47
8.2.80.0040.00418.00
8.2.70.0030.00517.88
8.2.60.0000.00818.05
8.2.50.0060.00618.07
8.2.40.0110.00018.47
8.2.30.0000.00719.47
8.2.20.0060.00317.97
8.2.10.0000.00717.92
8.2.00.0040.00418.05
8.1.270.0080.00023.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00622.22
8.1.230.0040.00717.76
8.1.220.0030.00517.79
8.1.210.0090.00018.77
8.1.200.0030.00717.47
8.1.190.0030.00517.66
8.1.180.0060.00318.10
8.1.170.0030.00618.64
8.1.160.0000.00718.94
8.1.150.0030.00618.88
8.1.140.0030.00617.76
8.1.130.0070.00017.93
8.1.120.0040.00417.75
8.1.110.0040.00317.73
8.1.100.0040.00417.70
8.1.90.0090.00317.65
8.1.80.0040.00417.63
8.1.70.0040.00417.67
8.1.60.0060.00317.82
8.1.50.0080.00017.66
8.1.40.0040.00417.69
8.1.30.0040.00417.86
8.1.20.0040.00417.82
8.1.10.0080.00017.77
8.1.00.0030.00917.68
8.0.300.0020.00518.77
8.0.290.0000.01016.88
8.0.280.0050.00218.48
8.0.270.0040.00417.28
8.0.260.0030.00317.12
8.0.250.0000.00817.09
8.0.240.0000.01017.18
8.0.230.0070.00017.19
8.0.220.0000.00717.23
8.0.210.0040.00417.01
8.0.200.0070.00017.02
8.0.190.0060.00317.23
8.0.180.0050.00316.98
8.0.170.0030.00617.07
8.0.160.0000.00717.09
8.0.150.0070.00017.15
8.0.140.0000.00716.98
8.0.130.0070.00013.59
8.0.120.0000.00817.05
8.0.110.0000.00817.08
8.0.100.0030.00517.19
8.0.90.0040.00417.09
8.0.80.0140.01017.13
8.0.70.0000.00717.07
8.0.60.0000.00817.20
8.0.50.0050.00317.27
8.0.30.0030.01717.36
8.0.20.0110.00717.45
8.0.10.0030.00517.03
8.0.00.0070.01317.02
7.4.330.0030.00315.14
7.4.320.0000.00716.82
7.4.300.0030.00316.86
7.4.290.0030.00316.80
7.4.280.0000.00816.86
7.4.270.0040.00516.80
7.4.260.0050.00013.63
7.4.250.0040.00416.72
7.4.240.0010.00616.96
7.4.230.0030.00316.94
7.4.220.0120.00616.80
7.4.210.0100.00416.80
7.4.200.0030.00617.01
7.4.190.0040.00417.00
7.4.160.0080.00816.68
7.4.150.0070.01117.40
7.4.140.0110.00617.86
7.4.130.0090.01116.77
7.4.120.0040.01516.79
7.4.110.0070.01316.60
7.4.100.0060.01516.55
7.4.90.0090.00616.64
7.4.80.0060.01219.39
7.4.70.0070.01116.68
7.4.60.0070.01016.88
7.4.50.0060.00316.46
7.4.40.0090.00622.77
7.4.30.0150.00316.57
7.4.00.0090.00314.93
7.3.330.0000.00513.26
7.3.320.0030.00313.30
7.3.310.0040.00416.50
7.3.300.0030.00316.54
7.3.290.0090.00716.39
7.3.280.0090.00616.46
7.3.270.0030.01617.40
7.3.260.0150.00616.41
7.3.250.0080.00916.68
7.3.240.0070.01116.58
7.3.230.0090.00916.76
7.3.210.0090.00916.73
7.3.200.0070.01019.39
7.3.190.0060.01216.77
7.3.180.0000.01716.44
7.3.170.0070.01016.46
7.3.160.0080.00816.79
7.3.120.0070.01014.68
7.3.10.0090.00616.51
7.3.00.0060.00316.61
7.2.330.0070.01116.73
7.2.320.0120.01116.86
7.2.310.0100.01016.77
7.2.300.0120.00616.85
7.2.290.0060.01416.72
7.2.130.0060.00317.00
7.2.120.0030.01017.28
7.2.110.0000.01317.20
7.2.100.0030.00617.10
7.2.90.0060.00917.32
7.2.80.0030.01016.82
7.2.70.0070.00717.36
7.2.60.0040.01117.09
7.2.50.0000.01316.90
7.2.40.0000.01416.82
7.2.30.0110.00417.24
7.2.20.0090.00316.54
7.2.10.0040.00816.68
7.2.00.0020.01318.32
7.1.250.0000.00815.84
7.1.100.0030.01218.25
7.1.70.0060.00617.45
7.1.60.0090.00317.73
7.1.50.0090.00917.28
7.1.00.0000.03722.52
7.0.200.0070.01117.04
7.0.140.0070.07022.05
7.0.110.0670.06719.96
7.0.100.0570.08020.05
7.0.90.0470.08319.89
7.0.80.0330.05019.96
7.0.70.0500.05019.94
7.0.60.0630.07320.01
7.0.50.0570.08320.38
7.0.40.0200.06720.28
7.0.30.0070.08720.29
7.0.20.0130.08320.09
7.0.10.0030.09320.08
7.0.00.0030.04320.29
5.6.280.0030.06720.98
5.6.250.0030.05720.66
5.6.240.0100.04720.56
5.6.230.0030.08320.67
5.6.220.0100.08020.70
5.6.210.0170.06320.65
5.6.200.0130.07721.20
5.6.190.0070.08721.27
5.6.180.0100.06320.92
5.6.170.0070.08021.12
5.6.160.0130.04321.12
5.6.150.0000.09020.93
5.6.140.0000.08020.98
5.6.130.0100.08321.14
5.6.120.0070.05320.98
5.6.110.0070.08020.90
5.6.100.0030.07021.06
5.6.90.0070.09021.24
5.6.80.0200.06320.31
5.6.70.0200.07020.66
5.6.60.0070.07020.42
5.6.50.0100.06720.57
5.6.40.0130.07020.43
5.6.30.0170.06020.30
5.6.20.0030.07020.63
5.6.10.0070.07320.44
5.6.00.0130.06720.55
5.5.380.0130.07720.51
5.5.370.0130.07720.41
5.5.360.0100.07020.39
5.5.350.0100.07720.45
5.5.340.0100.08020.88
5.5.330.0030.09020.84
5.5.320.0070.07721.04
5.5.310.0100.08020.94
5.5.300.0030.08320.94
5.5.290.0070.08720.81
5.5.280.0200.07020.99
5.5.270.0170.07020.73
5.5.260.0070.04721.01
5.5.250.0000.08720.68
5.5.240.0070.04720.08
5.5.230.0070.07720.18
5.5.220.0070.07320.15
5.5.210.0000.08720.26
5.5.200.0130.07020.25
5.5.190.0130.07020.21
5.5.180.0100.07720.10
5.5.160.0070.04320.16
5.5.150.0000.07020.15
5.5.140.0170.05320.31
5.5.130.0000.05020.21
5.5.120.0030.04320.16
5.5.110.0070.04720.11
5.5.100.0000.04020.15
5.5.90.0000.04720.23
5.5.80.0030.04320.08
5.5.70.0130.03020.16
5.5.60.0000.04720.25
5.5.50.0070.03320.23
5.5.40.0030.04020.13
5.5.30.0100.04720.09
5.5.20.0070.03719.97
5.5.10.0030.04020.06
5.5.00.0030.04020.03
5.4.450.0130.06719.28
5.4.440.0100.08019.45
5.4.430.0030.07719.33
5.4.420.0100.04319.30
5.4.410.0100.06019.24
5.4.400.0000.08019.18
5.4.390.0000.07319.03
5.4.380.0030.05019.12
5.4.370.0100.07319.27
5.4.360.0100.07318.95
5.4.350.0070.07319.02
5.4.340.0130.07319.08
5.4.320.0030.04718.95
5.4.310.0070.06719.27
5.4.300.0070.04019.14
5.4.290.0030.03719.02
5.4.280.0030.05318.96
5.4.270.0070.04719.00
5.4.260.0000.04019.25
5.4.250.0030.03719.07
5.4.240.0030.03319.24
5.4.230.0070.05319.11
5.4.220.0000.04018.95
5.4.210.0030.06718.97
5.4.200.0000.04019.02
5.4.190.0100.05319.15
5.4.180.0030.04318.97
5.4.170.0030.03718.94
5.4.160.0030.03719.25
5.4.150.0070.03319.00
5.4.140.0030.03716.37
5.4.130.0100.04716.19
5.4.120.0100.03316.20
5.4.110.0030.03716.37
5.4.100.0030.03316.53
5.4.90.0070.03016.19
5.4.80.0000.03716.44
5.4.70.0100.04716.32
5.4.60.0030.04316.16
5.4.50.0070.03016.21
5.4.40.0070.04316.16
5.4.30.0070.04016.25
5.4.20.0000.03716.45
5.4.10.0070.03316.16
5.4.00.0000.04015.71
5.3.290.0100.06014.60
5.3.280.0000.04014.66
5.3.270.0100.06014.46
5.3.260.0030.03714.49
5.3.250.0030.03714.62
5.3.240.0030.03714.70
5.3.230.0070.05314.70
5.3.220.0030.03314.63
5.3.210.0070.03314.41
5.3.200.0070.03314.50
5.3.190.0070.03314.41
5.3.180.0070.03314.58
5.3.170.0000.04014.46
5.3.160.0100.03714.67
5.3.150.0030.04314.63
5.3.140.0030.03314.38
5.3.130.0030.03714.62
5.3.120.0100.04314.48
5.3.110.0100.03014.49
5.3.100.0070.05014.00
5.3.90.0030.03313.91
5.3.80.0030.04714.03
5.3.70.0030.03713.95
5.3.60.0030.07313.86
5.3.50.0030.05313.83
5.3.40.0000.04013.83
5.3.30.0030.03713.97
5.3.20.0100.02713.55
5.3.10.0030.03313.67
5.3.00.0070.05713.48
5.2.170.0030.02711.30
5.2.160.0000.03011.08
5.2.150.0000.05011.13
5.2.140.0000.03011.20
5.2.130.0000.03010.89
5.2.120.0070.02311.25
5.2.110.0030.02711.11
5.2.100.0000.04311.04
5.2.90.0030.04011.18
5.2.80.0000.05311.02
5.2.70.0030.03011.11
5.2.60.0100.02710.94
5.2.50.0070.05010.93
5.2.40.0070.05711.16
5.2.30.0130.05010.92
5.2.20.0070.05711.04
5.2.10.0070.04310.80
5.2.00.0030.04710.93
5.1.60.0030.0509.90
5.1.50.0030.0509.91
5.1.40.0100.04310.03
5.1.30.0100.05010.23
5.1.20.0100.02710.30
5.1.10.0070.05010.21
5.1.00.0130.05010.00
5.0.50.0070.0438.48
5.0.40.0000.0438.35
5.0.30.0030.0638.29
5.0.20.0030.0278.29
5.0.10.0030.0438.29
5.0.00.0030.0608.29
4.4.90.0000.0208.29
4.4.80.0030.0138.29
4.4.70.0030.0278.29
4.4.60.0000.0208.29
4.4.50.0030.0338.29
4.4.40.0070.0478.29
4.4.30.0100.0308.29
4.4.20.0130.0238.29
4.4.10.0000.0378.29
4.4.00.0030.0478.29
4.3.110.0070.0308.29
4.3.100.0000.0378.29
4.3.90.0030.0338.29
4.3.80.0030.0478.29
4.3.70.0030.0338.29
4.3.60.0000.0208.29
4.3.50.0070.0308.29
4.3.40.0130.0438.29
4.3.30.0030.0178.29
4.3.20.0070.0308.29
4.3.10.0100.0278.29
4.3.00.0070.0308.29

preferences:
42.08 ms | 400 KiB | 5 Q