3v4l.org

run code in 300+ PHP versions simultaneously
<?php //source: https://dzone.com/articles/simple-example-illustrates //FIX-ME !!!!!!!!!!!!! class Parser { private $successor; public function __construct(Parser $successor) { $this->setSuccessor($successor); } public function parse(string $fileName): void { if ($this->getSuccessor() != null) { $this->getSuccessor()->parse($fileName); } else { echo "Unable to find the correct parser for the file:" . $fileName . PHP_EOL; } } protected function canHandleFile(string $fileName, string $format): bool { $spl = new SplFileInfo($fileName); return ($fileName == null) || ($spl->getExtension() == $format); } public function getSuccessor(): ?Parser { return $this->successor; } public function setSuccessor(Parser $successor): void { $this->successor = $successor; } } class TextParser extends Parser { public function parse(string $fileName): void { if ($this->canHandleFile($fileName, "txt")) { echo("A text parser is handling the file: " . $fileName . PHP_EOL); } else { parent::parse($fileName); } } } class JsonParser extends Parser { public function parse(string $fileName): void { if ($this->canHandleFile($fileName, "json")) { echo("A JSON parser is handling the file: " . $fileName . PHP_EOL); } else { parent::parse($fileName); } } } class CSVParser extends Parser { public function parse(string $fileName): void { if ($this->canHandleFile($fileName, "json")) { echo("A CSV parser is handling the file: " + $fileName . PHP_EOL); } else { parent::parse($fileName); } } } class XMLParser extends Parser { public function __construct() { return; } public function parse(string $fileName): void { if ($this->canHandleFile($fileName, "json")) { echo("A XML parser is handling the file: " + $fileName . PHP_EOL); } else { parent::parse($fileName); } } } //List of file names to parse. $fileList = ["someFile.txt", "otherFile.json", "xmlFile.xml", "csvFile.csv", "csvFile.doc"]; //No successor for this handler because this is the last in chain. $xmlParser = new XmlParser(); //XmlParser is the successor of CsvParser. $csvParser = new CsvParser($xmlParser); //CsvParser is the successor of JsonParser. $jsonParser = new JsonParser($csvParser); //JsonParser is the successor of TextParser. //TextParser is the start of the chain. $textParser = new TextParser($jsonParser); //Pass the file name to the first handler in the chain. foreach ($fileList as $key => $fileName) { $textParser->parse($fileName); }

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.5.00.0110.01019.79
8.4.150.0020.00014.05
8.4.140.0110.01317.84
8.4.130.0130.00817.65
8.4.120.0110.00920.63
8.4.110.0130.00622.54
8.4.100.0100.01118.38
8.4.90.0130.00818.52
8.4.80.0070.01019.61
8.4.70.0110.00918.23
8.4.60.0100.01118.94
8.4.50.0150.00520.34
8.4.40.0120.00919.29
8.4.30.0070.01420.52
8.4.20.0100.01019.05
8.4.10.0060.01019.55
8.3.280.0120.00918.55
8.3.270.0070.01416.73
8.3.260.0120.00816.72
8.3.250.0120.00918.79
8.3.240.0070.00816.77
8.3.230.0120.00416.75
8.3.220.0100.00917.14
8.3.210.0140.00516.65
8.3.200.0050.00416.93
8.3.190.0120.00717.23
8.3.180.0070.00316.61
8.3.170.0070.01117.16
8.3.160.0060.01218.36
8.3.150.0080.00016.69
8.3.140.0040.00417.26
8.3.130.0050.00318.57
8.3.120.0160.00316.46
8.3.110.0030.00516.63
8.3.100.0050.00318.46
8.3.90.0060.00326.77
8.3.80.0090.00016.63
8.3.70.0060.01216.63
8.3.60.0130.00618.30
8.3.50.0110.00716.66
8.3.40.0090.00618.85
8.3.30.0080.00818.37
8.3.20.0040.00422.39
8.3.10.0000.00818.95
8.3.00.0000.00821.77
8.2.290.0100.00820.50
8.2.280.0040.00418.51
8.2.270.0170.00317.23
8.2.260.0080.00816.64
8.2.250.0140.00718.28
8.2.240.0070.00017.10
8.2.230.0040.00420.94
8.2.220.0060.00324.06
8.2.210.0040.00426.77
8.2.200.0040.00416.50
8.2.190.0150.00316.75
8.2.180.0140.00325.92
8.2.170.0070.00722.96
8.2.160.0030.01020.35
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0050.00226.16
8.2.120.0030.00626.16
8.2.110.0030.00619.41
8.2.100.0000.01217.72
8.2.90.0000.00818.21
8.2.80.0080.00017.97
8.2.70.0030.00617.80
8.2.60.0040.00418.16
8.2.50.0070.00019.25
8.2.40.0040.00419.19
8.2.30.0080.00019.08
8.2.20.0030.00518.00
8.2.10.0000.00718.71
8.2.00.0070.00019.26
8.1.330.0100.00921.71
8.1.320.0120.00816.31
8.1.310.0080.00818.19
8.1.300.0060.00317.81
8.1.290.0050.00530.84
8.1.280.0120.00625.92
8.1.270.0050.00322.40
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00622.06
8.1.230.0110.00020.97
8.1.220.0000.00917.74
8.1.210.0000.00818.77
8.1.200.0030.00617.23
8.1.190.0050.00317.10
8.1.180.0000.00818.10
8.1.170.0000.00818.66
8.1.160.0000.00718.84
8.1.150.0020.00518.72
8.1.140.0030.00320.28
8.1.130.0030.00320.13
8.1.120.0060.00317.47
8.1.110.0040.00417.39
8.1.100.0030.00617.45
8.1.90.0030.00617.41
8.1.80.0040.00417.46
8.1.70.0020.00517.25
8.1.60.0080.00017.52
8.1.50.0040.00417.39
8.1.40.0030.00517.48
8.1.30.0070.00317.50
8.1.20.0040.00417.57
8.1.10.0040.00417.38
8.1.00.0040.00417.38
8.0.300.0040.00419.95
8.0.290.0000.00816.63
8.0.280.0000.00718.34
8.0.270.0030.00316.87
8.0.260.0060.00018.40
8.0.250.0080.00016.98
8.0.240.0030.00316.96
8.0.230.0000.00716.99
8.0.220.0030.00316.95
8.0.210.0030.00316.95
8.0.200.0030.00316.98
8.0.190.0070.00316.98
8.0.180.0000.00816.97
8.0.170.0080.00016.97
8.0.160.0000.00816.97
8.0.150.0020.00516.84
8.0.140.0080.00016.75
8.0.130.0030.00313.28
8.0.120.0080.00016.77
8.0.110.0070.00016.75
8.0.100.0070.00016.97
8.0.90.0020.00516.81
8.0.80.0100.01016.92
8.0.70.0040.00416.90
8.0.60.0040.00416.86
8.0.50.0000.00716.84
8.0.30.0030.01516.79
8.0.20.0060.01317.23
8.0.10.0070.00016.93
8.0.00.0080.00916.66
7.4.330.0020.00215.55
7.4.320.0000.00616.41
7.4.300.0000.00616.62
7.4.290.0090.00016.67
7.4.280.0040.00416.60
7.4.270.0000.00716.56
7.4.260.0000.00716.62
7.4.250.0070.00016.52
7.4.240.0000.00816.66
7.4.230.0070.00016.56
7.4.220.0070.00016.28
7.4.210.0100.00616.61
7.4.200.0040.00416.63
7.4.140.0130.00317.86
7.4.130.0120.01216.62
7.4.120.0080.00916.60
7.4.110.0110.00816.44
7.4.100.0000.01716.55
7.4.90.0080.00816.70
7.4.80.0110.01219.39
7.4.70.0090.00916.40
7.4.60.0060.01316.69
7.4.50.0090.00916.38
7.4.40.0130.00416.54
7.4.00.0090.00814.99
7.3.330.0070.00013.14
7.3.320.0000.00513.09
7.3.310.0000.00716.32
7.3.300.0090.00016.19
7.3.290.0040.00416.32
7.3.280.0150.00316.29
7.3.260.0090.00816.53
7.3.240.0100.00616.50
7.3.230.0130.00416.43
7.3.210.0090.00916.25
7.3.200.0140.00316.52
7.3.190.0070.01316.52
7.3.180.0090.01216.34
7.3.170.0000.01516.59
7.3.160.0160.00616.34
7.3.120.0140.00415.04
7.3.110.0130.00614.64
7.3.100.0040.01514.84
7.3.90.0030.01014.76
7.3.80.0060.00915.05
7.3.70.0000.01414.92
7.3.60.0030.01114.80
7.3.50.0060.01114.85
7.3.40.0050.00814.90
7.3.30.0030.01014.66
7.3.20.0130.00815.46
7.3.10.0110.00615.42
7.3.00.0080.00715.24
7.2.330.0060.01216.66
7.2.320.0090.00916.86
7.2.310.0100.01016.77
7.2.300.0090.01216.71
7.2.290.0190.00016.82
7.2.250.0070.01315.04
7.2.240.0110.00915.21
7.2.230.0090.00615.09
7.2.220.0070.00715.20
7.2.210.0030.01114.92
7.2.200.0030.01415.29
7.2.190.0070.00715.13
7.2.180.0080.00815.13
7.2.170.0060.01014.93
7.2.160.0030.00815.26
7.2.150.0100.00915.14
7.2.140.0110.00215.05
7.2.130.0100.00515.02
7.2.120.0080.00715.14
7.2.110.0090.00615.12
7.2.100.0130.00715.08
7.2.90.0110.00815.16
7.2.80.0080.00815.28
7.2.70.0130.00515.20
7.2.60.0120.00515.09
7.2.50.0180.00615.15
7.2.40.0130.00815.09
7.2.30.0120.00515.09
7.2.20.0130.00815.10
7.2.10.0070.00514.96
7.2.00.0150.01015.03
7.1.330.0090.00615.83
7.1.320.0050.00515.87
7.1.310.0030.01315.49
7.1.300.0030.01015.61
7.1.290.0080.00415.71
7.1.280.0110.00714.53
7.1.270.1060.00714.51
7.1.260.0050.00714.43
7.1.250.0060.00613.82

preferences:
22.18 ms | 403 KiB | 5 Q