3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tokenStream = []; // [tokenName, lexeme] pairs $input = <<<'end' $a = 3; // variable initialisation end; // Pre PHP 7 code preg_replace_callback( [ '~\$[a-z_][a-z\d_]*~i', '~=~', '~[\d]+~', '~;~', '~//.*~' ], function ($match) use (&$tokenStream) { if (strpos($match[0], '$') === 0) { $tokenStream[] = ['T_VARIABLE', $match[0]]; } elseif (strpos($match[0], '=') === 0) { $tokenStream[] = ['T_ASSIGN', $match[0]]; } elseif (ctype_digit($match[0])) { $tokenStream[] = ['T_NUM', $match[0]]; } elseif (strpos($match[0], ';') === 0) { $tokenStream[] = ['T_TERMINATE_STMT', $match[0]]; } elseif (strpos($match[0], '//') === 0) { $tokenStream[] = ['T_COMMENT', $match[0]]; } }, $input ); // PHP 7+ code preg_replace_callback_array( [ '~\$[a-z_][a-z\d_]*~i' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_VARIABLE', $match[0]]; }, '~=~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_ASSIGN', $match[0]]; }, '~[\d]+~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_NUM', $match[0]]; }, '~;~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_TERMINATE_STMT', $match[0]]; }, '~//.*~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_COMMENT', $match[0]]; } ], $input );

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.0060.00918.43
8.3.50.0150.00321.24
8.3.40.0000.01619.08
8.3.30.0090.00618.96
8.3.20.0040.00420.39
8.3.10.0040.00421.90
8.3.00.0060.00318.00
8.2.180.0090.00618.48
8.2.170.0120.00322.96
8.2.160.0070.00720.52
8.2.150.0000.00924.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0100.00017.75
8.2.110.0000.00920.39
8.2.100.0080.00417.91
8.2.90.0040.00419.17
8.2.80.0040.00417.97
8.2.70.0040.00417.88
8.2.60.0080.00018.05
8.2.50.0050.00318.07
8.2.40.0120.00018.99
8.2.30.0040.00420.74
8.2.20.0030.00617.80
8.2.10.0000.00718.23
8.2.00.0050.00218.09
8.1.280.0040.01125.92
8.1.270.0090.00921.94
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00323.77
8.1.230.0040.00722.70
8.1.220.0040.00417.79
8.1.210.0090.00018.77
8.1.200.0030.00717.48
8.1.190.0000.00817.48
8.1.180.0050.00318.10
8.1.170.0000.00918.71
8.1.160.0040.00422.07
8.1.150.0040.00418.90
8.1.140.0050.00317.63
8.1.130.0040.00417.67
8.1.120.0000.00717.64
8.1.110.0000.00717.54
8.1.100.0040.00417.54
8.1.90.0040.00717.53
8.1.80.0040.00417.66
8.1.70.0030.00317.52
8.1.60.0080.00017.74
8.1.50.0060.00317.74
8.1.40.0040.00417.68
8.1.30.0030.00517.87
8.1.20.0000.00717.74
8.1.10.0060.00317.77
8.1.00.0040.00417.58
8.0.300.0080.00018.77
8.0.290.0000.00717.00
8.0.280.0040.00418.54
8.0.270.0040.00417.31
8.0.260.0030.00317.34
8.0.250.0040.00417.11
8.0.240.0070.00017.06
8.0.230.0080.00017.09
8.0.220.0000.00717.10
8.0.210.0050.00217.16
8.0.200.0000.00917.15
8.0.190.0060.00317.20
8.0.180.0030.00517.08
8.0.170.0030.00517.20
8.0.160.0000.00717.12
8.0.150.0000.00717.03
8.0.140.0040.00416.98
8.0.130.0030.00313.59
8.0.120.0030.00517.15
8.0.110.0000.00717.16
8.0.100.0040.00417.20
8.0.90.0040.00417.09
8.0.80.0100.01017.10
8.0.70.0000.00717.04
8.0.60.0040.00417.25
8.0.50.0040.00417.09
8.0.30.0070.00917.39
8.0.20.0120.00617.40
8.0.10.0070.00017.38
8.0.00.0070.01117.06
7.4.330.0060.00015.11
7.4.320.0050.00216.84
7.4.300.0030.00316.82
7.4.290.0030.00316.78
7.4.280.0030.00616.83
7.4.270.0000.00716.67
7.4.260.0030.00616.70
7.4.250.0040.00416.71
7.4.240.0050.00316.71
7.4.230.0070.00016.88
7.4.220.0150.01216.68
7.4.210.0070.01416.70
7.4.200.0070.00016.86
7.4.160.0130.00316.48
7.4.150.0140.00417.40
7.4.140.0100.01317.86
7.4.130.0120.00716.82
7.4.120.0110.00816.75
7.4.110.0080.00816.83
7.4.100.0110.00616.67
7.4.90.0040.01516.66
7.4.80.0070.01519.39
7.4.70.0100.00716.73
7.4.60.0070.01016.70
7.4.50.0040.00416.89
7.4.40.0000.01616.68
7.4.30.0030.01516.76
7.4.00.0030.01215.30
7.3.330.0030.00613.44
7.3.320.0030.00313.59
7.3.310.0030.00316.66
7.3.300.0070.00016.45
7.3.290.0080.00816.53
7.3.280.0100.00816.55
7.3.270.0030.01417.40
7.3.260.0170.00716.66
7.3.250.0140.00416.61
7.3.240.0120.00616.70
7.3.230.0090.00916.75
7.3.210.0130.01016.72
7.3.200.0030.01316.55
7.3.190.0030.01416.50
7.3.180.0040.01216.66
7.3.170.0140.00816.63
7.3.160.0110.00716.71
7.3.120.0070.01014.97
7.3.110.0060.00915.12
7.3.100.0040.01114.88
7.3.90.0030.00915.09
7.3.80.0070.01015.03
7.3.70.0040.01214.86
7.3.60.0080.00814.82
7.3.50.0090.00614.98
7.3.40.0060.00915.16
7.3.30.0090.00614.81
7.3.20.0040.01016.94
7.3.10.0120.00416.77
7.3.00.0110.00417.09
7.2.330.0120.00616.79
7.2.320.0170.01816.73
7.2.310.0040.01316.82
7.2.300.0070.01016.99
7.2.290.0060.01116.76
7.2.240.0040.01215.07
7.2.230.0030.01315.23
7.2.220.0000.01815.37
7.2.210.0110.00715.27
7.2.200.0080.00415.48
7.2.190.0030.01315.27
7.2.180.0090.00615.36
7.2.170.0070.01015.08
7.2.160.0070.00715.17
7.2.150.0060.00917.16
7.2.140.0040.01116.95
7.2.130.0040.01116.89
7.2.120.0100.00716.97
7.2.110.0030.01016.86
7.2.100.0110.00516.76
7.2.90.0090.00916.80
7.2.80.0100.00517.04
7.2.70.0130.00516.85
7.2.60.0060.00817.10
7.2.50.0080.00717.18
7.2.40.0090.00817.09
7.2.30.0080.00717.08
7.2.20.0100.00617.21
7.2.10.0060.00817.19
7.2.00.0020.01117.95
7.1.330.0140.00015.80
7.1.320.0030.01316.15
7.1.310.0080.00815.98
7.1.300.0030.00915.97
7.1.290.0090.00315.74
7.1.280.0120.00315.90
7.1.270.0040.00816.08
7.1.260.0000.01615.96
7.1.250.0050.00516.13
7.1.240.0120.00315.85
7.1.230.0000.01215.93
7.1.220.0090.00915.73
7.1.210.0170.00015.95
7.1.200.0100.00416.05
7.1.190.0110.00415.93
7.1.180.0080.01015.88
7.1.170.0160.00315.99
7.1.160.0090.00615.75
7.1.150.0130.00315.91
7.1.140.0120.00316.12
7.1.130.0080.00715.84
7.1.120.0040.00816.05
7.1.110.0040.00815.73
7.1.100.0060.00817.20
7.1.90.0100.00516.14
7.1.80.0060.00915.95
7.1.70.0050.00616.69
7.1.60.0050.00917.62
7.1.50.0120.00916.54
7.1.40.0080.00815.68
7.1.30.0100.00715.81
7.1.20.0120.00315.99
7.1.10.0070.00715.95
7.1.00.0080.03819.10
7.0.320.0090.00515.36
7.0.310.0030.00915.21
7.0.300.0120.00015.61
7.0.290.0140.00315.42
7.0.280.0090.00415.54
7.0.270.0130.00415.46
7.0.260.0120.00315.39
7.0.250.0120.00915.36
7.0.240.0090.00615.50
7.0.230.0180.00415.74
7.0.220.0090.00715.67
7.0.210.0130.00415.62
7.0.200.0100.00816.25
7.0.190.0040.00815.71
7.0.180.0120.00715.64
7.0.170.0130.00415.70
7.0.160.0120.00615.39
7.0.150.0070.00515.47
7.0.140.0070.00815.56
7.0.130.0100.00315.26
7.0.120.0120.00215.78
7.0.110.0120.00415.37
7.0.100.0030.01315.74
7.0.90.0040.01415.19
7.0.80.0080.01115.59
7.0.70.0130.00515.63
7.0.60.0070.02017.60
7.0.50.0090.03716.80
7.0.40.0040.03116.92
7.0.30.0320.04016.79
7.0.20.0220.03816.85
7.0.10.0080.04716.93
7.0.00.0060.02516.89
5.6.380.0050.01014.48
5.6.370.0090.00914.45
5.6.360.0060.01214.28
5.6.350.0070.01114.43
5.6.340.0120.00614.67
5.6.330.0070.00714.48
5.6.320.0100.00714.55
5.6.310.0050.01014.42
5.6.300.0140.00614.17
5.6.290.0110.00614.68
5.6.280.0060.01717.64
5.6.270.0070.00714.29
5.6.260.0100.01014.67
5.6.250.0150.00014.42
5.6.240.0140.00314.58
5.6.230.0090.00914.50
5.6.220.0160.00014.47
5.6.210.0030.04817.42
5.6.200.0080.02316.44
5.6.190.0030.03817.71
5.6.180.0160.04217.51
5.6.170.0220.04117.43
5.6.160.0110.02917.59
5.6.150.0040.02916.31
5.6.140.0090.03316.21
5.6.130.0140.03816.48
5.6.120.0120.03717.78
5.6.110.0130.04117.73
5.6.100.0110.04417.70
5.6.90.0070.04417.80
5.6.80.0140.03717.21
5.6.70.0120.00614.41
5.6.60.0110.00814.23
5.6.50.0140.00314.10
5.6.40.0060.00614.26
5.6.30.0170.00014.34
5.6.20.0130.00314.25
5.6.10.0110.00714.32
5.6.00.0180.00014.44
5.5.380.0060.00611.27
5.5.370.0090.00311.50
5.5.360.0080.00311.27
5.5.350.0070.04215.95
5.5.340.0090.03514.69
5.5.330.0050.02515.85
5.5.320.0080.04415.87
5.5.310.0220.03715.92
5.5.300.0120.03814.69
5.5.290.0080.02314.61
5.5.280.0070.03916.10
5.5.270.0050.03816.13
5.5.260.0090.03516.08
5.5.250.0100.03815.90
5.5.240.0190.03515.74
5.5.230.0070.00511.27
5.5.220.0060.00611.32
5.5.210.0110.00311.27
5.5.200.0070.00311.28
5.5.190.0130.00011.34
5.5.180.0050.00711.27
5.5.170.0060.00814.62
5.5.160.0030.00611.27
5.5.150.0100.00311.32
5.5.140.0110.00411.29
5.5.130.0070.00711.45
5.5.120.0110.00311.48
5.5.110.0090.00311.29
5.5.100.0110.00411.27
5.5.90.0080.00811.27
5.5.80.0110.00411.27
5.5.70.0060.00611.30
5.5.60.0050.00811.27
5.5.50.0000.01311.41
5.5.40.0080.00611.27
5.5.30.0110.00411.27
5.5.20.0080.00411.36
5.5.10.0060.00711.27
5.5.00.0120.00211.27
5.4.450.0200.02915.43
5.4.440.0110.03515.44
5.4.430.0160.04215.41
5.4.420.0170.02515.48
5.4.410.0150.03215.41
5.4.400.0210.03115.32
5.4.390.0150.03015.05
5.4.380.0150.02715.25
5.4.370.0150.02815.26
5.4.360.0130.03015.32
5.4.350.0160.03115.16
5.4.340.0170.02815.19
5.4.330.0110.00011.44
5.4.320.0200.02515.27
5.4.310.0150.02715.14
5.4.300.0170.02515.19
5.4.290.0110.03315.26
5.4.280.0160.02715.11
5.4.270.0180.02815.27
5.4.260.0150.03515.28
5.4.250.0170.02615.25
5.4.240.0150.02615.26
5.4.230.0180.02515.12
5.4.220.0070.03415.26
5.4.210.0190.02715.28
5.4.200.0140.02615.30
5.4.190.0180.03015.20
5.4.180.0150.02715.10
5.4.170.0110.03115.14
5.4.160.0080.03115.11
5.4.150.0180.02615.19
5.4.140.0140.02613.87
5.4.130.0130.02813.90
5.4.120.0070.03213.85
5.4.110.0150.02313.97
5.4.100.0140.02513.90
5.4.90.0100.03414.05
5.4.80.0140.02713.96
5.4.70.0060.01813.84
5.4.60.0080.03313.92
5.4.50.0050.02013.89
5.4.40.0150.02713.92
5.4.30.0140.02113.90
5.4.20.0190.03613.81
5.4.10.0090.00011.27
5.4.00.0100.00311.27

preferences:
46.11 ms | 401 KiB | 5 Q