3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parse_tokens($code) { $ns = ''; $tokens = token_get_all($code); /* Assume token 0 = '<?php' and token 1 = whitespace */ for ($i = 2, $c = count($tokens); $i < $c; ++$i) { if (!is_array($tokens[$i])) { continue; } switch ($tokens[$i][0]) { case T_CLASS: list($class, $i) = $this->parse_class($tokens, $i); if ($class) { $test = $this->instantiate_test($loader, $ns . $class); if ($test) { $this->runner->run_test_case($test); } } break; case T_NAMESPACE: //list($ns, $i) = $this->parse_namespace($tokens, $i, $ns); break; } } } function parse_class($tokens, $i) { /* $i = 'class' and $i+1 = whitespace */ $i += 2; while (!is_array($tokens[$i]) || T_STRING !== $tokens[$i][0]) { ++$i; } $class = $tokens[$i][1]; print "$class\n"; if (0 === stripos($class, 'test')) { return [$class, $i]; } return [false, $i]; } $file = <<<'FILE' class TestTextBefore {} <?php /* class TestComment {} */ class Test {} <<<STRING class TestString {} STRING; class test2 { public function test1() {} public function test2() {} public function test3() {} } class NotATest {} class // valid tokens between the 'class' keyword and the test name /* should be handled correctly */ Test3 {} ?> class TestTestAfter {} FILE; parse_tokens($file);

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.0070.01118.68
8.3.50.0070.01416.11
8.3.40.0040.01118.84
8.3.30.0120.00618.79
8.3.20.0040.00420.33
8.3.10.0000.00823.48
8.3.00.0040.00420.77
8.2.180.0040.01118.66
8.2.170.0070.01422.96
8.2.160.0070.01020.39
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0060.00319.21
8.2.120.0040.00426.35
8.2.110.0030.00722.22
8.2.100.0070.00418.05
8.2.90.0000.00819.41
8.2.80.0080.00018.05
8.2.70.0000.00817.71
8.2.60.0030.00517.93
8.2.50.0030.00518.07
8.2.40.0000.01120.43
8.2.30.0040.00420.71
8.2.20.0020.00517.89
8.2.10.0040.00418.02
8.2.00.0040.00418.02
8.1.280.0090.00925.92
8.1.270.0030.00520.39
8.1.260.0040.00428.09
8.1.250.0030.00628.09
8.1.240.0040.00423.97
8.1.230.0000.01119.22
8.1.220.0030.00517.79
8.1.210.0000.00818.77
8.1.200.0090.00017.35
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0050.00318.59
8.1.160.0000.00720.86
8.1.150.0000.00718.92
8.1.140.0040.00419.54
8.1.130.0030.00317.75
8.1.120.0000.00717.53
8.1.110.0080.00017.52
8.1.100.0000.00817.53
8.1.90.0000.00817.43
8.1.80.0060.00317.55
8.1.70.0030.00317.50
8.1.60.0080.00017.58
8.1.50.0040.00417.46
8.1.40.0050.00317.55
8.1.30.0030.00617.59
8.1.20.0030.00617.71
8.1.10.0040.00417.52
8.1.00.0000.00717.59
8.0.300.0000.00718.77
8.0.290.0040.00416.75
8.0.280.0030.00318.38
8.0.270.0070.00017.29
8.0.260.0000.00717.21
8.0.250.0040.00416.95
8.0.240.0060.00316.99
8.0.230.0040.00417.07
8.0.220.0030.00616.88
8.0.210.0030.00316.98
8.0.200.0030.00317.05
8.0.190.0040.00417.03
8.0.180.0070.00016.96
8.0.170.0040.00417.06
8.0.160.0000.00817.03
8.0.150.0040.00416.94
8.0.140.0040.00416.98
8.0.130.0060.00013.46
8.0.120.0050.00316.95
8.0.110.0050.00216.89
8.0.100.0040.00416.96
8.0.90.0040.00416.86
8.0.80.0130.00316.98
8.0.70.0050.00216.81
8.0.60.0000.00717.02
8.0.50.0050.00317.05
8.0.30.0080.01017.27
8.0.20.0110.00717.40
8.0.10.0040.00417.18
8.0.00.0070.01316.85
7.4.330.0050.00016.68
7.4.320.0030.00316.58
7.4.300.0030.00316.54
7.4.290.0030.00716.56
7.4.280.0040.00416.65
7.4.270.0070.00016.69
7.4.260.0040.00416.57
7.4.250.0000.00716.47
7.4.240.0040.00316.67
7.4.230.0070.00016.75
7.4.220.0030.02316.69
7.4.210.0060.01316.76
7.4.200.0000.00716.50
7.4.160.0200.00316.59
7.4.150.0090.00917.40
7.4.140.0100.00817.86
7.4.130.0130.00616.54
7.4.120.0080.01116.51
7.4.110.0070.01116.74
7.4.100.0070.01016.46
7.4.90.0070.01116.65
7.4.80.0140.00319.39
7.4.70.0130.00316.54
7.4.60.0040.01216.64
7.4.50.0090.00616.68
7.4.40.0160.00316.68
7.4.30.0060.01216.70
7.4.00.0050.00915.13
7.3.330.0050.00013.48
7.3.320.0000.00613.43
7.3.310.0000.00716.46
7.3.300.0080.00016.40
7.3.290.0070.01016.43
7.3.280.0060.01216.45
7.3.270.0090.00917.40
7.3.260.0090.00816.52
7.3.250.0120.00716.51
7.3.240.0090.00816.50
7.3.230.0060.01216.39
7.3.210.0070.01016.46
7.3.200.0130.00316.44
7.3.190.0090.00616.53
7.3.180.0060.01016.50
7.3.170.0090.00816.63
7.3.160.0110.01116.47
7.3.120.0050.01414.93
7.3.110.0030.00814.74
7.3.100.0090.00714.96
7.3.90.0050.01014.94
7.3.80.0090.00714.93
7.3.70.0000.01414.84
7.3.60.0070.00514.93
7.3.50.0070.00514.96
7.3.40.0040.01115.00
7.3.30.0060.01114.66
7.3.20.0020.01416.70
7.3.10.0040.00816.71
7.3.00.0100.00716.55
7.2.330.0060.01216.75
7.2.320.0040.01216.61
7.2.310.0090.00916.91
7.2.300.0120.00916.73
7.2.290.0070.01116.60
7.2.250.0070.01215.29
7.2.240.0100.00914.90
7.2.230.0050.01115.30
7.2.220.0050.01015.13
7.2.210.0050.01515.17
7.2.200.0110.00615.08
7.2.190.0050.00915.13
7.2.180.0050.01015.05
7.2.170.0070.00715.06
7.2.160.0030.00614.99
7.2.150.0030.01017.03
7.2.140.0030.01316.96
7.2.130.0080.00617.04
7.2.120.0110.00617.12
7.2.110.0100.00617.03
7.2.100.0100.00317.08
7.2.90.0120.00317.00
7.2.80.0090.00617.22
7.2.70.0090.00617.14
7.2.60.0060.00816.95
7.2.50.0100.00716.80
7.2.40.0040.01117.04
7.2.30.0070.00716.77
7.2.20.0030.01317.17
7.2.10.0030.01017.11
7.2.00.0030.00917.99
7.1.330.0060.00915.81
7.1.320.0070.00915.82
7.1.310.0050.01115.93
7.1.300.0030.01015.71
7.1.290.0080.00515.83
7.1.280.0020.00915.87
7.1.270.0050.00915.77
7.1.260.0050.00815.71
7.1.250.0080.00415.90
7.1.240.0150.00015.65
7.1.230.0070.00715.57
7.1.220.0080.00615.96
7.1.210.0030.00915.87
7.1.200.0070.00715.92
7.1.190.0060.00615.99
7.1.180.0070.00715.98
7.1.170.0030.01015.71
7.1.160.0000.01215.87
7.1.150.0000.01515.77
7.1.140.0000.00915.97
7.1.130.0080.00815.79
7.1.120.0030.01015.82
7.1.110.0030.01015.77
7.1.100.0020.01117.13
7.1.90.0030.01315.84
7.1.80.0040.01115.65
7.1.70.0080.00316.51
7.1.60.0020.01717.60
7.1.50.0030.01416.46
7.1.40.0000.01415.86
7.1.30.0030.01315.92
7.1.20.0070.00415.54
7.1.10.0110.00315.87
7.1.00.0080.04019.08
7.0.330.0100.00315.46
7.0.320.0090.00315.22
7.0.310.0070.00315.42
7.0.300.0080.00615.59
7.0.290.0050.00315.32
7.0.280.0040.00415.19
7.0.270.0040.01115.41
7.0.260.0000.01215.41
7.0.250.0040.00815.32
7.0.240.0020.00515.53
7.0.230.0100.00315.43
7.0.220.0000.01715.56
7.0.210.0110.00715.25
7.0.200.0050.00516.15
7.0.190.0070.00715.54
7.0.180.0070.00715.30
7.0.170.0040.00815.58
7.0.160.0030.00515.59
7.0.150.0030.00915.56
7.0.140.0070.00715.55
7.0.130.0060.00315.35
7.0.120.0030.01015.57
7.0.110.0060.00315.39
7.0.100.0030.01015.23
7.0.90.0000.01115.32
7.0.80.0070.01015.09
7.0.70.0040.00915.57
7.0.60.0060.04617.69
7.0.50.0050.03816.81
7.0.40.0070.02316.83
7.0.30.0120.02316.89
7.0.20.0200.03816.79
7.0.10.0070.04517.02
7.0.00.0070.02516.88
5.6.400.0060.00913.98
5.6.390.0090.00614.46
5.6.380.0060.00914.31
5.6.370.0060.00614.34
5.6.360.0070.00814.44
5.6.350.0030.00614.79
5.6.340.0070.01114.24
5.6.330.0000.01014.38
5.6.320.0000.00914.58
5.6.310.0000.01414.41
5.6.300.0040.00714.68
5.6.290.0070.01014.64
5.6.280.0060.03817.70
5.6.270.0110.00014.37
5.6.260.0070.00414.31
5.6.250.0120.00614.18
5.6.240.0030.01514.27
5.6.230.0060.01214.62
5.6.220.0060.00914.59
5.6.210.0050.03917.65
5.6.200.0090.04116.28
5.6.190.0070.03317.63
5.6.180.0190.04117.57
5.6.170.0170.04017.57
5.6.160.0020.02817.41
5.6.150.0100.03516.50
5.6.140.0030.02516.46
5.6.130.0070.04216.32
5.6.120.0030.02817.69
5.6.110.0060.04617.62
5.6.100.0120.04217.63
5.6.90.0070.04017.89
5.6.80.0100.04217.66
5.6.70.0080.00414.28
5.6.60.0080.00814.41
5.6.50.0000.01514.38
5.6.40.0070.00414.26
5.6.30.0090.00614.26
5.6.20.0030.01214.55
5.6.10.0120.00314.61
5.6.00.0110.00414.47
5.5.380.0070.01014.30
5.5.370.0090.00614.12
5.5.360.0090.00614.32
5.5.350.2200.02517.39
5.5.340.0150.03416.07
5.5.330.0100.02017.29
5.5.320.0300.01717.54
5.5.310.0180.04317.14
5.5.300.0070.02216.22
5.5.290.0050.03916.33
5.5.280.0110.02317.58
5.5.270.0060.03017.71
5.5.260.0080.04717.58
5.5.250.0080.04317.56
5.5.240.0070.02317.21
5.5.230.0110.00414.14
5.5.220.0000.01213.98
5.5.210.0040.00414.20
5.5.200.0060.00914.05
5.5.190.0090.00014.41
5.5.180.0040.01114.52
5.5.170.0030.01314.11
5.5.160.0130.00314.40
5.5.150.0030.00914.23
5.5.140.0030.01014.51
5.5.130.0090.00314.14
5.5.120.0100.00314.21
5.5.110.0040.00714.40
5.5.100.0000.01414.09
5.5.90.0060.00614.50
5.5.80.0000.00913.99
5.5.70.0070.00314.09
5.5.60.0000.01714.40
5.5.50.0000.01213.86
5.5.40.0000.01014.60
5.5.30.0040.00414.09
5.5.20.0040.00714.08
5.5.10.0000.01314.16
5.5.00.0030.01013.87

preferences:
63.65 ms | 400 KiB | 5 Q