3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface IErrorManager { public function ariseFatal($message); public function ariseWarning($message); public function ariseNotice($message); } interface ILexer { public function getTokens(); public function tokenize($input); } interface IParser { public function parse($input); } interface IParseResult { public function getDefintion(); public function getName(); public function getConstants(); } interface ICompiler { public function compile($input); } class ErrorManager implements IErrorManager { public function ariseFatal($message) { $this->triggerError($message, E_USER_FATAL); } public function ariseWarning($message) { $this->triggerError($message, E_USER_WARNING); } public function ariseNotice($message) { $this->triggerError($message, E_USER_NOTICE); } private function triggerError($message, $type) { trigger_error((string)$message, (int)$type); } } abstract class CompilerElement { private $errorManager; protected function getErrorManager() { return $this->errorManager; } protected function __construct(IErrorManager $errorManager) { $this->errorManager = $errorManager; } } class Lexer extends CompilerElement implements ILexer { private $tokens = array(); public function getTokens() { return $this->tokens; } public function tokenize($input) { if (!is_string($input)) { $this->getErrorManager()->ariseFatal(get_class($this).'::parse expects parameter 1 to be string. '.gettype($input).' given.'); } } public function __construct(IErrorManager $errorManager) { parent::__construct($errorManager); } } class Parser extends CompilerElement implements IParser { private $lexer; public function parse($input) { if (!is_string($input)) { $this->getErrorManager()->ariseFatal(get_class($this).'::parse expects parameter 1 to be string. '.gettype($input).' given.'); } } public function __construct(ILexer $lexer, IErrorManager $errorManager) { parent::__construct($errorManager); $this->lexer = $lexer; } } class ParseResult extends CompilerElement implements IParseResult { private $definition; private $name; private $constants; public function getDefinition() { return $this->definition; } public function getName() { return $this->name; } public function getConstants() { return $this->constants; } public function __construct($definition, $name, array $constants, IErrorManager $errorManager) { parent::__construct($errorManager); if (!is_string($definition)) { $this->getErrorManager()->ariseFatal(get_class($this).'::__construct expects parameter 1 to be string. '.gettype($definition).' given.'); } if (!is_string($name)) { $this->getErrorManager()->ariseFatal(get_class($this).'::__construct expects parameter 2 to be string. '.gettype($name).' given.'); } $this->definition = $definition; $this->name = $name; $this->constants = $constants; } } class Compiler implements ICompiler { private $parser; const INTENDATION_CHAR = "\t"; public function compile($input) { $parseResult = $this->parser->parse($input); $return = $parseResult->getDefinition().' '.$parseResult->getName().' {'.PHP_EOL; foreach ($parseResult->getConstants() as $name => $value) { $return .= Compiler::INTENDATION_CHAR.'const '.$name.' = '.$value.PHP_EOL; } $return .= Compiler::INTENDATION_CHAR.'private function __construct() {}'.PHP_EOL; $return .= '}'; return $return; } public function __construct(IParser $parser) { $this->parser = $parser; } } /*$enumCode =<<< PHP enum MyEnum { Item1, Item2, Item3 } PHP;*/

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.00716.60
8.3.50.0110.00917.45
8.3.40.0130.00318.71
8.3.30.0110.00318.54
8.3.20.0080.00018.83
8.3.10.0050.00318.83
8.3.00.0040.00419.13
8.2.180.0000.01516.75
8.2.170.0090.00922.96
8.2.160.0100.01020.46
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00420.89
8.2.110.0130.00320.43
8.2.100.0110.00017.78
8.2.90.0000.00819.23
8.2.80.0040.00419.32
8.2.70.0000.00817.36
8.2.60.0060.00317.80
8.2.50.0060.00319.35
8.2.40.0000.01018.16
8.2.30.0030.00618.04
8.2.20.0060.00317.71
8.2.10.0000.00717.64
8.2.00.0000.00717.74
8.1.280.0040.01125.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00921.93
8.1.230.0110.00020.87
8.1.220.0000.00818.77
8.1.210.0000.00818.79
8.1.200.0030.00917.25
8.1.190.0040.00417.53
8.1.180.0030.00518.10
8.1.170.0040.00418.72
8.1.160.0030.00618.84
8.1.150.0000.00718.60
8.1.140.0040.00417.40
8.1.130.0040.00417.81
8.1.120.0020.00517.36
8.1.110.0070.00017.46
8.1.100.0000.00717.35
8.1.90.0050.00317.35
8.1.80.0070.00017.48
8.1.70.0070.00017.43
8.1.60.0040.00417.59
8.1.50.0050.00317.34
8.1.40.0030.00617.49
8.1.30.0040.00417.57
8.1.20.0080.00017.52
8.1.10.0070.00017.40
8.1.00.0030.00617.34
8.0.300.0020.00619.98
8.0.290.0050.00316.88
8.0.280.0000.00718.45
8.0.270.0030.00517.19
8.0.260.0030.00316.75
8.0.250.0040.00417.01
8.0.240.0070.00016.93
8.0.230.0070.00016.88
8.0.220.0000.00716.84
8.0.210.0060.00316.86
8.0.200.0000.00816.89
8.0.190.0000.00717.06
8.0.180.0000.00716.98
8.0.170.0050.00316.89
8.0.160.0000.00716.95
8.0.150.0030.00616.77
8.0.140.0060.00316.90
8.0.130.0060.00013.36
8.0.120.0040.00416.78
8.0.110.0040.00416.78
8.0.100.0040.00416.75
8.0.90.0000.00716.84
8.0.80.0130.00416.90
8.0.70.0040.00416.80
8.0.60.0050.00316.92
8.0.50.0040.00416.91
8.0.30.0100.00717.09
8.0.20.0080.01416.85
8.0.10.0040.00417.18
8.0.00.0130.00916.87
7.4.330.0000.00513.04
7.4.320.0060.00016.57
7.4.300.0060.00016.42
7.4.290.0030.00616.39
7.4.280.0030.00316.51
7.4.270.0060.00316.50
7.4.260.0050.00013.28
7.4.250.0000.00816.46
7.4.240.0030.00316.60
7.4.230.0030.00316.48
7.4.220.0040.01416.59
7.4.210.0030.01116.59
7.4.200.0030.00316.62
7.4.190.0030.00316.49
7.4.160.0040.01216.65
7.4.150.0110.00916.39
7.4.140.0120.00516.51
7.4.130.0100.00816.47
7.4.120.0130.00516.32
7.4.110.0070.01616.57
7.4.100.0090.00916.45
7.4.90.0060.01116.50
7.4.80.0100.01316.28
7.4.70.0120.00416.46
7.4.60.0060.01016.42
7.4.50.0100.00216.37
7.4.40.0000.01116.55
7.4.30.0070.01016.57
7.4.00.0080.00914.93
7.3.330.0060.00013.38
7.3.320.0050.00313.16
7.3.310.0030.00316.39
7.3.300.0000.00716.37
7.3.290.0030.01316.28
7.3.280.0050.01016.33
7.3.270.0060.01116.40
7.3.260.0110.00616.28
7.3.250.0070.01516.41
7.3.240.0120.00616.31
7.3.230.0130.00316.39
7.3.210.0090.00616.39
7.3.200.0090.01219.39
7.3.190.0130.00416.58
7.3.180.0040.01216.43
7.3.170.0090.01516.38
7.3.160.0100.00616.25
7.3.120.0050.01314.73
7.3.110.0030.01614.99
7.3.100.0030.01314.81
7.3.90.0040.01114.82
7.3.80.0030.01114.86
7.3.70.0070.00314.59
7.3.60.0000.01214.78
7.3.50.0040.00914.75
7.3.40.0070.00714.77
7.3.30.0030.01014.73
7.3.20.0090.00016.57
7.3.10.0060.00316.53
7.3.00.0090.00616.61
7.2.330.0070.01116.64
7.2.320.0080.01116.73
7.2.310.0110.00616.43
7.2.300.0140.00416.34
7.2.290.0100.00616.54
7.2.250.0070.01114.92
7.2.240.0070.01415.16
7.2.230.0110.00714.84
7.2.220.0000.01415.02
7.2.210.0000.00915.13
7.2.200.0070.00714.91
7.2.190.0060.00614.91
7.2.180.0030.01214.71
7.2.170.0070.00314.76
7.2.60.0100.00016.74
7.2.00.0060.00919.41
7.1.330.0030.01015.61
7.1.320.0070.01015.57
7.1.310.0040.01015.39
7.1.300.0000.01115.63
7.1.290.0040.01115.63
7.1.280.0060.00315.50
7.1.270.0100.00715.52
7.1.260.0090.00915.54
7.1.200.0120.00815.56
7.1.100.0030.00917.87
7.1.70.0040.00717.03
7.1.60.0140.01019.40
7.1.50.0060.01616.95
7.1.00.0000.07322.51
7.0.200.0050.00514.73
7.0.140.0000.07722.02
7.0.120.0030.07322.06
7.0.60.0030.06720.10
7.0.50.0000.07017.94
7.0.40.0070.04320.36
7.0.30.0530.07020.08
7.0.20.0300.05320.20
7.0.10.0270.07720.24
7.0.00.0300.06720.20
5.6.280.0000.07720.86
5.6.210.0070.08320.71
5.6.200.0100.05318.21
5.6.190.0170.08020.68
5.6.180.0300.05020.62
5.6.170.0470.07020.54
5.6.160.0130.08020.51
5.6.150.0070.08318.20
5.6.140.0130.08018.31
5.6.130.0070.07718.21
5.6.120.0000.10321.02
5.6.110.0130.03721.05
5.6.100.0200.07321.03
5.6.90.0030.09020.93
5.6.80.0070.08020.49
5.6.70.0230.06320.46
5.5.350.0330.07320.52
5.5.340.0430.03718.02
5.5.330.0100.07020.28
5.5.320.0000.06020.43
5.5.310.0230.07020.34
5.5.300.0000.04318.07
5.5.290.0100.06017.98
5.5.280.0030.06720.86
5.5.270.0100.07320.90
5.5.260.0030.09020.92
5.5.250.0070.07320.66
5.5.240.0030.09020.24
5.4.450.0070.08019.48
5.4.440.0100.06319.18
5.4.430.0030.04019.47
5.4.420.0000.07319.56
5.4.410.0070.08019.34
5.4.400.0070.03719.12
5.4.390.0130.07318.98
5.4.380.0070.04719.00
5.4.370.0100.05719.20
5.4.360.0100.05018.87
5.4.350.0070.04719.07
5.4.340.0100.03718.86
5.4.320.0070.06019.15
5.4.310.0030.07019.02
5.4.300.0100.07018.85
5.4.290.0000.08019.00
5.4.280.0000.08719.24
5.4.270.0100.03019.20
5.4.260.0100.07019.25
5.4.250.0030.06719.13
5.4.240.0100.06019.14
5.4.230.0070.06319.24
5.4.220.0070.05018.84
5.4.210.0100.07319.09
5.4.200.0130.03019.24
5.4.190.0100.03319.19
5.4.180.0100.05319.13
5.4.170.0100.07718.84
5.4.160.0070.08018.83
5.4.150.0100.08019.22
5.4.140.0170.06016.47
5.4.130.0100.04016.34
5.4.120.0070.03316.38
5.4.110.0100.03316.35
5.4.100.0070.06016.43
5.4.90.0070.04716.46
5.4.80.0130.03716.42
5.4.70.0070.06316.37
5.4.60.0030.07716.52
5.4.50.0100.05016.30
5.4.40.0100.06716.43
5.4.30.0130.07016.70
5.4.20.0170.06016.69
5.4.10.0000.05316.45
5.4.00.0000.04715.87
5.3.290.0070.04714.74
5.3.280.0030.06014.57
5.3.270.0130.05714.82
5.3.260.0100.05714.67
5.3.250.0030.05014.71
5.3.240.0100.07014.82
5.3.230.0000.04714.66
5.3.220.0070.04014.79
5.3.210.0170.07014.64
5.3.200.0000.04714.68
5.3.190.0100.03314.64
5.3.180.0030.03714.64
5.3.170.0030.07714.65
5.3.160.0000.07014.66
5.3.150.0070.05714.65
5.3.140.0070.05314.79
5.3.130.0070.05714.63
5.3.120.0170.05714.75
5.3.110.0100.04014.77
5.3.100.0000.04014.13
5.3.90.0030.03714.12
5.3.80.0070.05014.22
5.3.70.0030.04313.96
5.3.60.0070.06714.06
5.3.50.0070.03314.04
5.3.40.0030.04313.93
5.3.30.0030.04314.00
5.3.20.0100.03713.78
5.3.10.0030.04713.79
5.3.00.0070.07713.85
5.2.170.0100.05711.29
5.2.160.0000.06011.27
5.2.150.0070.07311.38
5.2.140.0030.05311.26
5.2.130.0030.03011.23
5.2.120.0100.05711.18
5.2.110.0030.04011.14
5.2.100.0070.04711.22
5.2.90.0130.05311.18
5.2.80.0100.06011.24
5.2.70.0030.03011.18
5.2.60.0000.05311.07
5.2.50.0030.04311.09
5.2.40.0070.04311.14
5.2.30.0030.04311.18
5.2.20.0100.04711.07
5.2.10.0070.05311.11
5.2.00.0070.04310.84
5.1.60.0100.03310.07
5.1.50.0030.02710.03
5.1.40.0100.04010.01
5.1.30.0000.04310.48
5.1.20.0030.04010.44
5.1.10.0070.02710.17
5.1.00.0100.03310.16
5.0.50.0030.0478.57
5.0.40.0030.0408.38
5.0.30.0030.0408.35
5.0.20.0000.0308.30
5.0.10.0000.0308.16
5.0.00.0070.0408.22
4.4.90.0000.0177.91
4.4.80.0070.0277.91
4.4.70.0000.0177.91
4.4.60.0030.0137.91
4.4.50.0000.0377.91
4.4.40.0030.0237.91
4.4.30.0000.0207.91
4.4.20.0070.0137.91
4.4.10.0030.0207.91
4.4.00.0030.0577.91
4.3.110.0000.0237.91
4.3.100.0070.0107.91
4.3.90.0100.0177.91
4.3.80.0070.0237.91
4.3.70.0030.0137.91
4.3.60.0030.0177.91
4.3.50.0000.0207.91
4.3.40.0000.0277.91
4.3.30.0030.0337.91
4.3.20.0000.0337.91
4.3.10.0000.0377.91
4.3.00.0030.0337.91

preferences:
44.26 ms | 401 KiB | 5 Q