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-beta'));

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.0140.00018.68
8.3.50.0170.00521.24
8.3.40.0110.00419.25
8.3.30.0060.00919.21
8.3.20.0000.00720.48
8.3.10.0070.00023.71
8.3.00.0070.00717.63
8.2.180.0180.00416.63
8.2.170.0000.01522.96
8.2.160.0070.00720.22
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0050.00322.23
8.2.110.0000.01021.23
8.2.100.0040.00817.88
8.2.90.0080.00019.52
8.2.80.0040.00417.97
8.2.70.0030.00617.88
8.2.60.0050.00518.18
8.2.50.0000.00918.07
8.2.40.0000.00819.75
8.2.30.0030.00618.21
8.2.20.0000.00817.99
8.2.10.0080.00018.15
8.2.00.0050.00317.87
8.1.280.0100.01025.92
8.1.270.0040.00423.85
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0040.00422.32
8.1.230.0040.00718.99
8.1.220.0050.00317.79
8.1.210.0040.00418.77
8.1.200.0060.00317.48
8.1.190.0080.00017.61
8.1.180.0080.00018.10
8.1.170.0000.00818.68
8.1.160.0050.00222.02
8.1.150.0060.00318.97
8.1.140.0000.00817.55
8.1.130.0000.00717.86
8.1.120.0040.00417.58
8.1.110.0040.00417.63
8.1.100.0040.00417.64
8.1.90.0000.00717.57
8.1.80.0050.00317.61
8.1.70.0000.00817.57
8.1.60.0000.00817.82
8.1.50.0000.00817.72
8.1.40.0030.00617.79
8.1.30.0000.00817.77
8.1.20.0040.00417.85
8.1.10.0040.00417.80
8.1.00.0040.00417.73
8.0.300.0030.00618.77
8.0.290.0040.00416.73
8.0.280.0080.00018.51
8.0.270.0000.00717.25
8.0.260.0000.00717.46
8.0.250.0030.00317.24
8.0.240.0000.00717.13
8.0.230.0000.00816.99
8.0.220.0080.00017.09
8.0.210.0040.00417.14
8.0.200.0050.00217.15
8.0.190.0000.00817.11
8.0.180.0040.00417.03
8.0.170.0030.00517.07
8.0.160.0050.00317.08
8.0.150.0040.00417.03
8.0.140.0050.00216.84
8.0.130.0060.00013.53
8.0.120.0000.01017.04
8.0.110.0050.00217.00
8.0.100.0000.00816.99
8.0.90.0050.00216.94
8.0.80.0090.01217.11
8.0.70.0000.00817.17
8.0.60.0040.00417.08
8.0.50.0000.00817.13
8.0.30.0140.00717.30
8.0.20.0100.01017.68
8.0.10.0000.00717.06
8.0.00.0090.00917.19
7.4.330.0050.00015.00
7.4.320.0060.00016.81
7.4.300.0000.00616.84
7.4.290.0080.00416.88
7.4.280.0030.00516.84
7.4.270.0030.00316.84
7.4.260.0000.00716.79
7.4.250.0040.00416.83
7.4.240.0050.00216.62
7.4.230.0000.00716.70
7.4.220.0100.01116.84
7.4.210.0080.00616.82
7.4.200.0050.00216.58
7.4.160.0110.00416.76
7.4.150.0060.01217.40
7.4.140.0190.00617.86
7.4.130.0120.00916.75
7.4.120.0110.01116.73
7.4.110.0070.01016.75
7.4.100.0110.00816.93
7.4.90.0110.00716.66
7.4.80.0040.01519.39
7.4.70.0090.00916.80
7.4.60.0070.01116.75
7.4.50.0050.00316.83
7.4.40.0150.00716.57
7.4.30.0040.01916.62
7.4.00.0040.00715.33
7.3.330.0000.00613.53
7.3.320.0050.00013.59
7.3.310.0000.00716.40
7.3.300.0040.00416.59
7.3.290.0120.00616.48
7.3.280.0070.01016.51
7.3.270.0060.01217.40
7.3.260.0090.00916.99
7.3.240.0110.00616.70
7.3.230.0030.01316.66
7.3.210.0140.00416.69
7.3.200.0120.01219.39
7.3.190.0140.01016.62
7.3.180.0070.01016.55
7.3.170.0120.00616.71
7.3.160.0070.01016.80
7.2.330.0060.01416.94
7.2.320.0060.01216.97
7.2.310.0090.01516.88
7.2.300.0060.01216.89
7.2.290.0130.00916.86
7.2.00.0060.00919.87
7.1.100.0080.00318.55
7.1.70.0000.00817.30
7.1.60.0030.01019.32
7.1.50.0040.01917.12
7.1.00.0000.08022.46
7.0.200.0070.00016.64
7.0.140.0000.07722.01
7.0.60.0030.08321.66
7.0.50.0070.08017.96
7.0.40.0100.05720.11
7.0.30.0230.05320.28
7.0.20.0370.04720.23
7.0.10.0170.05720.08
7.0.00.0070.08720.09
5.6.280.0000.07320.84
5.6.210.0070.09020.61
5.6.200.0100.04318.16
5.6.190.0070.07720.63
5.6.180.0470.07320.63
5.6.170.0300.07720.50
5.6.160.0170.08320.55
5.6.150.0070.08318.19
5.6.140.0030.04718.14
5.6.130.0000.08318.16
5.6.120.0130.07721.02
5.6.110.0100.06720.98
5.6.100.0170.07321.13
5.6.90.0000.04720.96
5.6.80.0070.05720.46
5.5.350.3970.04020.47
5.5.340.0030.06717.94
5.5.330.0030.06320.27
5.5.320.0500.06020.32
5.5.310.0300.07720.30
5.5.300.0130.06017.94
5.5.290.0100.08317.95
5.5.280.0100.08020.79
5.5.270.0030.06021.00
5.5.260.0000.04720.82
5.5.250.0100.07320.61
5.5.240.0030.08020.38
5.4.450.4570.03719.59
5.4.440.3870.04019.55
5.4.430.1770.06319.36
5.4.420.4600.03319.45
5.4.410.3900.04019.41
5.4.400.3670.03318.95
5.4.390.3970.03719.22
5.4.380.4830.03719.06
5.4.370.0070.05719.23
5.4.360.4630.03718.99
5.4.350.4000.03319.05
5.4.340.3800.03019.15
5.4.320.3500.03018.95
5.4.310.3700.03319.22
5.4.300.3200.03719.10
5.4.290.3400.03719.07
5.4.280.3670.04018.93
5.4.270.3800.03319.26
5.4.260.3830.04019.07
5.4.250.4230.05019.10
5.4.240.3870.03718.93
5.4.230.4700.03718.92
5.4.220.3800.04319.12
5.4.210.3870.04319.22
5.4.200.3700.03019.23
5.4.190.3670.03718.98
5.4.180.3830.03018.97
5.4.170.3770.04319.19
5.4.160.4200.04019.04
5.4.150.3900.04019.16
5.4.140.3970.03716.45
5.4.130.3970.03016.45
5.4.120.3700.04016.53
5.4.110.3900.04316.52
5.4.100.4000.03016.52
5.4.90.3770.04016.58
5.4.80.3670.03716.54
5.4.70.3870.03716.55
5.4.60.3900.03316.22
5.4.50.3900.03016.53
5.4.40.4070.05016.47
5.4.30.3830.03016.32
5.4.20.4230.03016.45
5.4.10.3770.03716.46
5.4.00.3730.03315.97
5.3.290.3330.04314.58
5.3.280.4200.03714.68
5.3.270.4100.04714.76
5.3.260.3970.03314.75
5.3.250.4100.04014.60
5.3.240.3900.04014.75
5.3.230.3570.03714.63
5.3.220.3670.04014.61
5.3.210.3570.04314.59
5.3.200.3830.03714.73
5.3.190.3800.03314.57
5.3.180.3900.03714.58
5.3.170.4130.03314.57
5.3.160.3670.03714.71
5.3.150.3630.03314.45
5.3.140.3970.04014.57
5.3.130.4230.02714.60
5.3.120.3630.04014.54
5.3.110.3600.04314.70
5.3.100.3600.03714.07
5.3.90.3800.03714.16
5.3.80.3730.04014.02
5.3.70.3700.03313.97
5.3.60.4030.03714.03
5.3.50.3870.03313.94
5.3.40.3770.04713.95
5.3.30.4670.03014.06
5.3.20.4670.03713.57
5.3.10.4100.04313.62
5.3.00.3930.03013.60
5.2.170.3330.03011.29
5.2.160.3300.03011.11
5.2.150.3630.03011.31
5.2.140.3200.02711.11
5.2.130.3630.03710.99
5.2.120.3400.03311.12
5.2.110.3370.04011.02
5.2.100.2800.02011.07
5.2.90.3430.01711.07
5.2.80.3130.03311.10
5.2.70.2930.03710.98
5.2.60.3370.02311.21
5.2.50.3500.03311.02
5.2.40.2470.02711.05
5.2.30.2900.03011.03
5.2.20.2530.03010.95
5.2.10.3100.03010.86
5.2.00.3130.03010.77
5.1.60.2670.02310.14
5.1.50.2370.02310.15
5.1.40.2730.02710.02
5.1.30.2970.02310.48
5.1.20.2400.02310.35
5.1.10.2700.0339.98
5.1.00.3170.02310.09
5.0.50.1500.0178.59
5.0.40.1700.0238.55
5.0.30.1870.0278.13
5.0.20.1830.0208.35
5.0.10.1800.0178.08
5.0.00.1800.0308.22
4.4.90.1430.0136.18
4.4.80.1300.0106.18
4.4.70.1330.0176.18
4.4.60.1270.0136.18
4.4.50.1570.0206.18
4.4.40.1400.0276.18
4.4.30.1500.0176.18
4.4.20.1300.0176.18
4.4.10.1430.0176.18
4.4.00.1470.0276.18
4.3.110.1430.0176.18
4.3.100.1770.0206.18
4.3.90.1830.0136.18
4.3.80.0730.0376.18
4.3.70.0070.0306.18
4.3.60.0030.0236.18
4.3.50.0000.0376.18
4.3.40.0100.0436.18
4.3.30.0030.0206.18
4.3.20.0000.0376.18
4.3.10.0030.0306.18
4.3.00.0000.0376.18

preferences:
45.24 ms | 401 KiB | 5 Q