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 = $match['major']; $this->minor = $match['minor']; $this->release = isset($match['release']) ? (int)$match['release'] : null; $this->stageName = isset($match['stage']) ? $match['stage'] : ''; $this->stageNo = isset($match['stageno']) ? $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.0090.00618.55
8.3.50.0130.00821.21
8.3.40.0150.00718.84
8.3.30.0090.00619.21
8.3.20.0000.00820.34
8.3.10.0110.00423.52
8.3.00.0090.00317.75
8.2.180.0180.00416.63
8.2.170.0030.01222.96
8.2.160.0110.00420.29
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0050.00322.22
8.2.110.0060.00322.11
8.2.100.0080.00418.28
8.2.90.0040.00419.27
8.2.80.0070.00317.97
8.2.70.0050.00517.88
8.2.60.0060.00317.93
8.2.50.0040.00418.07
8.2.40.0050.00320.11
8.2.30.0040.00418.23
8.2.20.0050.00217.93
8.2.10.0090.00018.08
8.2.00.0080.00017.82
8.1.280.0180.00425.92
8.1.270.0000.00923.91
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0090.00022.18
8.1.230.0090.00317.95
8.1.220.0030.00617.77
8.1.210.0000.00918.77
8.1.200.0080.00317.60
8.1.190.0040.00417.60
8.1.180.0050.00318.10
8.1.170.0030.00518.95
8.1.160.0060.00322.00
8.1.150.0000.00718.88
8.1.140.0040.00417.64
8.1.130.0000.00717.82
8.1.120.0000.00717.54
8.1.110.0030.00517.62
8.1.100.0040.00417.65
8.1.90.0000.00817.71
8.1.80.0040.00417.57
8.1.70.0000.00817.63
8.1.60.0040.00417.79
8.1.50.0080.00017.61
8.1.40.0030.00617.73
8.1.30.0040.00417.81
8.1.20.0040.00417.89
8.1.10.0000.00917.63
8.1.00.0000.00817.79
8.0.300.0000.00718.77
8.0.290.0070.00017.00
8.0.280.0000.00718.46
8.0.270.0000.00717.32
8.0.260.0030.00317.41
8.0.250.0040.00417.18
8.0.240.0030.00317.20
8.0.230.0000.00816.95
8.0.220.0100.00016.92
8.0.210.0070.00016.91
8.0.200.0030.00317.08
8.0.190.0060.00317.00
8.0.180.0000.00717.09
8.0.170.0050.00317.00
8.0.160.0040.00416.97
8.0.150.0050.00217.04
8.0.140.0040.00416.87
8.0.130.0000.00713.43
8.0.120.0030.00616.99
8.0.110.0030.00516.98
8.0.100.0030.00516.96
8.0.90.0040.00417.10
8.0.80.0060.01717.02
8.0.70.0000.00816.89
8.0.60.0000.00817.04
8.0.50.0040.00417.08
8.0.30.0120.01517.28
8.0.20.0140.01117.40
8.0.10.0000.00717.26
8.0.00.0120.00517.09
7.4.330.0030.00315.00
7.4.320.0030.00316.80
7.4.300.0000.00716.70
7.4.290.0060.00316.82
7.4.280.0030.00716.79
7.4.270.0050.00316.64
7.4.260.0000.00716.77
7.4.250.0040.00416.55
7.4.240.0050.00216.75
7.4.230.0040.00416.91
7.4.220.0120.00616.90
7.4.210.0040.01116.68
7.4.200.0040.00416.52
7.4.160.0060.01116.82
7.4.150.0160.00817.40
7.4.140.0140.00717.86
7.4.130.0070.01016.70
7.4.120.0070.01116.82
7.4.110.0140.00416.83
7.4.100.0120.00616.78
7.4.90.0110.00716.66
7.4.80.0060.01219.39
7.4.70.0090.01216.84
7.4.60.0120.00616.75
7.4.50.0030.00516.56
7.4.40.0150.00616.84
7.4.30.0150.00616.68
7.4.00.0000.01915.26
7.3.330.0000.00713.63
7.3.320.0000.00513.39
7.3.310.0070.00016.60
7.3.300.0030.00316.50
7.3.290.0150.00016.58
7.3.280.0100.00716.52
7.3.270.0210.00317.40
7.3.260.0130.00616.49
7.3.250.0110.00716.54
7.3.240.0110.00716.78
7.3.230.0120.00816.55
7.3.210.0160.00416.70
7.3.200.0140.00819.39
7.3.190.0140.00616.74
7.3.180.0130.00316.96
7.3.170.0110.00716.53
7.3.160.0120.00816.71
7.2.330.0060.01216.80
7.2.320.0140.00616.89
7.2.310.0070.01117.00
7.2.300.0130.00316.93
7.2.290.0060.01116.83
7.2.00.0030.01019.86
7.1.100.0040.01118.27
7.1.70.0080.00417.44
7.1.60.0030.02119.32
7.1.50.0000.01116.96
7.1.00.0030.07722.36
7.0.200.0000.00916.89
7.0.140.0030.07722.10
7.0.60.0070.05719.99
7.0.50.0030.08317.96
7.0.40.0000.04720.13
7.0.30.0370.04020.21
7.0.20.0200.08320.22
7.0.10.0070.08720.18
7.0.00.0100.06720.35
5.6.280.0030.08321.14
5.6.210.0200.07320.57
5.6.200.0070.06718.25
5.6.190.0000.04720.47
5.6.180.0270.08020.67
5.6.170.0470.06320.62
5.6.160.0030.08720.44
5.6.150.0130.07318.27
5.6.140.0070.03718.16
5.6.130.0170.06018.17
5.6.120.0070.09020.96
5.6.110.0000.05321.04
5.6.100.0030.06321.16
5.6.90.0030.04020.98
5.6.80.0070.07720.52
5.5.350.0070.08320.32
5.5.340.0030.08318.07
5.5.330.0130.05320.56
5.5.320.0270.04020.25
5.5.310.0200.06320.27
5.5.300.0070.03718.01
5.5.290.0070.04717.93
5.5.280.0070.04720.68
5.5.270.0100.08020.78
5.5.260.0070.08720.79
5.5.250.0170.07320.80
5.5.240.0230.07020.28
5.4.450.0070.06319.45
5.4.440.0900.06319.70
5.4.430.1000.06319.45
5.4.420.0670.00019.41
5.4.410.0700.00019.21
5.4.400.0870.00019.22
5.4.390.0600.00019.21
5.4.380.0630.00019.03
5.4.370.0670.00019.06
5.4.360.0730.00019.24
5.4.350.0670.00019.08
5.4.340.0060.03512.04
5.4.320.0050.03812.52
5.4.310.0060.03912.52
5.4.300.0060.03712.53
5.4.290.0010.04412.52
5.4.280.0100.03212.41
5.4.270.0080.03712.41
5.4.260.0060.04012.42
5.4.250.0110.03712.41
5.4.240.0070.03712.42
5.4.230.0070.03712.41
5.4.220.0040.03912.41
5.4.210.0060.03712.41
5.4.200.0090.03512.41
5.4.190.0060.03712.41
5.4.180.0100.03312.40
5.4.170.0050.03712.41
5.4.160.0080.03612.41
5.4.150.0070.03812.41
5.4.140.0090.03512.09
5.4.130.0110.03612.08
5.4.120.0140.02812.04
5.4.110.0060.04012.04
5.4.100.0060.03812.04
5.4.90.0090.04212.04
5.4.80.0040.05212.04
5.4.70.0060.04012.03
5.4.60.0040.03712.03
5.4.50.0050.03712.03
5.4.40.0020.04112.02
5.4.30.0060.03812.02
5.4.20.0040.03812.02
5.4.10.0060.04012.02
5.4.00.0070.03811.50
5.3.290.0080.04612.80
5.3.280.0050.04112.71
5.3.270.0070.04612.72
5.3.260.0060.04112.72
5.3.250.0050.04112.72
5.3.240.0050.04112.72
5.3.230.0050.03912.71
5.3.220.0070.03812.68
5.3.210.0090.04012.68
5.3.200.0070.04112.68
5.3.190.0110.04712.68
5.3.180.0060.03812.67
5.3.170.0110.03712.67
5.3.160.0070.04212.67
5.3.150.0050.04312.67
5.3.140.0060.04212.66
5.3.130.0080.03812.66
5.3.120.0050.04112.65
5.3.110.0060.03912.66
5.3.100.0040.03912.12
5.3.90.0050.04112.10
5.3.80.0090.03312.09
5.3.70.0080.03412.09
5.3.60.0030.03912.07
5.3.50.0040.03912.02
5.3.40.0090.03512.02
5.3.30.0100.03411.98
5.3.20.0060.03811.76
5.3.10.0090.03311.73
5.3.00.0060.03911.71
5.2.170.0070.0349.22
5.2.160.0030.0359.22
5.2.150.0070.0319.22
5.2.140.0070.0369.22
5.2.130.0050.0319.18
5.2.120.0070.0349.18
5.2.110.0040.0309.18
5.2.100.0060.0309.18
5.2.90.0070.0369.18
5.2.80.0070.0369.18
5.2.70.0050.0339.18
5.2.60.0060.0299.13
5.2.50.0110.0359.10
5.2.40.0100.0289.07
5.2.30.0050.0319.05
5.2.20.0040.0309.04
5.2.10.0070.0328.94
5.2.00.0090.0288.80
5.1.60.0030.0328.09
5.1.50.0070.0248.09
5.1.40.0050.0268.07
5.1.30.0010.0318.41
5.1.20.0050.0278.44
5.1.10.0050.0258.16
5.1.00.0040.0268.16
5.0.50.0040.0276.64
5.0.40.0060.0256.50
5.0.30.0020.0336.32
5.0.20.0010.0216.28
5.0.10.0050.0276.26
5.0.00.0030.0366.25
4.4.90.0020.0174.78
4.4.80.0040.0194.76
4.4.70.0040.0164.75
4.4.60.0040.0154.76
4.4.50.0020.0194.77
4.4.40.0030.0274.71
4.4.30.0050.0154.76
4.4.20.0030.0234.84
4.4.10.0020.0174.85
4.4.00.0050.0254.76
4.3.110.0020.0184.67
4.3.100.0030.0204.67
4.3.90.0060.0154.63
4.3.80.0050.0274.58
4.3.70.0060.0184.63
4.3.60.0050.0194.63
4.3.50.0040.0214.62
4.3.40.0020.0314.54
4.3.30.0050.0133.30
4.3.20.0010.0183.29
4.3.10.0040.0173.24
4.3.00.0270.0177.23

preferences:
45.92 ms | 401 KiB | 5 Q