3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MessageId { protected static $partSeperator = '_'; protected static $hashAlgorithm = 'crc32'; protected static $validNames = ['foo']; 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); } } $foo = new MessageId('foo'); var_dump((string) $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.0120.00414.85
7.4.00.0060.01315.04
7.3.130.0110.00714.70
7.3.120.0070.01114.71
7.3.110.0100.00814.80
7.3.100.0090.00615.04
7.3.90.0030.01014.84
7.3.80.0070.00614.87
7.3.70.0070.00914.81
7.3.60.0080.00714.88
7.3.50.0060.00814.87
7.3.40.0050.00814.96
7.3.30.0000.01514.74
7.3.20.0060.00616.84
7.3.10.0050.01116.56
7.3.00.0100.00616.54
7.2.260.0060.01015.37
7.2.250.0050.01415.14
7.2.240.0060.00815.20
7.2.230.0080.00815.35
7.2.220.0090.00615.23
7.2.210.0100.00715.16
7.2.200.0030.00815.20
7.2.190.0120.00614.97
7.2.180.0050.01115.06
7.2.170.0040.00915.26
7.2.160.0060.00614.99
7.2.150.0000.01016.82
7.2.140.0060.00317.13
7.2.130.0080.00816.94
7.2.120.0080.00716.83
7.2.110.0060.01116.93
7.2.100.0080.00717.02
7.2.90.0100.00717.08
7.2.80.0070.00816.94
7.2.70.0050.00916.99
7.2.60.0070.00917.00
7.2.50.0070.00717.00
7.2.40.0030.01116.96
7.2.30.0060.01217.05
7.2.20.0030.01216.96
7.2.10.0110.00416.92
7.2.00.0050.00917.65
7.1.330.0080.00715.80
7.1.320.0030.01015.64
7.1.310.0100.00415.72
7.1.300.0090.00715.50
7.1.290.0090.00515.72
7.1.280.0070.00715.74
7.1.270.0100.00415.62
7.1.260.0050.00715.65
7.1.250.0060.00915.52
7.1.240.0040.01115.64
7.1.230.0110.00015.34
7.1.220.0060.00615.71
7.1.210.0030.00915.79
7.1.200.0070.00715.69
7.1.190.0030.01115.70
7.1.180.0030.01415.80
7.1.170.0040.00715.69
7.1.160.0070.00715.80
7.1.150.0040.01115.71
7.1.140.0030.00815.69
7.1.130.0030.01015.44
7.1.120.0000.01615.46
7.1.110.0060.00615.77
7.1.100.0070.00415.39
7.1.90.0130.00315.84
7.1.80.0030.01215.75
7.1.70.0020.00916.43
7.1.60.0090.00917.45
7.1.50.0080.00816.39
7.1.40.0110.00415.65
7.1.30.0000.01515.75
7.1.20.0070.01015.63
7.1.10.0030.01015.77
7.1.00.0020.03819.17
7.0.330.0040.00715.38
7.0.320.0080.00615.28
7.0.310.0030.00615.23
7.0.300.0070.00715.34
7.0.290.0080.00615.27
7.0.280.0040.01115.34
7.0.270.0030.01015.55
7.0.260.0000.01215.18
7.0.250.0100.00315.09
7.0.240.0030.00715.28
7.0.230.0080.00015.48
7.0.220.0090.00315.49
7.0.210.0040.01115.17
7.0.200.0110.00815.11
7.0.190.0000.01215.54
7.0.180.0030.01015.41
7.0.170.0100.00315.16
7.0.160.0080.00015.20
7.0.150.0090.00315.31
7.0.140.0070.03818.64
7.0.130.0000.01115.51
7.0.120.0040.00415.18
7.0.110.0120.00415.45
7.0.100.0070.01015.47
7.0.90.0000.01515.16
7.0.80.0070.00715.36
7.0.70.0080.00815.39
7.0.60.0090.04317.58
7.0.50.0080.03216.64
7.0.40.0050.03616.75
7.0.30.0150.02616.85
7.0.20.0120.03516.79
7.0.10.0030.02516.99
7.0.00.0020.04716.70
5.6.400.0030.01014.26
5.6.390.0060.00614.41
5.6.380.0080.00814.59
5.6.370.0030.00714.20
5.6.360.0030.00614.53
5.6.350.0030.01314.64
5.6.340.0000.01614.18
5.6.330.0100.00714.41
5.6.320.0030.01014.20
5.6.310.0030.00814.02
5.6.300.0060.00914.33
5.6.290.0080.00314.52
5.6.280.0030.03917.71
5.6.270.0090.00614.64
5.6.260.0110.00414.17
5.6.250.0030.01114.51
5.6.240.0100.00314.34
5.6.230.0100.00314.68
5.6.220.0110.00714.62
5.6.210.0060.04517.45
5.6.200.0100.03416.33
5.6.190.0070.04717.27
5.6.180.0150.03617.48
5.6.170.0130.04817.48
5.6.160.0080.03617.58
5.6.150.0100.03516.30
5.6.140.0020.02816.35
5.6.130.0050.04416.16
5.6.120.0050.02517.61
5.6.110.0080.02317.87
5.6.100.0060.03817.74
5.6.90.0110.03517.82
5.6.80.0090.04017.54
5.6.70.0060.00914.27
5.6.60.0060.00614.32
5.6.50.0040.00814.49
5.6.40.0030.01514.16
5.6.30.0030.00714.30
5.6.20.0060.00914.30
5.6.10.0030.01414.44
5.6.00.0080.00414.52
5.5.380.0100.00314.51
5.5.370.0070.01014.38
5.5.360.0060.00914.32
5.5.350.2180.02217.39
5.5.340.0010.03416.24
5.5.330.0100.03817.30
5.5.320.0030.04017.28
5.5.310.0130.04817.12
5.5.300.0080.03016.27
5.5.290.0060.02716.01
5.5.280.0040.03917.44
5.5.270.0040.02417.54
5.5.260.0100.04117.55
5.5.250.0090.04417.49
5.5.240.0320.02517.33
5.5.230.0060.00614.15
5.5.220.0000.01014.30
5.5.210.0030.01014.39
5.5.200.0070.00714.01
5.5.190.0000.01214.44
5.5.180.0060.01014.34
5.5.170.0060.01014.18
5.5.160.0100.00614.43
5.5.150.0080.00614.39
5.5.140.0050.00814.16
5.5.130.0000.01414.39
5.5.120.0100.00314.26
5.5.110.0000.01014.27
5.5.100.0130.00314.35
5.5.90.0070.00714.34
5.5.80.0110.00414.04
5.5.70.0030.01314.41
5.5.60.0070.00714.44
5.5.50.0090.00614.43
5.5.40.0000.00814.26
5.5.30.0040.01114.40
5.5.20.0040.00414.31
5.5.10.0140.00313.99
5.5.00.0000.01114.38
5.4.450.1630.02615.33
5.4.440.1640.02015.22
5.4.430.1580.02515.29
5.4.420.1950.02015.32
5.4.410.1670.01815.23
5.4.400.1580.02315.03
5.4.390.1550.02515.08
5.4.380.1980.02414.90
5.4.370.1570.02014.98
5.4.360.1710.02315.17
5.4.350.1630.02315.10
5.4.340.1600.02215.13
5.4.330.0080.00610.95
5.4.320.1630.02115.25
5.4.310.1780.01815.08
5.4.300.1650.01814.97
5.4.290.1570.02114.99
5.4.280.1630.02214.86
5.4.270.1640.02315.05
5.4.260.1640.02115.09
5.4.250.1630.02914.96
5.4.240.1880.02514.99
5.4.230.1530.02215.10
5.4.220.1600.01815.02
5.4.210.1570.01714.84
5.4.200.1410.02115.03
5.4.190.1560.01715.15
5.4.180.1570.02014.96
5.4.170.1430.02315.20
5.4.160.2070.02614.89
5.4.150.1520.02214.96
5.4.140.1350.01613.73
5.4.130.2110.02113.62
5.4.120.1530.02013.64
5.4.110.1520.02213.82
5.4.100.1540.01813.65
5.4.90.1630.02313.74
5.4.80.1700.01813.60
5.4.70.1780.02513.62
5.4.60.1570.02013.64
5.4.50.1650.02313.71
5.4.40.1650.02013.62
5.4.30.1630.01713.80
5.4.20.1630.02013.71
5.4.10.1770.02413.77
5.4.00.1650.02413.38
5.3.290.1690.02212.49
5.3.280.1600.02412.48
5.3.270.1670.02512.49
5.3.260.1670.02212.48
5.3.250.1590.02212.33
5.3.240.1680.02312.42
5.3.230.1580.02312.40
5.3.220.1650.02212.42
5.3.210.1680.01812.41
5.3.200.1650.01912.41
5.3.190.1740.02412.49
5.3.180.1680.02212.62
5.3.170.1670.02212.50
5.3.160.1650.02612.58
5.3.150.2050.02112.58
5.3.140.1550.01812.43
5.3.130.1650.02312.38
5.3.120.1780.02412.35
5.3.110.1670.02512.47
5.3.100.1430.02012.16
5.3.90.1660.02312.08
5.3.80.1540.01912.11
5.3.70.1630.02112.08
5.3.60.1630.02212.18
5.3.50.1700.02012.06
5.3.40.1630.02012.12
5.3.30.1520.02312.08
5.3.20.1690.02012.07
5.3.10.1600.01911.93
5.3.00.1530.02211.70
5.2.170.2530.02711.05
5.2.160.2800.03311.29
5.2.150.2770.03311.36
5.2.140.2900.02011.04
5.2.130.2800.02711.23
5.2.120.2770.03311.02
5.2.110.2800.03011.10
5.2.100.2530.03011.26
5.2.90.2530.02711.01
5.2.80.2870.03311.03
5.2.70.2770.03311.31
5.2.60.2400.02710.99
5.2.50.2930.02710.99
5.2.40.2070.02010.99
5.2.30.2130.03010.99
5.2.20.2330.02710.99
5.2.10.2230.02310.99
5.2.00.2130.03010.99
5.1.60.2000.03011.00
5.1.50.2300.03011.00
5.1.40.2070.02311.01
5.1.30.2830.02011.01
5.1.20.2300.02711.04
5.1.10.2030.02711.05
5.1.00.2100.02011.05
5.0.50.1130.02711.05
5.0.40.1030.02011.05
5.0.30.1170.03311.05
5.0.20.1000.02011.07
5.0.10.1270.02311.08
5.0.00.1100.02311.10
4.4.90.1230.01711.10
4.4.80.1100.01011.11
4.4.70.1230.02311.12
4.4.60.1070.01711.13
4.4.50.1130.01711.13
4.4.40.1270.02711.13
4.4.30.1000.01711.13
4.4.20.1000.01711.13
4.4.10.1030.01311.13
4.4.00.1200.03011.13
4.3.110.1030.01311.14
4.3.100.1270.01711.16
4.3.90.1200.01711.18
4.3.80.1200.03011.18
4.3.70.1000.01711.19
4.3.60.1300.01711.20
4.3.50.1030.01311.20
4.3.40.1000.02311.20
4.3.30.0700.02311.20
4.3.20.0500.01311.20
4.3.10.0730.02011.21
4.3.00.0600.01711.22

preferences:
35.83 ms | 401 KiB | 5 Q