3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class CommandId { private $name; private $time; private $hash; public function __construct($name, $time = null, $hash = null) { $this->time = (float) $time ?: microtime(true); $this->name = trim($name); $this->hash = $hash ?: hash('crc32', rand(0, $this->time)); if (empty($this->name)) { throw new DomainException('Name must not be empty'); } } public static function fromString($idString) { $parts = explode('_', $idString); if (count($parts) != 3) { throw new DomainException("Unexpected format [$idString]"); } return new static($parts[0], $parts[1], $parts[2]); } public function name() { return $this->name; } public function time() { return $this->time; } public function equals(self $other) { return ($this->name == $other->name && $this->time == $other->time && $this->hash == $other->hash ); } public function __toString() { return implode('_', [$this->name, $this->time, $this->hash]); } } $one = new CommandId('foo'); $two = CommandId::fromString((string) $one); var_dump((string) $one, (string) $two, $one->equals($two));

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.0130.00315.14
7.4.00.0100.01014.98
7.3.130.0110.00614.99
7.3.120.0090.00914.98
7.3.110.0030.01614.79
7.3.100.0080.00714.96
7.3.90.0060.00814.77
7.3.80.0050.00815.10
7.3.70.0080.00414.86
7.3.60.0040.01014.95
7.3.50.0070.00715.04
7.3.40.0050.00614.99
7.3.30.0080.00814.70
7.3.20.0030.00916.73
7.3.10.0090.00516.68
7.3.00.0050.00716.75
7.2.260.0090.01015.15
7.2.250.0050.01015.04
7.2.240.0120.00515.35
7.2.230.0060.01015.04
7.2.220.0080.00615.06
7.2.210.0060.00914.95
7.2.200.0060.00915.14
7.2.190.0050.01115.17
7.2.180.0070.00715.31
7.2.170.0020.01315.15
7.2.160.0030.00714.96
7.2.150.0070.00516.91
7.2.140.0030.00816.87
7.2.130.0050.01116.99
7.2.120.0020.01017.09
7.2.110.0100.00516.75
7.2.100.0030.01316.93
7.2.90.0070.00817.07
7.2.80.0060.01116.82
7.2.70.0060.00717.01
7.2.60.0100.00717.15
7.2.50.0030.01017.04
7.2.40.0120.00116.94
7.2.30.0050.01117.01
7.2.20.0060.00616.94
7.2.10.0090.00516.89
7.2.00.0080.00817.15
7.1.330.0100.00515.77
7.1.320.0040.00815.85
7.1.310.0050.00815.93
7.1.300.0070.00715.58
7.1.290.0060.00615.70
7.1.280.0080.00615.65
7.1.270.0030.00915.66
7.1.260.0070.00815.65
7.1.250.0080.00615.73
7.1.240.0060.00615.62
7.1.230.0070.00715.78
7.1.220.0030.01215.77
7.1.210.0090.00515.82
7.1.200.0080.00615.63
7.1.190.0040.00715.81
7.1.180.0030.00815.76
7.1.170.0060.00715.66
7.1.160.0010.01015.76
7.1.150.0070.00615.70
7.1.140.0060.00615.85
7.1.130.0040.00915.68
7.1.120.0080.00515.71
7.1.110.0060.00915.86
7.1.100.0030.00815.73
7.1.90.0060.00915.87
7.1.80.0110.00115.63
7.1.70.0080.00616.06
7.1.60.0020.01517.02
7.1.50.0050.01116.19
7.1.40.0060.00615.87
7.1.30.0060.00615.73
7.1.20.0070.00515.75
7.1.10.0080.00715.75
7.1.00.0060.02817.88
7.0.330.0070.00515.36
7.0.320.0070.00515.54
7.0.310.0070.00815.29
7.0.300.0050.00715.38
7.0.290.0060.00815.37
7.0.280.0070.00815.32
7.0.270.0030.00815.24
7.0.260.0030.01015.41
7.0.250.0060.00615.50
7.0.240.0090.00315.50
7.0.230.0050.00915.48
7.0.220.0070.00915.52
7.0.210.0060.00915.46
7.0.200.0040.01115.82
7.0.190.0040.01115.34
7.0.180.0040.00915.39
7.0.170.0040.00715.48
7.0.160.0030.01015.43
7.0.150.0060.00515.46
7.0.140.0070.02417.60
7.0.130.0010.00715.47
7.0.120.0050.00515.54
7.0.110.0060.00815.53
7.0.100.0040.02816.91
7.0.90.0030.03516.86
7.0.80.0080.02416.97
7.0.70.0130.02317.06
7.0.60.0080.02316.86
7.0.50.0060.02317.16
7.0.40.0080.02815.66
7.0.30.0050.02415.76
7.0.20.0100.03015.64
7.0.10.0110.02615.58
7.0.00.0040.02815.73
5.6.400.0030.01014.58
5.6.390.0000.01114.69
5.6.380.0030.01014.59
5.6.370.0050.00914.73
5.6.360.0030.00814.38
5.6.350.0100.00514.48
5.6.340.0100.00414.57
5.6.330.0080.00614.34
5.6.320.0050.01014.56
5.6.310.0030.01014.15
5.6.300.0050.00514.67
5.6.290.0020.00914.43
5.6.280.0030.03016.65
5.6.270.0060.00814.45
5.6.260.0090.00514.72
5.6.250.0050.02216.59
5.6.240.0060.02816.51
5.6.230.0060.03016.66
5.6.220.0070.03216.54
5.6.210.0040.02516.54
5.6.200.0070.03316.63
5.6.190.0010.02716.75
5.6.180.0040.02316.65
5.6.170.0050.02716.78
5.6.160.0070.02116.63
5.6.150.0060.02816.68
5.6.140.0060.01816.68
5.6.130.0130.01516.62
5.6.120.0070.01816.71
5.6.110.0070.01716.74
5.6.100.0040.02916.52
5.6.90.0070.02116.58
5.6.80.0070.01616.37
5.6.70.0030.01816.40
5.6.60.0050.01916.40
5.6.50.0020.02816.39
5.6.40.0030.01916.34
5.6.30.0070.01816.30
5.6.20.0020.02116.40
5.6.10.0080.01516.41
5.6.00.0050.01616.26
5.5.380.0090.02716.45
5.5.370.0080.02516.46
5.5.360.0090.02816.39
5.5.350.0070.02616.40
5.5.340.0050.03416.57
5.5.330.0090.01916.30
5.5.320.0090.02816.45
5.5.310.0080.02916.33
5.5.300.0040.02116.53
5.5.290.0080.01716.42
5.5.280.0060.02016.48
5.5.270.0070.01916.55
5.5.260.0000.02616.47
5.5.250.0030.01916.32
5.5.240.0080.01716.29
5.5.230.0030.01916.31
5.5.220.0060.01916.26
5.5.210.0040.02116.30
5.5.200.0030.02216.31
5.5.190.0020.02216.17
5.5.180.0080.02016.31
5.5.170.0020.01014.41
5.5.160.0060.01316.29
5.5.150.0040.01916.33
5.5.140.0010.02116.33
5.5.130.0060.02016.24
5.5.120.0050.01616.32
5.5.110.0040.01516.11
5.5.100.0040.01916.34
5.5.90.0020.02116.12
5.5.80.0040.01916.26
5.5.70.0070.02516.30
5.5.60.0010.02616.16
5.5.50.0060.02816.27
5.5.40.0040.02816.11
5.5.30.0090.03016.29
5.5.20.0020.03316.21
5.5.10.0070.02016.06
5.5.00.0050.03316.19
5.4.450.0040.02013.99
5.4.440.0040.01713.89
5.4.430.0030.02013.91
5.4.420.0040.02313.90
5.4.410.0040.01613.92
5.4.400.0050.01813.71
5.4.390.0050.01713.79
5.4.380.0040.01813.81
5.4.370.0030.01813.87
5.4.360.0070.01413.75
5.4.350.0050.01713.85
5.4.340.0010.02213.86
5.4.330.0010.00710.99
5.4.320.0030.01613.83
5.4.310.0050.01513.88
5.4.300.0030.01613.76
5.4.290.0020.01713.89
5.4.280.0020.02213.65
5.4.270.0020.01813.85
5.4.260.0030.01313.69
5.4.250.0020.01613.67
5.4.240.0040.01813.79
5.4.230.0080.02313.72
5.4.220.0050.02213.59
5.4.210.0030.02913.83
5.4.200.0030.01813.82
5.4.190.0060.02313.71
5.4.180.0140.02313.75
5.4.170.0030.01913.65
5.4.160.0060.01613.68
5.4.150.0060.01913.60
5.4.140.0040.02612.91
5.4.130.0030.03012.92
5.4.120.0050.01412.99
5.4.110.0080.02312.82
5.4.100.0040.01812.94
5.4.90.0050.03112.81
5.4.80.0030.01712.88
5.4.70.0030.02812.83
5.4.60.0030.02812.91
5.4.50.0030.02812.94
5.4.40.0080.01612.87
5.4.30.0090.02912.86
5.4.20.0010.03212.90
5.4.10.0090.02712.84
5.4.00.0030.02712.70
5.3.290.0030.01511.79
5.3.280.0040.01911.69
5.3.270.0060.02911.68
5.3.260.0030.03011.70
5.3.250.0060.02211.68
5.3.240.0090.02611.62
5.3.230.0040.02311.72
5.3.220.0030.02411.66
5.3.210.0030.01811.74
5.3.200.0080.02211.65
5.3.190.0040.02811.72
5.3.180.0070.02211.84
5.3.170.0060.02911.82
5.3.160.0080.01611.79
5.3.150.0050.02911.72
5.3.140.0030.02811.79
5.3.130.0010.03611.77
5.3.120.0030.02711.79
5.3.110.0050.02011.81
5.3.100.0060.02711.60
5.3.90.0080.02611.61
5.3.80.0070.02311.51
5.3.70.0010.01911.54
5.3.60.0080.02511.64
5.3.50.0030.01711.53
5.3.40.0030.02911.55
5.3.30.0060.01611.46
5.3.20.0010.03011.43
5.3.10.0060.02711.25
5.3.00.0030.02011.29
5.2.170.0070.06011.29
5.2.160.0030.06011.21
5.2.150.0070.04011.24
5.2.140.0070.04711.05
5.2.130.0030.07011.03
5.2.120.0070.05011.16
5.2.110.0130.05011.21
5.2.100.0100.06711.02
5.2.90.0070.03011.04
5.2.80.0070.06311.20
5.2.70.0100.05011.08
5.2.60.0100.04311.10
5.2.50.0000.05711.13
5.2.40.0070.05711.00
5.2.30.0030.05711.10
5.2.20.0130.05010.96
5.2.10.0000.05010.93
5.2.00.0000.06010.79
5.1.60.0030.03010.08
5.1.50.0030.04710.09
5.1.40.0030.03710.09
5.1.30.0070.05710.48
5.1.20.0030.05310.50
5.1.10.0030.06010.17
5.1.00.0000.0409.92
5.0.50.0030.0238.61
5.0.40.0070.0338.46
5.0.30.0100.0638.28
5.0.20.0070.0378.24
5.0.10.0070.0208.25
5.0.00.0070.0478.24
4.4.90.0000.0208.24
4.4.80.0030.0338.24
4.4.70.0000.0338.24
4.4.60.0000.0278.24
4.4.50.0030.0338.24
4.4.40.0130.0438.24
4.4.30.0030.0338.24
4.4.20.0030.0178.24
4.4.10.0030.0338.24
4.4.00.0030.0438.24
4.3.110.0070.0278.24
4.3.100.0000.0278.24
4.3.90.0030.0308.24
4.3.80.0000.0308.24
4.3.70.0000.0338.24
4.3.60.0100.0278.24
4.3.50.0030.0338.24
4.3.40.0000.0438.24
4.3.30.0000.0208.24
4.3.20.0070.0308.24
4.3.10.0030.0278.24
4.3.00.0000.0178.24

preferences:
42.32 ms | 401 KiB | 5 Q