3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculate_string( $mathString ) { $mathString = trim($mathString); // trim white spaces $mathString = preg_replace ('#[^0-9\+-\*\/\(\) ]#', '', $mathString); // remove any non-numbers chars; exception for math operators $compute = create_function("", "return (" . $mathString . ");" ); return 0 + $compute(); } $string = " (1 + 1) * (2 + 2)"; echo calculate_string($string); // outputs 8

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.0120.00918.40
8.3.50.0190.00621.15
8.3.40.0150.00418.96
8.3.30.0110.00418.66
8.3.20.0040.00420.28
8.3.10.0040.00423.51
8.3.00.0040.00417.93
8.2.180.0140.00716.88
8.2.170.0110.00422.96
8.2.160.0070.00720.52
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0070.00019.77
8.2.110.0070.00321.03
8.2.100.0050.00517.72
8.2.90.0080.00019.45
8.2.80.0000.00817.97
8.2.70.0000.00817.80
8.2.60.0000.00917.92
8.2.50.0030.00618.10
8.2.40.0060.00320.56
8.2.30.0080.00019.32
8.2.20.0000.00717.62
8.2.10.0050.00218.02
8.2.00.0040.00417.99
8.1.280.0140.00725.92
8.1.270.0070.01322.03
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0070.00322.52
8.1.230.0040.00722.82
8.1.220.0000.00917.74
8.1.210.0030.00618.77
8.1.200.0050.00317.36
8.1.190.0040.00417.12
8.1.180.0030.00518.10
8.1.170.0000.00818.50
8.1.160.0050.00222.20
8.1.150.0040.00418.77
8.1.140.0030.00517.45
8.1.130.0070.00017.63
8.1.120.0040.00417.44
8.1.110.0030.00517.39
8.1.100.0050.00317.47
8.1.90.0020.00517.39
8.1.80.0070.00017.46
8.1.70.0040.00417.42
8.1.60.0050.00317.59
8.1.50.0000.00817.55
8.1.40.0040.00417.54
8.1.30.0000.00817.59
8.1.20.0040.00417.66
8.1.10.0030.00517.58
8.1.00.0070.00017.48
8.0.300.0040.00419.98
8.0.290.0000.00816.88
8.0.280.0000.00718.43
8.0.270.0000.00817.29
8.0.260.0060.00317.11
8.0.250.0060.00316.96
8.0.240.0040.00416.93
8.0.230.0030.00316.94
8.0.220.0030.00316.96
8.0.210.0030.00616.83
8.0.200.0000.00716.92
8.0.190.0120.00016.82
8.0.180.0060.00316.85
8.0.170.0040.00416.81
8.0.160.0070.00016.95
8.0.150.0000.00716.85
8.0.140.0070.00016.80
8.0.130.0030.00313.40
8.0.120.0070.00316.88
8.0.110.0000.00716.79
8.0.100.0000.00716.93
8.0.90.0000.00716.86
8.0.80.0110.00416.88
8.0.70.0040.00416.89
8.0.60.0000.00716.85
8.0.50.0040.00416.96
8.0.30.0110.00817.02
8.0.20.0110.00817.43
8.0.10.0020.00516.91
8.0.00.0070.01216.74
7.4.330.0020.00215.22
7.4.320.0000.00616.60
7.4.300.0060.00016.59
7.4.290.0030.00316.71
7.4.280.0090.00016.62
7.4.270.0000.00616.69
7.4.260.0070.00016.58
7.4.250.0000.00816.56
7.4.240.0000.00716.59
7.4.230.0070.00016.41
7.4.220.0080.01216.52
7.4.210.0080.00516.56
7.4.200.0070.00016.43
7.4.160.0080.00816.78
7.4.150.0150.00317.40
7.4.140.0120.00917.86
7.4.130.0080.01016.44
7.4.120.0100.00916.51
7.4.110.0120.00916.55
7.4.100.0070.01716.59
7.4.90.0120.00616.71
7.4.80.0100.00919.39
7.4.70.0130.00316.48
7.4.60.0030.01416.76
7.4.50.0030.00516.45
7.4.40.0040.01216.61
7.4.30.0100.00616.51
7.4.10.0030.01216.36
7.4.00.0060.00915.83
7.3.330.0020.00213.51
7.3.320.0050.00013.51
7.3.310.0060.00016.53
7.3.300.0050.00216.30
7.3.290.0060.00016.49
7.3.280.0100.01116.42
7.3.270.0140.00417.40
7.3.260.0140.01016.40
7.3.250.0140.00616.44
7.3.240.0090.00916.63
7.3.230.0120.00616.60
7.3.210.0060.01016.68
7.3.200.0110.01116.51
7.3.190.0000.01516.59
7.3.180.0170.00416.32
7.3.170.0040.01216.41
7.3.160.0140.00316.44
7.3.130.0060.01316.39
7.3.120.0080.00816.28
7.3.110.0030.01016.61
7.3.100.0060.01216.57
7.3.90.0150.00016.35
7.3.80.0070.00316.48
7.3.70.0040.01116.22
7.3.60.0100.00616.44
7.3.50.0090.00616.49
7.3.40.0030.01016.43
7.3.30.0090.00616.57
7.3.20.0030.01318.29
7.3.10.0040.00917.37
7.3.00.0080.00917.35
7.2.330.0080.00816.50
7.2.320.0040.01416.73
7.2.310.0140.00416.71
7.2.300.0160.00016.75
7.2.290.0130.00916.55
7.2.260.0030.01216.53
7.2.250.0070.01416.49
7.2.240.0040.01116.45
7.2.230.0090.00616.54
7.2.220.0090.00616.74
7.2.210.0070.00716.45
7.2.200.0070.01016.77
7.2.190.0030.01316.52
7.2.180.0000.01416.39
7.2.170.0090.00616.54
7.2.160.0060.01316.69
7.2.150.0090.00918.53
7.2.140.0000.01318.31
7.2.130.0110.00617.60
7.2.120.0050.01017.81
7.2.110.0050.01017.59
7.2.100.0020.01117.63
7.2.90.0110.00317.57
7.2.80.0030.01117.71
7.2.70.0040.00917.68
7.2.60.0110.00617.53
7.2.50.0080.00517.59
7.2.40.0060.01117.87
7.2.30.0090.00517.76
7.2.20.0090.00817.63
7.2.10.0050.01017.76
7.2.00.0040.00718.39
7.1.330.0070.01017.58
7.1.320.0000.01317.40
7.1.310.0030.01017.54
7.1.300.0030.01017.45
7.1.290.0000.01417.32
7.1.280.0090.00317.20
7.1.270.0030.01217.27
7.1.260.0030.01017.37
7.1.250.0060.00916.48
7.1.240.0100.00717.36
7.1.230.0040.00817.21
7.1.220.0070.00717.22
7.1.210.0030.01217.16
7.1.200.0040.00816.53
7.1.190.0030.00617.35
7.1.180.0000.00917.31
7.1.170.0090.00617.23
7.1.160.0030.01017.36
7.1.150.0040.00717.25
7.1.140.0030.01017.25
7.1.130.0060.00617.17
7.1.120.0040.00817.43
7.1.110.0000.01417.35
7.1.100.0030.01017.82
7.1.90.0060.00617.23
7.1.80.0070.00717.42
7.1.70.0040.00817.37
7.1.60.0130.00718.32
7.1.50.0090.01017.19
7.1.40.0030.00617.29
7.1.30.0060.00317.28
7.1.20.0000.01117.31
7.1.10.0060.00917.20
7.1.00.0020.04519.72
7.0.330.0070.01016.80
7.0.320.0060.01016.95
7.0.310.0090.00617.12
7.0.300.0060.00617.18
7.0.290.0040.00417.02
7.0.280.0040.01117.19
7.0.270.0090.00617.13
7.0.260.0000.01516.92
7.0.250.0060.00616.97
7.0.240.0080.00317.31
7.0.230.0070.00716.90
7.0.220.0090.00617.18
7.0.210.0100.00317.09
7.0.200.0060.00316.97
7.0.190.0070.00717.04
7.0.180.0080.00817.10
7.0.170.0030.00617.03
7.0.160.0030.01017.30
7.0.150.0100.00717.27
7.0.140.0030.01016.96
7.0.130.0060.00617.25
7.0.120.0030.01017.25
7.0.110.0050.00517.17
7.0.100.0150.00416.93
7.0.90.0040.00717.02
7.0.80.0030.01017.01
7.0.70.0110.00017.06
7.0.60.0050.04918.48
7.0.50.0060.02117.50
7.0.40.0050.04517.54
7.0.30.0110.02517.63
7.0.20.0260.03617.51
7.0.10.0050.03117.64
7.0.00.0060.03117.60
5.6.400.0080.00615.96
5.6.390.0000.01215.79
5.6.380.0130.00016.02
5.6.370.0090.00616.03
5.6.360.0100.00315.96
5.6.350.0030.01015.89
5.6.340.0040.01115.93
5.6.330.0090.00615.93
5.6.320.0090.00616.05
5.6.310.0000.01115.97
5.6.300.0060.01015.83
5.6.290.0030.01015.70
5.6.280.0060.03518.38
5.6.270.0120.00315.78
5.6.260.0130.00615.93
5.6.250.0000.01615.86
5.6.240.0090.00615.89
5.6.230.0100.00315.81
5.6.220.0070.00715.91
5.6.210.0050.02318.28
5.6.200.0070.02317.13
5.6.190.0070.04318.21
5.6.180.0160.02418.10
5.6.170.0120.04518.35
5.6.160.0020.02718.26
5.6.150.0110.03717.00
5.6.140.0070.02317.13
5.6.130.0100.04217.13
5.6.120.0150.02518.43
5.6.110.0050.03718.40
5.6.100.0070.04518.43
5.6.90.0100.04218.34
5.6.80.0100.03418.17
5.6.70.1910.02618.09
5.6.60.0030.00615.77
5.6.50.0060.00916.09
5.6.40.0110.00415.78
5.6.30.0070.00415.76
5.6.20.0070.00415.81
5.6.10.0060.00615.58
5.6.00.0030.01315.91
5.5.380.0090.00315.72
5.5.370.0100.00715.78
5.5.360.0030.00715.75
5.5.350.0180.03918.07
5.5.340.0070.02016.83
5.5.330.0040.03117.96
5.5.320.0220.01818.01
5.5.310.0130.02217.93
5.5.300.0050.02416.94
5.5.290.0040.04616.83
5.5.280.0080.03018.23
5.5.270.0070.04718.32
5.5.260.0060.04418.29
5.5.250.0070.02718.14
5.5.240.2130.02017.99
5.5.230.0030.01015.75
5.5.220.0030.00815.67
5.5.210.0040.01115.62
5.5.200.0070.00715.85
5.5.190.0030.00915.60
5.5.180.0060.00315.83
5.5.170.0060.00615.74
5.5.160.0090.00615.80
5.5.150.0090.00615.83
5.5.140.0060.00615.77
5.5.130.0060.00615.61
5.5.120.0000.01515.64
5.5.110.0030.01015.78
5.5.100.0060.00315.57
5.5.90.0030.00615.32
5.5.80.0080.00415.57
5.5.70.0030.01015.78
5.5.60.0090.00615.90
5.5.50.0070.00315.73
5.5.40.0110.00015.71
5.5.30.0070.00315.40
5.5.20.0070.00715.80
5.5.10.0050.00515.59
5.5.00.0140.00015.56
5.4.450.0300.04015.99
5.4.440.0430.04116.10
5.4.430.0370.04316.26
5.4.420.0550.03316.13
5.4.410.0440.03715.89
5.4.400.0280.03715.94
5.4.390.0330.03516.03
5.4.380.0350.03416.00
5.4.370.0280.03715.95
5.4.360.0410.04015.89
5.4.350.0350.03015.70
5.4.340.0370.03715.91
5.4.330.0040.00812.48
5.4.320.0280.03715.97
5.4.310.0380.03215.93
5.4.300.0390.03415.88
5.4.290.0300.04515.85
5.4.280.0400.03016.01
5.4.270.0380.04215.82
5.4.260.0400.04115.86
5.4.250.0410.03815.99
5.4.240.0430.03715.93
5.4.230.0370.03615.84
5.4.220.0280.03915.75
5.4.210.0430.03515.74
5.4.200.0380.03515.77
5.4.190.0380.04215.71
5.4.180.0440.02615.90
5.4.170.0440.03515.84
5.4.160.0340.03815.57
5.4.150.0580.03315.88
5.4.140.0370.02714.33
5.4.130.0330.03414.61
5.4.120.0350.03514.54
5.4.110.0320.03514.54
5.4.100.0320.03214.45
5.4.90.0370.04314.48
5.4.80.0420.03714.33
5.4.70.0000.02414.49
5.4.60.0070.04214.46
5.4.50.0030.03614.39
5.4.40.0100.01914.43
5.4.30.0170.03614.57
5.4.20.0250.03114.51
5.4.10.0000.01112.70
5.4.00.0000.01112.70

preferences:
60.09 ms | 401 KiB | 5 Q