3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Version { const STAGE_ALPHA = 1; const STAGE_BETA = 2; const STAGE_RC = 3; const STAGE_RELEASE = 4; public $major; public $minor; public $release; public $stageName; public $stageNo; private $stageMap = [ 'alpha' => self::STAGE_ALPHA, 'beta' => self::STAGE_BETA, 'rc' => self::STAGE_RC, ]; /** * @param string $version * @throws \Exception */ public function __construct($version) { static $tagNameExpr = '# ^ v? (?P<major>[0-9]+) \. (?P<minor>[0-9]+) (?:\.(?P<release>[0-9]+))? (?:- (?P<stage>alpha|beta|rc) (?:(?P<stageno>\d+))? )? $ #ix'; if (!preg_match($tagNameExpr, trim(strtolower($version)), $match)) { throw new \Exception('Invalid version spec string'); } $this->major = (int)$match['major']; $this->minor = (int)$match['minor']; $this->release = isset($match['release']) && $match['release'] !== '' ? (int)$match['release'] : null; $this->stageName = isset($match['stage']) && $match['stage'] !== '' ? $match['stage'] : ''; $this->stageNo = isset($match['stageno']) && $match['stageno'] !== '' ? (int)$match['stageno'] : null; } /** * @return string */ public function __toString() { return "$this->major.$this->minor." . ($this->release ?: 0) . ($this->stageNo ? '-' . $this->stageName . $this->stageNo : ''); } /** * @param string[] $stages * @return bool */ public function isValidNextStage(array $stages) { $latestStageType = $latestStagePoint = 0; foreach ($stages as $stage) { if ($stage === '') { // a release already exists return false; } if (preg_match('#^(alpha|beta|rc)(\d+)$#', strtolower($stage), $match)) { if ($this->stageMap[$match[1]] > $latestStageType) { $latestStageType = $this->stageMap[$match[1]]; $latestStagePoint = 0; } else if ($this->stageMap[$match[1]] === $latestStageType && $match[2] > $latestStagePoint) { $latestStagePoint = (int)$match[2]; } } } if (!$this->stageName) { // this is a release and one does not yet exist return true; } if (!isset($this->stageMap[$this->stageName])) { // invalid new stage return false; } if ($this->stageMap[$this->stageName] < $latestStageType) { // new stage lower than latest return false; } if ($this->stageMap[$this->stageName] > $latestStageType) { // new stage greater than latest, number must be 1 if (!isset($this->stageNo)) { $this->stageNo = 1; return true; } return $this->stageNo === 1; } if (!isset($this->stageNo)) { $this->stageNo = $latestStagePoint + 1; return true; } return $this->stageNo === $latestStagePoint + 1; } } var_dump(new Version('1.12-beta3'));

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.0040.01118.68
8.3.50.0120.01021.40
8.3.40.0120.00319.04
8.3.30.0120.00319.31
8.3.20.0050.00320.32
8.3.10.0050.00323.48
8.3.00.0100.00317.88
8.2.180.0070.00716.75
8.2.170.0130.00622.96
8.2.160.0000.01320.50
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0050.00226.16
8.2.120.0080.00022.18
8.2.110.0070.00322.38
8.2.100.0120.00017.88
8.2.90.0040.00419.30
8.2.80.0000.00817.97
8.2.70.0030.00618.00
8.2.60.0090.00318.29
8.2.50.0080.00018.07
8.2.40.0040.00419.84
8.2.30.0030.00618.16
8.2.20.0000.00817.90
8.2.10.0080.00018.31
8.2.00.0030.00517.88
8.1.280.0110.01525.92
8.1.270.0100.00621.99
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0050.00524.03
8.1.230.0040.00820.93
8.1.220.0090.00017.77
8.1.210.0050.00318.77
8.1.200.0060.00317.61
8.1.190.0000.00817.61
8.1.180.0030.00618.10
8.1.170.0030.00618.89
8.1.160.0040.00422.15
8.1.150.0000.00818.95
8.1.140.0050.00317.59
8.1.130.0050.00217.97
8.1.120.0000.00717.68
8.1.110.0040.00417.66
8.1.100.0020.00517.66
8.1.90.0000.00717.57
8.1.80.0080.00017.68
8.1.70.0040.00417.59
8.1.60.0040.00417.87
8.1.50.0060.00317.66
8.1.40.0040.00417.73
8.1.30.0040.00417.93
8.1.20.0040.00417.81
8.1.10.0060.00317.81
8.1.00.0060.00317.74
8.0.300.0040.00418.77
8.0.290.0000.00816.88
8.0.280.0000.00718.54
8.0.270.0080.00017.35
8.0.260.0000.00817.35
8.0.250.0030.00317.04
8.0.240.0070.00017.19
8.0.230.0030.00517.18
8.0.220.0000.01117.02
8.0.210.0000.00716.98
8.0.200.0050.00216.99
8.0.190.0100.00017.17
8.0.180.0040.00416.99
8.0.170.0090.00017.09
8.0.160.0050.00317.00
8.0.150.0040.00416.99
8.0.140.0000.00717.00
8.0.130.0060.00013.55
8.0.120.0000.00817.06
8.0.110.0040.00417.09
8.0.100.0000.00716.98
8.0.90.0000.00817.13
8.0.80.0100.01017.05
8.0.70.0030.00616.92
8.0.60.0040.00416.94
8.0.50.0000.00716.97
8.0.30.0120.01217.37
8.0.20.0170.01217.40
8.0.10.0040.00417.03
8.0.00.0070.01117.11
7.4.330.0000.00615.00
7.4.320.0030.00316.82
7.4.300.0000.00716.80
7.4.290.0070.00316.84
7.4.280.0000.00816.84
7.4.270.0070.00016.75
7.4.260.0040.00416.83
7.4.250.0080.00016.70
7.4.240.0070.00216.77
7.4.230.0050.00216.83
7.4.220.0110.00716.88
7.4.210.0030.01216.77
7.4.200.0000.00816.71
7.4.160.0040.01116.76
7.4.150.0090.00917.40
7.4.140.0130.00917.86
7.4.130.0090.00916.68
7.4.120.0080.01516.70
7.4.110.0220.00016.86
7.4.100.0030.01416.66
7.4.90.0090.00916.90
7.4.80.0150.00319.39
7.4.70.0060.01216.82
7.4.60.0140.00716.78
7.4.50.0060.00316.67
7.4.40.0000.01716.58
7.4.30.0040.01416.73
7.4.00.0150.00015.27
7.3.330.0030.00313.37
7.3.320.0000.00613.44
7.3.310.0030.00316.64
7.3.300.0070.00016.59
7.3.290.0000.01716.58
7.3.280.0090.01016.51
7.3.270.0090.00917.40
7.3.260.0140.00316.50
7.3.240.0140.00316.80
7.3.230.0120.00616.58
7.3.210.0120.00416.68
7.3.200.0120.01219.39
7.3.190.0050.01416.53
7.3.180.0090.00616.61
7.3.170.0090.00916.86
7.3.160.0070.01016.63
7.2.330.0140.00417.03
7.2.320.0100.00717.02
7.2.310.0090.00916.95
7.2.300.0060.01216.99
7.2.290.0060.01216.81
7.2.00.0000.01519.75
7.1.100.0040.00418.42
7.1.70.0050.00317.55
7.1.60.0070.00719.32
7.1.50.0080.01217.05
7.1.00.0100.07322.42
7.0.200.0000.01016.96
7.0.140.0070.07021.95
7.0.60.0130.07320.14
7.0.50.0000.04318.02
7.0.40.0070.05319.98
7.0.30.0270.07720.08
7.0.20.0170.04320.26
7.0.10.0130.07720.25
7.0.00.0130.04320.09
5.6.280.0000.07721.14
5.6.210.0100.08020.54
5.6.200.0070.03718.16
5.6.190.0030.07320.61
5.6.180.0170.05720.41
5.6.170.0170.04320.71
5.6.160.0130.08720.49
5.6.150.0070.06718.25
5.6.140.0100.03318.30
5.6.130.0030.05318.13
5.6.120.0130.07720.83
5.6.110.0070.08321.16
5.6.100.0000.04320.91
5.6.90.0030.04321.14
5.6.80.0100.07320.53
5.5.350.0170.04720.52
5.5.340.0000.08717.96
5.5.330.0070.08020.43
5.5.320.0300.03720.42
5.5.310.0170.04720.38
5.5.300.0030.06018.08
5.5.290.0000.04318.04
5.5.280.0030.08720.68
5.5.270.0100.05720.98
5.5.260.0130.06320.82
5.5.250.0030.08720.63
5.5.240.0200.07720.15
5.4.450.0170.05319.57
5.4.440.0170.07019.32
5.4.430.0200.04719.19
5.4.420.0130.06719.48
5.4.410.0200.07319.07
5.4.400.0330.05719.00
5.4.390.0170.06719.22
5.4.380.0170.07319.13
5.4.370.0230.05718.95
5.4.360.0270.06718.87
5.4.350.0200.07719.08
5.4.340.0230.07019.21
5.4.320.0170.05719.00
5.4.310.0330.06019.08
5.4.300.0200.04719.19
5.4.290.0230.03319.22
5.4.280.0270.05319.09
5.4.270.0230.06018.84
5.4.260.0230.04019.14
5.4.250.0230.07719.30
5.4.240.0230.07019.07
5.4.230.0330.04718.97
5.4.220.0200.07719.21
5.4.210.0200.06319.07
5.4.200.0270.06718.86
5.4.190.0170.06018.97
5.4.180.0270.07318.97
5.4.170.0300.05718.86
5.4.160.0270.07319.04
5.4.150.0270.04718.96
5.4.140.0270.06316.36
5.4.130.0270.05716.47
5.4.120.0230.06016.47
5.4.110.0230.07316.20
5.4.100.0230.07716.30
5.4.90.0300.06016.57
5.4.80.0170.05316.56
5.4.70.0100.04016.45
5.4.60.0070.06716.57
5.4.50.0200.06016.50
5.4.40.0270.07016.51
5.4.30.0200.05316.43
5.4.20.0230.05016.26
5.4.10.0300.06316.16
5.4.00.0270.04315.93
5.3.290.0200.07014.64
5.3.280.0370.05714.67
5.3.270.0170.06014.82
5.3.260.0270.06714.82
5.3.250.0270.06714.69
5.3.240.0170.07014.68
5.3.230.0200.07014.65
5.3.220.0170.04714.68
5.3.210.0200.08014.66
5.3.200.0230.05014.64
5.3.190.0170.03714.64
5.3.180.0330.06314.61
5.3.170.0170.04714.47
5.3.160.0330.06714.68
5.3.150.0200.07314.58
5.3.140.0230.07014.71
5.3.130.0330.04714.62
5.3.120.0200.07714.77
5.3.110.0170.06714.51
5.3.100.0200.05714.01
5.3.90.0170.07014.01
5.3.80.0200.07314.02
5.3.70.0100.04713.95
5.3.60.0170.03313.91
5.3.50.0170.06314.10
5.3.40.0170.07313.84
5.3.30.0300.05013.81
5.3.20.0230.05713.71
5.3.10.0200.06713.87
5.3.00.0200.06013.56
5.2.170.0130.05012.03
5.2.160.0230.06012.03
5.2.150.0170.06012.03
5.2.140.0170.06312.03
5.2.130.0170.06312.03
5.2.120.0230.02312.03
5.2.110.0200.06012.03
5.2.100.0070.05012.03
5.2.90.0170.03712.03
5.2.80.0130.04312.03
5.2.70.0200.03312.03
5.2.60.0170.06012.03
5.2.50.0170.05712.03
5.2.40.0130.06012.03
5.2.30.0170.06012.03
5.2.20.0130.05712.03
5.2.10.0200.05712.03
5.2.00.0130.05312.03
5.1.60.0130.05712.03
5.1.50.0130.05012.03
5.1.40.0130.05312.03
5.1.30.0230.04012.03
5.1.20.0130.04312.03
5.1.10.0170.05312.03
5.1.00.0130.05012.03
5.0.50.0000.04312.03
5.0.40.0170.03012.03
5.0.30.0100.06312.03
5.0.20.0070.02312.03
5.0.10.0170.03712.03
5.0.00.0100.04712.03
4.4.90.0030.02312.03
4.4.80.0030.02312.03
4.4.70.0100.03712.03
4.4.60.0130.02312.03
4.4.50.0100.02312.03
4.4.40.0130.04312.03
4.4.30.0070.03312.03
4.4.20.0070.03312.03
4.4.10.0100.03312.03
4.4.00.0030.05712.03
4.3.110.0030.03012.03
4.3.100.0070.02012.03
4.3.90.0070.03312.03
4.3.80.0100.03712.03
4.3.70.0100.01712.03
4.3.60.0130.01312.03
4.3.50.0030.02012.03
4.3.40.0030.02712.03
4.3.30.0030.01712.03
4.3.20.0000.01712.03
4.3.10.0070.02012.03
4.3.00.0070.01312.03

preferences:
39.09 ms | 401 KiB | 5 Q