3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ILexer { /** * return associative array containing tokens for parser * @param string $input code to tokenize * @return array */ public function tokenize($input); } interface INameValidator { /** * Checks if name is valid. In a case of failure trigger syntax error. * @param string $name * @return void */ public function validate($name); } interface IParser { /** * Sets array of keywords. * @param array $keywords associative array where key is keyword and value respective php instruction. * @return void */ public function setKeywords(array $keywords); /** * Parses code. Checks for syntax errors. * If no error occurs returns data for compiler to assemble php class * otherwise trigger syntax error. * @param string $input code to parse. * @return array IParserResult */ public function parse($input); } interface IParseResult { public function getDefinition(); public function getName(); public function getConstants(); } //I know this lexer sucks. class Lexer extends CompilerElement implements ILexer { // Potential hidden dependency private $specialChars = array( '{' => 'start_body', '}' => 'end_body' ); public function tokenize($input) { if (!is_string($input)) { $this->getErrorManager()->ariseFatal(get_class($this).'::parse expects parameter 1 to be string. '.gettype($input).' given.'); } $tokens = array(); $token = $this->getEmptyToken(); $tokenMetadata = $this->getDefaultTokenMetadata(); $inputLength = strlen($input); for ($i = 0; $i < $inputLength; $i++) { $current = $input[$i]; //check if special character if (isset($this->specialChars[$current])) { $token[$this->specialChars[$current]] = $current; if ($i !== $inputLength - 1) continue; } if (isset($token['end_body'])) { $tokens[] = $token; $token = $this->getEmptyToken(); $tokenMetadata = $this->getDefaultTokenMetadata(); if ($i === $inputLength - 1) continue; } $isWhitespace = ctype_space($current); if (isset($token['start_body'])) { //skip if whitespace if ($isWhitespace) { continue; } if ($current === ',') { $tokenMetadata['newItem'] = true; $tokenMetadata['newItemNameResolved'] = false; continue; } if ($current === '=') { $tokenMetadata['newItemNameResolved'] = true; continue; } if ($tokenMetadata['newItem']) { $token['e_'.$current] = null; $tokenMetadata['newItem'] = false; } else { end($token); $lastKey = key($token); if (!$tokenMetadata['newItemNameResolved']) { unset($token[$lastKey]); $token[$lastKey.$current] = null; } else { $token[$lastKey] .= $current; } } continue; } if (!$tokenMetadata['typeResolved']) { if ($isWhitespace) { if (strlen($token['type']) === 0) { continue; } else { $tokenMetadata['typeResolved'] = true; } } else { $token['type'] .= $current; } } else if (!$tokenMetadata['nameResolved']) { if ($isWhitespace) { if (strlen($token['name']) === 0) { continue; } else { $tokenMetadata['nameResolved'] = true; } } else { $token['name'] .= $current; } } } return $tokens; } private function getEmptyToken() { return array( 'type' => '', 'name' => '' ); } private function getDefaultTokenMetadata() { return array( 'typeResolved' => false, 'nameResolved' => false, 'newItem' => true, 'newItemNameResolved' => false ); } public function __construct(IErrorManager $errorManager) { parent::__construct($errorManager); } }

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.0110.00417.00
8.3.50.0140.00317.54
8.3.40.0100.00718.79
8.3.30.0120.00318.58
8.3.20.0040.00418.95
8.3.10.0030.00618.82
8.3.00.0100.00019.17
8.2.180.0140.00717.00
8.2.170.0070.00722.96
8.2.160.0080.00818.73
8.2.150.0000.00924.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0070.00021.13
8.2.110.0130.00620.38
8.2.100.0120.00017.72
8.2.90.0000.00817.75
8.2.80.0030.00618.73
8.2.70.0040.00417.75
8.2.60.0050.00318.03
8.2.50.0060.00317.93
8.2.40.0000.00819.48
8.2.30.0030.00717.80
8.2.20.0080.00317.80
8.2.10.0000.00817.69
8.2.00.0110.00017.85
8.1.280.0070.00725.92
8.1.270.0050.00323.99
8.1.260.0070.00026.35
8.1.250.0000.00728.09
8.1.240.0030.00622.11
8.1.230.0040.00817.71
8.1.220.0080.00017.74
8.1.210.0070.00318.77
8.1.200.0000.00817.35
8.1.190.0040.00417.10
8.1.180.0050.00518.10
8.1.170.0000.00817.62
8.1.160.0030.00319.04
8.1.150.0040.00418.51
8.1.140.0040.00417.44
8.1.130.0000.00817.34
8.1.120.0000.00817.36
8.1.110.0000.00817.36
8.1.100.0040.00417.43
8.1.90.0000.00717.33
8.1.80.0070.00017.39
8.1.70.0030.00317.43
8.1.60.0000.00817.49
8.1.50.0000.00717.48
8.1.40.0080.00017.43
8.1.30.0040.00417.63
8.1.20.0080.00017.68
8.1.10.0000.00717.45
8.1.00.0050.00317.45
8.0.300.0040.00418.77
8.0.290.0040.00417.00
8.0.280.0000.00718.59
8.0.270.0030.00317.16
8.0.260.0030.00318.36
8.0.250.0000.00816.96
8.0.240.0000.00717.05
8.0.230.0100.00017.03
8.0.220.0040.00417.00
8.0.210.0050.00216.84
8.0.200.0040.00417.05
8.0.190.0070.00016.91
8.0.180.0060.00317.01
8.0.170.0080.00017.04
8.0.160.0050.00316.92
8.0.150.0050.00316.77
8.0.140.0040.00416.98
8.0.130.0060.00013.39
8.0.120.0050.00516.85
8.0.110.0040.00416.95
8.0.100.0050.00316.90
8.0.90.0040.00416.84
8.0.80.0060.00916.98
8.0.70.0020.00516.99
8.0.60.0040.00416.94
8.0.50.0000.00816.96
8.0.30.0060.01317.20
8.0.20.0160.00817.19
8.0.10.0040.00417.10
8.0.00.0120.01016.74
7.4.330.0050.00012.94
7.4.320.0060.00016.48
7.4.300.0040.00416.67
7.4.290.0030.00616.57
7.4.280.0040.00416.54
7.4.270.0000.00716.42
7.4.260.0000.00513.29
7.4.250.0000.00916.58
7.4.240.0040.00316.42
7.4.230.0020.00516.57
7.4.220.0110.00716.48
7.4.210.0050.00816.52
7.4.200.0030.00416.48
7.4.190.0080.00016.67
7.4.160.0130.00316.43
7.4.150.0150.00616.43
7.4.140.0090.01617.86
7.4.130.0140.00616.55
7.4.120.0090.01216.50
7.4.110.0100.01316.46
7.4.100.0140.00716.52
7.4.90.0080.00816.42
7.4.80.0120.00619.39
7.4.70.0190.00016.38
7.4.60.0030.01516.50
7.4.50.0060.00316.42
7.4.40.0050.01316.65
7.4.30.0110.00516.57
7.4.00.0060.01015.21
7.3.330.0000.00613.09
7.3.320.0060.00013.31
7.3.310.0000.00716.35
7.3.300.0000.00716.36
7.3.290.0040.01116.34
7.3.280.0090.00616.35
7.3.270.0140.00416.47
7.3.260.0110.01116.23
7.3.240.0100.00716.67
7.3.230.0060.01216.50
7.3.210.0030.01316.53
7.3.200.0060.01016.43
7.3.190.0110.00516.34
7.3.180.0090.01216.49
7.3.170.0030.01416.52
7.3.160.0030.01316.36
7.3.120.0100.00314.77
7.2.330.0130.00616.27
7.2.320.0100.00716.47
7.2.310.0090.00916.44
7.2.300.0120.00416.50
7.2.290.0030.01416.63
7.2.60.0110.00416.34
7.2.00.0060.00619.31
7.1.200.0100.00315.52
7.1.100.0320.00417.84
7.1.70.0040.00716.97
7.1.60.0120.01219.25
7.1.50.0030.01916.85
7.1.00.0100.02722.30
7.0.200.0070.00416.41
7.0.140.0030.07722.11
7.0.120.0070.07322.05
7.0.60.0030.08720.08
7.0.50.0030.08318.00
7.0.40.0100.07720.11
7.0.30.0270.03320.07
7.0.20.0300.06320.07
7.0.10.0000.06320.21
7.0.00.0130.05320.08
5.6.280.0030.07021.05
5.6.210.0100.08320.75
5.6.200.0030.06018.22
5.6.190.0070.07020.47
5.6.180.0170.08020.50
5.6.170.0170.04020.55
5.6.160.0070.05020.55
5.6.150.0100.04018.23
5.6.140.0030.06018.28
5.6.130.0100.08318.31
5.6.120.0130.08021.15
5.6.110.0130.08021.06
5.6.100.0170.03721.02
5.6.90.0100.08021.01
5.6.80.0100.08020.41
5.5.350.0000.06720.50
5.5.340.0070.07017.96
5.5.330.0030.04720.27
5.5.320.0430.04320.32
5.5.310.0130.04320.20
5.5.300.0070.04317.93
5.5.290.0000.05317.99
5.5.280.0130.07720.77
5.5.270.0070.04020.90
5.5.260.0130.05020.86
5.5.250.0230.03720.71
5.5.240.0000.08020.29
5.4.450.0270.06319.44
5.4.440.0270.05319.57
5.4.430.0370.06319.64
5.4.420.0230.05719.19
5.4.410.0230.06019.04
5.4.400.0330.05319.22
5.4.390.0230.06719.22
5.4.380.0300.06319.24
5.4.370.0170.07719.23
5.4.360.0170.05319.24
5.4.350.0230.03719.33
5.4.340.0200.06719.22
5.4.320.0200.04019.20
5.4.310.0170.03719.16
5.4.300.0170.03718.94
5.4.290.0270.03718.85
5.4.280.0130.04018.98
5.4.270.0200.03718.85
5.4.260.0230.03719.31
5.4.250.0170.03719.11
5.4.240.0270.03319.07
5.4.230.0200.04319.15
5.4.220.0270.03019.30
5.4.210.0300.04019.05
5.4.200.0170.04319.21
5.4.190.0130.04019.05
5.4.180.0130.04018.85
5.4.170.0100.04319.07
5.4.160.0170.03719.07
5.4.150.0170.03719.06
5.4.140.0200.03716.43
5.4.130.0170.04016.55
5.4.120.0200.05716.71
5.4.110.0130.07316.51
5.4.100.0170.06316.50
5.4.90.0130.03716.32
5.4.80.0130.03716.44
5.4.70.0230.06016.31
5.4.60.0270.02716.29
5.4.50.0300.05016.58
5.4.40.0130.03716.54
5.4.30.0230.07716.55
5.4.20.0330.04716.45
5.4.10.0230.05316.48
5.4.00.0230.06315.82
5.3.290.0230.03314.81
5.3.280.0170.04314.71
5.3.270.0100.05014.66
5.3.260.0200.04014.64
5.3.250.0130.04714.63
5.3.240.0230.02714.71
5.3.230.0200.03714.79
5.3.220.0200.03714.57
5.3.210.0170.04314.53
5.3.200.0170.04314.61
5.3.190.0200.03314.71
5.3.180.0170.04014.59
5.3.170.0170.04314.62
5.3.160.0200.03714.67
5.3.150.0200.03314.60
5.3.140.0130.07014.50
5.3.130.0270.05714.66
5.3.120.0300.07014.67
5.3.110.0270.07014.50
5.3.100.0170.04714.00
5.3.90.0170.04014.21
5.3.80.0230.06714.08
5.3.70.0400.06013.93
5.3.60.0200.06313.95
5.3.50.0230.06013.89
5.3.40.0270.06313.89
5.3.30.0270.04013.95
5.3.20.0230.04013.80
5.3.10.0200.06013.73
5.3.00.0130.04713.60
5.2.170.0100.03313.02
5.2.160.0170.05013.02
5.2.150.0200.02713.02
5.2.140.0200.02713.02
5.2.130.0130.03013.02
5.2.120.0200.06013.02
5.2.110.0200.02713.02
5.2.100.0230.05713.02
5.2.90.0130.03713.02
5.2.80.0200.06013.02
5.2.70.0100.03313.02
5.2.60.0130.03713.02
5.2.50.0170.04013.02
5.2.40.0170.02313.02
5.2.30.0130.04313.02
5.2.20.0170.04013.02
5.2.10.0130.06013.02
5.2.00.0330.04713.02
5.1.60.0170.05313.02
5.1.50.0170.05313.02
5.1.40.0130.04013.02
5.1.30.0230.05713.02
5.1.20.0200.05313.02
5.1.10.0200.04713.02
5.1.00.0130.03313.02
5.0.50.0070.04713.02
5.0.40.0230.03313.02
5.0.30.0130.06013.02
5.0.20.0170.03013.02
5.0.10.0070.02013.02
5.0.00.0030.04013.02
4.4.90.0070.02313.02
4.4.80.0030.03713.02
4.4.70.0030.02313.02
4.4.60.0070.03713.02
4.4.50.0100.03013.02
4.4.40.0100.04713.02
4.4.30.0100.03713.02
4.4.20.0100.02013.02
4.4.10.0170.03013.02
4.4.00.0100.04713.02
4.3.110.0070.03013.02
4.3.100.0030.03713.02
4.3.90.0100.03313.02
4.3.80.0070.03013.02
4.3.70.0100.01313.02
4.3.60.0030.01713.02
4.3.50.0130.02313.02
4.3.40.0030.02713.02
4.3.30.0030.03713.02
4.3.20.0070.02713.02
4.3.10.0000.02013.02
4.3.00.0030.01713.02

preferences:
37.7 ms | 401 KiB | 5 Q