3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MessageId { protected static $partSeperator = '_'; protected static $hashAlgorithm = 'crc32'; protected static $validNames = []; protected $name; protected $time; protected $hash; public function __construct($name) { $this->time = microtime(true); $this->name = trim($name); $this->hash = hash(static::$hashAlgorithm, rand(0, $this->time)); if (empty($this->name)) { throw new DomainException('Name must not be empty'); } if (!in_array($this->name, static::$validNames)) { throw new DomainException("Invalid name [$name]"); } } public static function fromString($idString) { $parts = explode(static::$partSeperator, $idString); if (count($parts) != 3) { throw new DomainException("Unexpected format [$idString]"); } return static::fromParts($parts[0], $parts[1], $parts[2]); } public static function fromParts($name, $time, $hash) { $id = new static($name); $id->time = floatval($time); $id->hash = strval($hash); return $id; } public function name() { return $this->name; } public function time() { return $this->time; } public function equals(self $other) { return ((string) $this == (string) $other); } public function __toString() { return implode(static::$partSeperator, (array) $this); } } var_dump(new MessageId('foo'));

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)
7.4.10.0070.01015.83
7.4.00.0070.01015.54
7.3.130.0030.01515.68
7.3.120.0080.01015.48
7.3.110.0050.01115.47
7.3.100.0070.00815.41
7.3.90.0050.00915.50
7.3.80.0050.00415.41
7.3.70.0050.00715.30
7.3.60.0050.00815.34
7.3.50.0050.00815.34
7.3.40.0060.00715.47
7.3.30.0040.00915.45
7.3.20.0080.00717.33
7.3.10.0050.00717.14
7.3.00.0030.01117.24
7.2.260.0090.01115.94
7.2.250.0070.00915.74
7.2.240.0080.00915.59
7.2.230.0030.01115.73
7.2.220.0060.00715.70
7.2.210.0040.00815.70
7.2.200.0060.00715.62
7.2.190.0070.00515.54
7.2.180.0060.00615.72
7.2.170.0020.00915.63
7.2.160.0040.01015.94
7.2.150.0060.00817.83
7.2.140.0020.01217.86
7.2.130.0050.01117.56
7.2.120.0050.00717.89
7.2.110.0050.00917.72
7.2.100.0080.00317.54
7.2.90.0080.00917.79
7.2.80.0030.01217.71
7.2.70.0080.00717.72
7.2.60.0080.00617.78
7.2.50.0030.01017.72
7.2.40.0040.01017.68
7.2.30.0080.00917.73
7.2.20.0110.00717.75
7.2.10.0090.00617.61
7.2.00.0070.01017.74
7.1.330.0060.00816.42
7.1.320.0040.00916.31
7.1.310.0040.00916.44
7.1.300.0070.00516.26
7.1.290.0060.00616.41
7.1.280.0060.00716.32
7.1.270.0060.00616.18
7.1.260.0060.00716.30
7.1.250.0070.00716.62
7.1.240.0000.01116.64
7.1.230.0050.00816.69
7.1.220.0020.01016.54
7.1.210.0040.01016.57
7.1.200.0060.00816.63
7.1.190.0030.01016.62
7.1.180.0100.00516.50
7.1.170.0060.01016.51
7.1.160.0050.00816.59
7.1.150.0070.00616.64
7.1.140.0060.00816.59
7.1.130.0000.01116.65
7.1.120.0050.01016.47
7.1.110.0050.01316.56
7.1.100.0020.01216.66
7.1.90.0040.00916.59
7.1.80.0070.00716.57
7.1.70.0060.00816.79
7.1.60.0090.00817.56
7.1.50.0070.01016.73
7.1.40.0040.01016.63
7.1.30.0000.01416.63
7.1.20.0080.00916.60
7.1.10.0090.00616.27
7.1.00.0090.01518.56
7.0.330.0050.01016.21
7.0.320.0030.00816.06
7.0.310.0050.00816.25
7.0.300.0070.00716.18
7.0.290.0050.01016.29
7.0.280.0050.01016.07
7.0.270.0050.01116.21
7.0.260.0060.00816.14
7.0.250.0100.00716.36
7.0.240.0060.00716.17
7.0.230.0060.00916.23
7.0.220.0020.00716.34
7.0.210.0060.00916.36
7.0.200.0170.00515.65
7.0.190.0030.00916.37
7.0.180.0100.00516.23
7.0.170.0060.00616.16
7.0.160.0070.00816.28
7.0.150.0060.01116.24
7.0.140.0080.02818.22
7.0.130.0040.01416.20
7.0.120.0070.02618.11
7.0.110.0050.00916.32
7.0.100.0050.00816.29
7.0.90.0110.00516.05
7.0.80.0060.01016.27
7.0.70.0030.01016.31
7.0.60.0030.02218.09
7.0.50.0080.02516.82
7.0.40.0030.01916.28
7.0.30.0080.01416.16
7.0.20.0050.01916.27
7.0.10.0030.02016.22
7.0.00.0030.01916.23
5.6.400.0030.01215.23
5.6.390.0030.01015.00
5.6.380.0020.01014.90
5.6.370.0040.00615.26
5.6.360.0050.00715.29
5.6.350.0050.00915.28
5.6.340.0080.00515.02
5.6.330.0070.00615.18
5.6.320.0080.01115.04
5.6.310.0120.00615.20
5.6.300.0050.01415.46
5.6.290.0050.00815.30
5.6.280.0050.03117.03
5.6.270.0070.00515.30
5.6.260.0070.00715.12
5.6.250.0040.01015.25
5.6.240.0050.00715.22
5.6.230.0090.00515.15
5.6.220.0060.00815.11
5.6.210.0080.02216.96
5.6.200.0030.03116.14
5.6.190.0050.01917.08
5.6.180.0050.02016.89
5.6.170.0080.01916.75
5.6.160.0060.01816.98
5.6.150.0030.02116.96
5.6.140.0070.02016.89
5.6.130.0080.01616.85
5.6.120.0080.02316.88
5.6.110.0070.03316.82
5.6.100.0050.02416.90
5.6.90.0040.02316.90
5.6.80.0070.02216.65
5.6.70.0070.02316.63
5.6.60.0100.02816.60
5.6.50.0080.02716.53
5.6.40.0060.02716.75
5.6.30.0040.03516.54
5.6.20.0050.02416.55
5.6.10.0030.03116.54
5.6.00.0030.03616.61
5.5.380.0020.01015.03
5.5.370.0070.00915.00
5.5.360.0050.00915.02
5.5.350.0040.02917.13
5.5.340.0100.02915.88
5.5.330.0030.01916.86
5.5.320.0060.01916.92
5.5.310.0040.02116.84
5.5.300.0050.01916.71
5.5.290.0020.03216.86
5.5.280.0040.03416.94
5.5.270.0040.02316.75
5.5.260.0030.02716.72
5.5.250.0030.02716.60
5.5.240.0070.02216.56
5.5.230.0070.03016.54
5.5.220.0030.03216.58
5.5.210.0030.03116.54
5.5.200.0040.02516.36
5.5.190.0020.03016.56
5.5.180.0030.02816.46
5.5.170.0050.00715.15
5.5.160.0090.03016.62
5.5.150.0030.03416.66
5.5.140.0070.02716.57
5.5.130.0060.03016.56
5.5.120.0070.02616.38
5.5.110.0070.02916.59
5.5.100.0010.03416.56
5.5.90.0040.02116.43
5.5.80.0020.02216.50
5.5.70.0060.02916.47
5.5.60.0050.02816.51
5.5.50.0050.02716.48
5.5.40.0090.02216.46
5.5.30.0080.03116.51
5.5.20.0030.03316.35
5.5.10.0060.03116.39
5.5.00.0060.02516.64
5.4.450.0040.01914.60
5.4.440.0040.03014.50
5.4.430.0050.02614.63
5.4.420.0020.02014.49
5.4.410.0040.02714.38
5.4.400.0090.01414.40
5.4.390.0060.02714.40
5.4.380.0020.02414.43
5.4.370.0020.02914.27
5.4.360.0060.02914.44
5.4.350.0050.01914.46
5.4.340.0060.02714.32
5.4.330.0050.00612.02
5.4.320.0080.02714.38
5.4.310.0020.03014.54
5.4.300.0070.02314.41
5.4.290.0020.02914.48
5.4.280.0070.02614.34
5.4.270.0020.03414.54
5.4.260.0050.03314.33
5.4.250.0060.01514.29
5.4.240.0050.02414.55
5.4.230.0040.02314.37
5.4.220.0070.03014.24
5.4.210.0080.02514.37
5.4.200.0040.02514.46
5.4.190.0030.02914.38
5.4.180.0030.02414.51
5.4.170.0060.02914.22
5.4.160.0050.03214.35
5.4.150.0010.02414.26
5.4.140.0030.02913.44
5.4.130.0030.02813.44
5.4.120.0050.02713.40
5.4.110.0050.02813.44
5.4.100.0030.01913.36
5.4.90.0040.01913.55
5.4.80.0030.02213.42
5.4.70.0030.02913.57
5.4.60.0030.02213.47
5.4.50.0040.03013.56
5.4.40.0040.02313.61
5.4.30.0080.02313.49
5.4.20.0060.02613.42
5.4.10.0030.02513.45
5.4.00.0020.02413.28
5.3.290.0030.03012.68
5.3.280.0060.03012.63
5.3.270.0020.03312.72
5.3.260.0030.02912.61
5.3.250.0080.02012.57
5.3.240.0040.02512.62
5.3.230.0060.02712.70
5.3.220.0130.02212.64
5.3.210.0060.03112.51
5.3.200.0010.03112.68
5.3.190.0060.03012.56
5.3.180.0030.02712.70
5.3.170.0030.02112.62
5.3.160.0040.02612.67
5.3.150.0030.03012.71
5.3.140.0030.01812.65
5.3.130.0030.02712.67
5.3.120.0060.02812.66
5.3.110.0010.02812.67
5.3.100.0020.02012.47
5.3.90.0050.02812.53
5.3.80.0050.02212.47
5.3.70.0040.02612.49
5.3.60.0040.02912.45
5.3.50.0030.02712.48
5.3.40.0040.02212.46
5.3.30.0030.02912.40
5.3.20.0060.02812.30
5.3.10.0040.02312.30
5.3.00.0050.02712.16
5.2.170.0000.06013.14
5.2.160.0030.06013.14
5.2.150.0030.05713.14
5.2.140.0030.05313.14
5.2.130.0030.03013.14
5.2.120.0000.06713.14
5.2.110.0000.06313.14
5.2.100.0030.06313.14
5.2.90.0000.04313.14
5.2.80.0000.07713.14
5.2.70.0000.05713.14
5.2.60.0030.04013.14
5.2.50.0030.04313.14
5.2.40.0030.05013.14
5.2.30.0000.06713.14
5.2.20.0130.06313.14
5.2.10.0000.03713.14
5.2.00.0030.06013.14
5.1.60.0030.05013.14
5.1.50.0030.05013.14
5.1.40.0070.03013.14
5.1.30.0070.03013.14
5.1.20.0000.05313.14
5.1.10.0030.02713.14
5.1.00.0000.03713.14
5.0.50.0000.03313.14
5.0.40.0000.05013.14
5.0.30.0030.05313.14
5.0.20.0000.04713.14
5.0.10.0030.03013.14
5.0.00.0100.03013.14
4.4.90.0070.02713.14
4.4.80.0000.03713.14
4.4.70.0030.02713.14
4.4.60.0000.03013.14
4.4.50.0000.01313.14
4.4.40.0000.04313.14
4.4.30.0000.02713.14
4.4.20.0030.01313.14
4.4.10.0000.02713.14
4.4.00.0030.05013.14
4.3.110.0000.03013.14
4.3.100.0000.03013.14
4.3.90.0030.02313.14
4.3.80.0000.04313.14
4.3.70.0030.03313.14
4.3.60.0030.02013.14
4.3.50.0000.04013.14
4.3.40.0030.05013.14
4.3.30.0070.03013.14
4.3.20.0030.03013.14
4.3.10.0030.03013.14
4.3.00.0000.03013.14

preferences:
70.53 ms | 401 KiB | 5 Q