3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LogData { private const LOG_TYPE_MISSING_PARENT = 'MISSING_PARENT'; public array $lines = []; public function __construct(public readonly string $type, public readonly ?string $dateTime = null) { } /** * This object is used just in case the log file does not start with a log type. */ public static function createMissingParentHolder(): self { return new self(self::LOG_TYPE_MISSING_PARENT); } } $logData = <<<EOT INFO - 2023-05-23 09:10:45 --> CSRF token verified. CRITICAL - 2023-05-23 09:24:54 --> Undefined array key 158 in APPPATH/Views/tables/components/record_year__months_regions.php on line 18. 1 APPPATH/Views/tables/components/record_year__months_regions.php(18): CodeIgniter\Debug\Exceptions->errorHandler(2, 'Undefined array key 158', 'FILEPATH', 18) 17 FCPATH/index.php(67): CodeIgniter\CodeIgniter->run() CRITICAL - 2023-05-23 09:26:33 --> Undefined array key 158 in APPPATH/Views/tables/components/record_year__months_regions.php on line 18. EOT; $fp = fopen('php://memory', 'rb+'); fwrite($fp, $logData); rewind($fp); $keywords = ['INFO', 'CRITICAL', 'ERROR', 'WARNING', 'DEBUG']; $logObjects = []; $currentLogObject = null; while (($line = fgets($fp)) !== false) { $words = explode(' ', $line); $firstWord = $words[0] ?? ''; $timeWord = $words[3] ?? ''; // See if we found a special word if (in_array($firstWord, $keywords, true)) { // If we have an existing object, store it if ($currentLogObject) { $logObjects[] = $currentLogObject; } // Create a new object $currentLogObject = new LogData($firstWord, $timeWord); } elseif ($currentLogObject === null) { // We didn't find a special word, so make sure something exists to stash the line $currentLogObject = LogData::createMissingParentHolder(); } // No matter what happens above, stash the line $currentLogObject->lines[] = $line; } // At the end of the loop, make sure to store the last object if ($currentLogObject !== null) { $logObjects[] = $currentLogObject; } var_dump($logObjects);

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.30.0100.00919.39
8.5.20.0080.00920.11
8.5.10.0030.00619.42
8.5.00.0140.00820.13
8.4.180.0060.00522.22
8.4.170.0110.01023.58
8.4.160.0160.00623.96
8.4.150.0070.00616.87
8.4.140.0140.00617.67
8.4.130.0050.00517.77
8.4.120.0090.01120.51
8.4.110.0070.01118.78
8.4.100.0070.00318.67
8.4.90.0110.00920.65
8.4.80.0070.00217.75
8.4.70.0110.00917.64
8.4.60.0090.00318.89
8.4.50.0110.01120.53
8.4.40.0030.00620.79
8.4.30.0120.00822.05
8.4.20.0170.00317.89
8.4.10.0070.01321.88
8.3.300.0120.00820.80
8.3.290.0130.00918.75
8.3.280.0070.00516.22
8.3.270.0130.00716.36
8.3.260.0150.00416.67
8.3.250.0130.00619.09
8.3.240.0100.01016.36
8.3.230.0030.00516.50
8.3.220.0120.00718.91
8.3.210.0050.00216.74
8.3.200.0060.00516.68
8.3.190.0070.01216.96
8.3.180.0100.00916.70
8.3.170.0130.00717.34
8.3.160.0100.01018.39
8.3.150.0040.01216.62
8.3.140.0030.00617.02
8.3.130.0130.00318.36
8.3.120.0070.01319.01
8.3.110.0000.00922.58
8.3.100.0050.00322.58
8.3.90.0080.00822.58
8.3.50.0050.00522.58
8.2.300.0110.00817.85
8.2.290.0160.00320.80
8.2.280.0120.00718.84
8.2.270.0060.01217.49
8.2.260.0040.00420.87
8.2.250.0000.00916.73
8.2.240.0100.01017.11
8.2.230.0040.00422.58
8.2.220.0070.00322.58
8.2.210.0040.00422.58
8.2.60.0160.00117.29
8.2.50.0150.00317.25
8.2.40.0120.00417.38
8.2.30.0140.00317.38
8.2.20.0100.00717.50
8.2.10.0120.00517.38
8.2.00.0150.00317.61
8.1.340.0120.00819.66
8.1.330.0110.00222.00
8.1.320.0150.00516.22
8.1.310.0130.00618.45
8.1.300.0000.00917.59
8.1.190.0120.00416.88
8.1.180.0110.00616.88
8.1.170.0150.00317.13
8.1.160.0140.00417.13
8.1.150.0190.00016.97
8.1.140.0090.00617.13
8.1.130.0060.00917.25
8.1.120.0170.00017.13
8.1.110.0090.00617.47
8.1.100.0140.00317.23
8.1.90.0130.00317.25
8.1.80.0170.00017.13
8.1.70.0130.00317.23
8.1.60.0120.00817.38
8.1.50.0140.00317.50
8.1.40.0080.00817.50
8.1.30.0100.00717.50
8.1.20.0090.00917.13
8.1.10.0180.00017.25
8.1.00.0150.00317.13
8.0.280.0160.00016.52
8.0.270.0150.00016.63
8.0.260.0170.00016.52
8.0.250.0070.00716.52
8.0.240.0120.00416.52
8.0.230.0150.00016.52
8.0.220.0130.00316.52
8.0.210.0140.00316.52
8.0.200.0120.00416.63
8.0.190.0150.00016.52
8.0.180.0100.00716.59
8.0.170.0090.00616.52
8.0.160.0080.00816.52
8.0.150.0140.00316.52
8.0.140.0100.00616.52
8.0.130.0130.00316.75
8.0.120.0080.00816.52
8.0.110.0100.00516.52
8.0.100.0130.00316.63
8.0.90.0150.00016.52
8.0.80.0150.00016.75
8.0.70.0130.00416.52
8.0.60.0040.01216.52
8.0.50.0140.00316.52
8.0.30.0110.00416.63
8.0.20.0160.00016.52
8.0.10.0130.00316.52

preferences:
52.58 ms | 1075 KiB | 5 Q