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, $q)) { $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.60.0160.00318.68
8.3.50.0140.00521.14
8.3.40.0150.00019.00
8.3.30.0080.00620.46
8.3.20.0040.00420.39
8.3.10.0040.00422.04
8.3.00.0000.00822.39
8.2.180.0190.00017.00
8.2.170.0000.01822.96
8.2.160.0140.00022.20
8.2.150.0090.00024.18
8.2.140.0050.00324.66
8.2.130.0000.00926.16
8.2.120.0080.00021.04
8.2.110.0060.00322.22
8.2.100.0110.00319.67
8.2.90.0000.00919.06
8.2.80.0060.00319.51
8.2.70.0050.00317.88
8.2.60.0050.00317.93
8.2.50.0000.00818.07
8.2.40.0060.00318.34
8.2.30.0040.00419.58
8.2.20.0060.00318.00
8.2.10.0050.00318.09
8.2.00.0040.00418.15
8.1.280.0080.00825.92
8.1.270.0040.00423.99
8.1.260.0060.00326.35
8.1.250.0000.00828.09
8.1.240.0060.00324.02
8.1.230.0120.00021.06
8.1.220.0030.00618.04
8.1.210.0040.00418.77
8.1.200.0000.01017.38
8.1.190.0030.00617.64
8.1.180.0040.00419.26
8.1.170.0050.00318.91
8.1.160.0040.00418.98
8.1.150.0040.00418.98
8.1.140.0100.00017.74
8.1.130.0000.00718.04
8.1.120.0000.00717.75
8.1.110.0040.00417.71
8.1.100.0030.00617.75
8.1.90.0040.00417.69
8.1.80.0000.00817.57
8.1.70.0030.00317.56
8.1.60.0030.00617.72
8.1.50.0050.00317.64
8.1.40.0030.00617.70
8.1.30.0040.00417.81
8.1.20.0050.00317.90
8.1.10.0000.00817.73
8.1.00.0110.00017.59
8.0.300.0000.00818.84
8.0.290.0060.00317.18
8.0.280.0030.00318.54
8.0.270.0040.00417.41
8.0.260.0030.00317.04
8.0.250.0030.00317.25
8.0.240.0080.00317.15
8.0.230.0000.00717.17
8.0.220.0000.00817.29
8.0.210.0030.00317.10
8.0.200.0040.00417.18
8.0.190.0050.00217.23
8.0.180.0070.00017.10
8.0.170.0000.00917.11
8.0.160.0030.00517.13
8.0.150.0040.00417.09
8.0.140.0040.00417.03
8.0.130.0030.00313.63
8.0.120.0050.00317.20
8.0.110.0030.00517.29
8.0.100.0020.00517.10
8.0.90.0040.00417.08
8.0.80.0080.00817.26
8.0.70.0050.00317.14
8.0.60.0040.00417.23
8.0.50.0030.00517.24
8.0.30.0090.01117.51
8.0.20.0130.00817.41
8.0.10.0000.00817.25
8.0.00.0130.00517.02
7.4.330.0000.00515.10
7.4.320.0000.00716.96
7.4.300.0000.00616.84
7.4.290.0030.00516.93
7.4.280.0030.00316.96
7.4.270.0040.00416.95
7.4.260.0060.00013.70
7.4.250.0060.00316.97
7.4.240.0050.00216.95
7.4.230.0040.00416.55
7.4.220.0030.01616.75
7.4.210.0070.00916.84
7.4.200.0050.00316.79
7.4.190.0070.00016.89
7.4.160.0080.00816.69
7.4.150.0120.00617.40
7.4.140.0100.01017.86
7.4.130.0090.00716.88
7.4.120.0070.01016.78
7.4.110.0170.00616.87
7.4.100.0140.00616.82
7.4.90.0080.01116.83
7.4.80.0130.00519.39
7.4.70.0070.01016.84
7.4.60.0080.00916.75
7.4.50.0060.00316.61
7.4.40.0100.00722.77
7.4.30.0130.00416.79
7.4.00.0070.01015.32
7.3.330.0000.00513.36
7.3.320.0030.00313.33
7.3.310.0040.00416.56
7.3.300.0030.00316.59
7.3.290.0160.00316.52
7.3.280.0120.00816.56
7.3.270.0070.01117.40
7.3.260.0100.01216.75
7.3.250.0110.01016.60
7.3.240.0090.01216.88
7.3.230.0130.00316.77
7.3.210.0090.00916.75
7.3.200.0070.01019.39
7.3.190.0030.01516.51
7.3.180.0090.00616.46
7.3.170.0060.00916.55
7.3.160.0060.01616.80
7.3.120.0040.01514.96
7.3.10.0030.01016.55
7.3.00.0000.01316.60
7.2.330.0070.01016.88
7.2.320.0170.00616.94
7.2.310.0100.01316.55
7.2.300.0100.00716.75
7.2.290.0060.01216.91
7.2.130.0030.01316.83
7.2.120.0090.00617.10
7.2.110.0070.00716.91
7.2.100.0040.00817.23
7.2.90.0050.00816.91
7.2.80.0060.00917.13
7.2.70.0100.00717.06
7.2.60.0000.01517.18
7.2.50.0030.01016.82
7.2.40.0040.01116.97
7.2.30.0000.01317.16
7.2.20.0040.01117.09
7.2.10.0090.00617.17
7.2.00.0080.00318.28
7.1.250.0060.00615.97
7.1.100.0090.00018.42
7.1.70.0000.00717.29
7.1.60.0210.00019.21
7.1.50.0140.02135.18
7.1.00.0030.05322.41
7.0.200.0070.00017.08
7.0.140.0070.06722.14
7.0.110.0230.06720.10
7.0.100.0100.08020.14
7.0.90.0070.07720.10
7.0.80.0100.07020.07
7.0.70.0130.08320.08
7.0.60.0130.08019.95
7.0.50.0070.07320.00
7.0.40.0100.08019.82
7.0.30.0030.05019.87
7.0.20.0070.08319.76
7.0.10.0030.08719.79
7.0.00.0170.07719.76
5.6.280.0000.07721.09
5.6.260.0070.07320.65
5.6.250.0070.07720.65
5.6.240.0170.07720.69
5.6.230.0130.04720.47
5.6.220.0100.07320.64
5.6.210.0000.08720.62
5.6.200.0130.06320.57
5.6.190.0170.07720.70
5.6.180.0170.07320.48
5.6.170.0170.03720.70
5.6.160.0100.07720.68
5.6.150.0000.05020.55
5.6.140.0100.07720.63
5.6.130.0100.05720.64
5.6.120.0130.07720.64
5.6.110.0130.08020.57
5.6.100.0130.06720.57
5.6.90.0130.07720.66
5.6.80.0070.07320.00
5.6.70.0130.06720.06
5.6.60.0130.08019.82
5.6.50.0100.07319.99
5.6.40.0130.06719.91
5.6.30.0100.06319.97
5.6.20.0100.04019.99
5.6.10.0130.06319.82
5.6.00.0030.08319.92
5.5.380.0170.07320.35
5.5.370.0030.08320.46
5.5.360.0070.06020.31
5.5.350.0000.06020.45
5.5.340.0070.05020.99
5.5.330.0070.08320.95
5.5.320.0030.08020.97
5.5.310.0070.08320.69
5.5.300.0100.08021.03
5.5.290.0100.08020.78
5.5.280.0070.08320.89
5.5.270.0070.05320.93
5.5.260.0100.08320.77
5.5.250.0100.08020.65
5.5.240.0030.07320.29
5.5.230.0130.08020.18
5.5.220.0130.06720.24
5.5.210.0130.07320.18
5.5.200.0100.07320.24
5.5.190.0100.07720.32
5.5.180.0070.08020.13
5.5.160.0070.05020.09
5.5.150.0030.04020.25
5.5.140.0000.08720.25
5.5.130.0230.05320.33
5.5.120.0170.06320.30
5.5.110.0030.07320.36
5.5.100.0000.08720.23
5.5.90.0070.07720.23
5.5.80.0130.07020.00
5.5.70.0000.07019.97
5.5.60.0070.07020.24
5.5.50.0070.07320.17
5.5.40.0070.04320.03
5.5.30.0070.07720.06
5.5.20.0030.08020.09
5.5.10.0100.07720.02
5.5.00.0030.08320.03
5.4.450.0200.06719.24
5.4.440.0130.05019.43
5.4.430.0100.07019.29
5.4.420.0000.08719.40
5.4.410.0030.08319.29
5.4.400.0130.07719.18
5.4.390.0170.07018.93
5.4.380.0100.04018.93
5.4.370.0030.07019.02
5.4.360.0070.07319.01
5.4.350.0070.07319.16
5.4.340.0100.07019.12
5.4.320.0130.06319.14
5.4.310.0030.07019.08
5.4.300.0030.06019.07
5.4.290.0070.04019.10
5.4.280.0030.08018.92
5.4.270.0100.07019.11
5.4.260.0200.05718.94
5.4.250.0100.07019.27
5.4.240.0030.07719.02
5.4.230.0000.08319.17
5.4.220.0130.05019.18
5.4.210.0130.05719.04
5.4.200.0100.04019.02
5.4.190.0100.07019.26
5.4.180.0070.08019.07
5.4.170.0130.07018.97
5.4.160.0100.07018.93
5.4.150.0130.06318.93
5.4.140.0070.07016.54
5.4.130.0000.08016.23
5.4.120.0170.05716.54
5.4.110.0170.06316.29
5.4.100.0030.07716.55
5.4.90.0100.06316.43
5.4.80.0170.06316.27
5.4.70.0030.07316.46
5.4.60.0030.04716.48
5.4.50.0100.07316.45
5.4.40.0070.07016.41
5.4.30.0100.04016.15
5.4.20.0130.06316.47
5.4.10.0100.07316.35
5.4.00.0030.08016.00
5.3.290.0070.08014.49
5.3.280.0000.04314.52
5.3.270.0030.08314.47
5.3.260.0170.05714.50
5.3.250.0070.07014.48
5.3.240.0030.08014.47
5.3.230.0030.05314.53
5.3.220.0030.07714.63
5.3.210.0100.06314.58
5.3.200.0100.07314.39
5.3.190.0070.06014.41
5.3.180.0030.08014.66
5.3.170.0100.07014.58
5.3.160.0030.04314.66
5.3.150.0130.07014.57
5.3.140.0100.04314.40
5.3.130.0070.07714.55
5.3.120.0030.05314.45
5.3.110.0030.08014.45
5.3.100.0130.06714.14
5.3.90.0130.06714.01
5.3.80.0000.07014.11
5.3.70.0070.06713.90
5.3.60.0130.06013.93
5.3.50.0070.07714.00
5.3.40.0070.07313.87
5.3.30.0130.06013.97
5.3.20.0030.07713.63
5.3.10.0070.05713.75
5.3.00.0030.07713.48
5.2.170.0070.06313.10
5.2.160.0070.06313.10
5.2.150.0070.06013.10
5.2.140.0030.06013.10
5.2.130.0100.03313.10
5.2.120.0070.05713.10
5.2.110.0070.06313.10
5.2.100.0070.03313.10
5.2.90.0130.05313.10
5.2.80.0030.06313.10
5.2.70.0130.02713.10
5.2.60.0030.06313.10
5.2.50.0030.05313.10
5.2.40.0100.05313.10
5.2.30.0070.05013.10
5.2.20.0030.04713.10
5.2.10.0000.06013.10
5.2.00.0100.05013.10
5.1.60.0100.04713.10
5.1.50.0130.03013.10
5.1.40.0100.05013.10
5.1.30.0070.05713.10
5.1.20.0030.04313.10
5.1.10.0030.05713.10
5.1.00.0030.05313.10
5.0.50.0070.04313.10
5.0.40.0030.03713.10
5.0.30.0030.03713.10
5.0.20.0000.04313.10
5.0.10.0000.04713.10
5.0.00.0070.05313.10
4.4.90.0000.03713.10
4.4.80.0000.03713.10
4.4.70.0000.03713.10
4.4.60.0030.03313.10
4.4.50.0030.03013.10
4.4.40.0030.03013.10
4.4.30.0000.03713.10
4.4.20.0030.01713.10
4.4.10.0100.03013.10
4.4.00.0070.05313.10
4.3.110.0030.02313.10
4.3.100.0000.03713.10
4.3.90.0000.03013.10
4.3.80.0070.05013.10
4.3.70.0000.02713.10
4.3.60.0030.03313.10
4.3.50.0070.03313.10
4.3.40.0030.05013.10
4.3.30.0000.03713.10
4.3.20.0000.03313.10
4.3.10.0000.04013.10
4.3.00.0000.03013.10

preferences:
62.11 ms | 401 KiB | 5 Q