3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rules = [ [0, '(', '_', 0, ['_', 'x']], [0, '(', 'x', 0, ['x', 'x']], [0, ')', 'x', 0, []], [0, 'EOF', '_', 1, []], ]; $state = 0; $accept_states = [1]; $init_stack = '_'; $input = '(((()))())'; $tokens = array_merge( str_split($input), ['EOF'] ); function match(array $rules, $state, $token, $top) { foreach ($rules as $rule) { list($init_state, $match_input, $match_stack, $new_state, $push_stack) = $rule; if ($state === $init_state && $token === $match_input && $top === $match_stack) { return $rule; } } $token = var_export($token, true); throw new \RuntimeException("No rule found for state $state, token $token"); } $stack = new \SplStack(); $stack->push($init_stack); foreach ($tokens as $token) { $top = $stack->pop(); $rule = match($rules, $state, $token, $top); list($init_state, $match_input, $match_stack, $new_state, $push_stack) = $rule; $state = $new_state; foreach ($push_stack as $push_token) { $stack->push($push_token); } } if (!in_array($state, $accept_states)) { throw new \RuntimeException("Reached EOF but ended in state $state which is not an accept state."); } echo "The provided input has been accepted by accept state $state\n"; echo sprintf("Stack: %s\n", json_encode(iterator_to_array($stack)));

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.0130.00618.55
8.3.50.0140.00821.92
8.3.40.0070.00718.79
8.3.30.0100.00320.21
8.3.20.0000.00720.34
8.3.10.0080.00022.04
8.3.00.0050.00322.56
8.2.180.0000.01516.38
8.2.170.0150.00319.09
8.2.160.0040.01122.96
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00420.67
8.2.110.0060.00322.14
8.2.100.0080.00417.91
8.2.90.0070.00018.93
8.2.80.0000.00719.25
8.2.70.0030.00517.50
8.2.60.0060.00317.80
8.2.50.0050.00318.07
8.2.40.0040.00418.09
8.2.30.0040.00419.29
8.2.20.0070.00017.59
8.2.10.0000.00717.54
8.2.00.0030.00517.48
8.1.280.0160.01125.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00422.05
8.1.230.0040.00819.20
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0060.00317.11
8.1.190.0030.00517.41
8.1.180.0060.00318.88
8.1.170.0040.00418.59
8.1.160.0060.00318.75
8.1.150.0030.00718.50
8.1.140.0000.00817.35
8.1.130.0030.00317.75
8.1.120.0070.00017.25
8.1.110.0040.00717.29
8.1.100.0080.00017.25
8.1.90.0030.00317.25
8.1.80.0000.00717.14
8.1.70.0040.00417.18
8.1.60.0050.00317.41
8.1.50.0040.00417.36
8.1.40.0000.00817.35
8.1.30.0040.00417.38
8.1.20.0080.00017.48
8.1.10.0040.00417.39
8.1.00.0040.00417.25
8.0.300.0040.00418.77
8.0.290.0030.00317.04
8.0.280.0000.00718.24
8.0.270.0070.00016.80
8.0.260.0030.00316.73
8.0.250.0030.00316.81
8.0.240.0000.00716.92
8.0.230.0070.00016.84
8.0.220.0030.00316.84
8.0.210.0030.00316.86
8.0.200.0000.00617.00
8.0.190.0040.00416.98
8.0.180.0000.00716.95
8.0.170.0060.00316.80
8.0.160.0080.00016.93
8.0.150.0000.00816.73
8.0.140.0030.00316.74
8.0.130.0050.00013.39
8.0.120.0000.00816.89
8.0.110.0080.00016.83
8.0.100.0040.00416.76
8.0.90.0040.00416.80
8.0.80.0050.00916.78
8.0.70.0030.00316.83
8.0.60.0070.00016.82
8.0.50.0050.00316.79
8.0.30.0100.01217.00
8.0.20.0150.00517.40
8.0.10.0080.00016.88
8.0.00.0050.01416.59
7.4.330.0000.00515.08
7.4.320.0070.00016.53
7.4.300.0000.00616.71
7.4.290.0000.00716.61
7.4.280.0070.00016.68
7.4.270.0000.00816.63
7.4.260.0000.00513.40
7.4.250.0030.00416.49
7.4.240.0010.00616.53
7.4.230.0000.00716.73
7.4.220.0080.00816.52
7.4.210.0050.01016.59
7.4.200.0050.00216.67
7.4.190.0040.00416.62
7.4.160.0150.00916.49
7.4.150.0060.01117.40
7.4.140.0100.00717.86
7.4.130.0140.00416.55
7.4.120.0080.00816.58
7.4.110.0080.00816.69
7.4.100.0120.00616.61
7.4.90.0100.01316.68
7.4.80.0110.00719.39
7.4.70.0130.00616.45
7.4.60.0050.01416.58
7.4.50.0050.00516.66
7.4.40.0100.00622.77
7.4.30.0130.00616.39
7.4.00.0100.00315.09
7.3.330.0000.00613.43
7.3.320.0060.00013.25
7.3.310.0050.00316.43
7.3.300.0040.00416.25
7.3.290.0070.00716.30
7.3.280.0130.00516.40
7.3.270.0100.00717.40
7.3.260.0000.02316.37
7.3.250.0100.00716.48
7.3.240.0180.00316.68
7.3.230.0130.00716.48
7.3.210.0110.00716.54
7.3.200.0150.00319.39
7.3.190.0120.01216.62
7.3.180.0100.00716.44
7.3.170.0100.01016.53
7.3.160.0000.02116.57
7.3.120.0040.01214.96
7.2.330.0130.00916.78
7.2.320.0100.01316.76
7.2.310.0030.01216.75
7.2.300.0080.00816.78
7.2.290.0060.01516.67
7.2.00.0000.01319.28
7.1.100.0000.01418.30
7.1.70.0060.00317.18
7.1.60.0070.01719.32
7.1.50.0070.00717.02
7.1.00.0030.05022.36
7.0.200.0040.00416.89
7.0.140.0000.07322.01
7.0.90.0100.04720.07
7.0.80.0600.07019.98
7.0.70.0070.08319.96
7.0.60.0030.05320.11
7.0.50.0400.08720.29
7.0.40.0200.06720.13
7.0.30.0000.04720.08
7.0.20.0170.05320.05
7.0.10.0030.08320.02
7.0.00.0030.04320.16
5.6.280.0030.07321.04
5.6.230.0100.06720.60
5.6.220.0130.08020.54
5.6.210.0100.03720.62
5.6.200.0030.09021.13
5.6.190.0070.09321.04
5.6.180.0070.07721.09
5.6.170.0030.05721.11
5.6.160.0100.07021.09
5.6.150.0070.05321.02
5.6.140.0130.05321.00
5.6.130.0070.08721.06
5.6.120.0070.08721.13
5.6.110.0030.05020.94
5.6.100.0100.07721.07
5.6.90.0130.07321.10
5.6.80.0200.06320.36
5.6.70.0130.04320.41
5.6.60.0030.08720.32
5.6.50.0030.07020.49
5.6.40.0000.08020.33
5.6.30.0170.06720.41
5.6.20.0070.07320.48
5.6.10.0070.05320.48
5.6.00.0130.06720.40
5.5.370.0170.07720.42
5.5.360.0100.08320.42
5.5.350.0230.07020.46
5.5.340.0070.05020.94
5.5.330.0100.07720.80
5.5.320.0030.06720.95
5.5.310.0100.08720.90
5.5.300.0030.08720.92
5.5.290.0070.05320.77
5.5.280.0130.06720.85
5.5.270.0100.06720.91
5.5.260.0100.04720.74
5.5.250.0030.06020.69
5.5.240.0030.05020.16
5.5.230.0030.08020.13
5.5.220.0100.04720.32
5.5.210.0030.07320.32
5.5.200.0070.04720.18
5.5.190.0070.08020.16
5.5.180.0030.07320.25
5.5.160.0130.07320.25
5.5.150.0070.07020.14
5.5.140.0030.08320.12
5.5.130.0030.05020.29
5.5.120.0070.08720.12
5.5.110.0130.07020.20
5.5.100.0100.04020.03
5.5.90.0030.04720.12
5.5.80.0100.07020.06
5.5.70.0100.06720.08
5.5.60.0100.07320.07
5.5.50.0100.06320.07
5.5.40.0100.07320.10
5.5.30.0070.04020.09
5.5.20.0070.03720.16
5.5.10.0170.07720.13
5.5.00.0070.05020.13
5.4.450.0100.07019.37
5.4.440.0070.04719.57
5.4.430.0100.04019.53
5.4.420.0030.08019.19
5.4.410.0030.07719.43
5.4.400.0130.06319.21
5.4.390.0170.03019.21
5.4.380.0000.05019.03
5.4.370.0030.08019.14
5.4.360.0130.07319.14
5.4.350.0100.07318.95
5.4.340.0070.06019.20
5.4.320.0070.08019.09
5.4.310.0030.06719.21
5.4.300.0100.07319.12
5.4.290.0000.06318.94
5.4.280.0070.04018.90
5.4.270.0070.07019.18
5.4.260.0100.04719.21
5.4.250.0030.05019.12
5.4.240.0130.07018.89
5.4.230.0030.07719.08
5.4.220.0170.06719.08
5.4.210.0100.04019.04
5.4.200.0130.03718.96
5.4.190.0100.05718.84
5.4.180.0070.07319.03
5.4.170.0030.04319.20
5.4.160.0070.06019.21
5.4.150.0070.04719.21
5.4.140.0030.05016.38
5.4.130.0070.07716.15
5.4.120.0070.06316.41
5.4.110.0070.06316.42
5.4.100.0070.06316.39
5.4.90.0030.07716.51
5.4.80.0070.07016.49
5.4.70.0030.07716.35
5.4.60.0000.07716.36
5.4.50.0100.05316.30
5.4.40.0100.06316.49
5.4.30.0030.07016.30
5.4.20.0030.06016.46
5.4.10.0100.04016.41
5.4.00.0100.07015.89
5.3.290.0030.08014.66
5.3.280.0030.07314.53
5.3.270.0030.05314.55
5.3.260.0070.07014.42
5.3.250.0030.07314.59
5.3.240.0070.04714.59
5.3.230.0030.08714.46
5.3.220.0000.08014.48
5.3.210.0030.04314.55
5.3.200.0070.06314.55
5.3.190.0070.07314.43
5.3.180.0070.07014.47
5.3.170.0130.05714.43
5.3.160.0030.06714.43
5.3.150.0170.06314.47
5.3.140.0070.04014.53
5.3.130.0130.07314.54
5.3.120.0100.07314.41
5.3.110.0100.07014.56
5.3.100.0030.07013.90
5.3.90.0070.04014.00
5.3.80.0030.08014.02
5.3.70.0100.03713.98
5.3.60.0000.08014.00
5.3.50.0100.03713.85
5.3.40.0000.06013.91
5.3.30.0030.07713.87
5.3.20.0070.04013.70
5.3.10.0000.06713.65
5.3.00.0130.06313.58
5.2.170.0100.06011.14
5.2.160.0070.05710.93
5.2.150.0030.04310.97
5.2.140.0030.06310.93
5.2.130.0030.06011.08
5.2.120.0100.05011.08
5.2.110.0030.03310.91
5.2.100.0030.05711.11
5.2.90.0070.03711.02
5.2.80.0100.05711.07
5.2.70.0030.06011.16
5.2.60.0030.06311.07
5.2.50.0030.06311.05
5.2.40.0000.06310.98
5.2.30.0030.05710.96
5.2.20.0100.06010.95
5.2.10.0000.06010.90
5.2.00.0100.05310.62
5.1.60.0100.0479.83
5.1.50.0100.05010.07
5.1.40.0030.05310.04
5.1.30.0030.05710.34
5.1.20.0000.05710.38
5.1.10.0070.0539.95
5.1.00.0070.0439.91
5.0.50.0100.0408.54
5.0.40.0030.0438.25
5.0.30.0000.0508.29
5.0.20.0070.0378.04
5.0.10.0100.0378.27
5.0.00.0030.0608.22
4.4.90.0030.0377.32
4.4.80.0000.0377.32
4.4.70.0000.0207.32
4.4.60.0070.0307.32
4.4.50.0000.0237.32
4.4.40.0000.0477.32
4.4.30.0000.0377.32
4.4.20.0030.0337.32
4.4.10.0030.0177.32
4.4.00.0000.0577.32
4.3.110.0000.0307.32
4.3.100.0000.0377.32
4.3.90.0000.0307.32
4.3.80.0030.0377.32
4.3.70.0000.0377.32
4.3.60.0000.0407.32
4.3.50.0000.0377.32
4.3.40.0000.0577.32
4.3.30.0030.0337.32
4.3.20.0030.0377.32
4.3.10.0070.0277.32
4.3.00.0000.0377.32

preferences:
46.56 ms | 401 KiB | 5 Q