3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class CommandId { private $name; private $time; private $hash; public function __construct($name) { $this->time = microtime(true); $this->name = trim($name); $this->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]"); } $id = new static($parts[0]); $id->time = (float) $parts[1]; $id->hash = $parts[2]; return $id; } 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); assert($one->equals($two)); var_dump((string) $one, (string) $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.3.120.0160.00014.94
7.3.110.0090.01214.83
7.3.100.0060.01214.76
7.3.90.0000.01614.84
7.3.80.0060.00915.01
7.3.70.0000.01314.86
7.3.60.0040.01114.75
7.3.50.0030.00914.85
7.3.40.0040.01214.82
7.3.30.0030.01014.91
7.3.20.0100.00616.53
7.3.10.0080.00616.75
7.3.00.0040.00716.77
7.2.240.0120.00915.30
7.2.230.0070.01115.35
7.2.220.0070.00715.17
7.2.210.0030.01215.18
7.2.200.0100.00015.06
7.2.190.0040.01515.23
7.2.180.0040.01215.05
7.2.170.0030.00615.30
7.2.160.0040.00715.00
7.2.150.0030.01216.77
7.2.140.0030.01316.82
7.2.130.0070.00716.91
7.2.120.0090.00716.94
7.2.110.0060.00716.83
7.2.100.0060.00816.86
7.2.90.0070.00717.01
7.2.80.0060.00816.96
7.2.70.0050.01117.06
7.2.60.0070.00716.98
7.2.50.0020.01216.97
7.2.40.0040.01016.93
7.2.30.0050.01216.97
7.2.20.0070.00617.06
7.2.10.0060.00916.84
7.2.00.0060.00817.53
7.1.330.0100.01015.88
7.1.320.0090.00915.87
7.1.310.0040.00815.60
7.1.300.0000.01215.66
7.1.290.0100.00315.78
7.1.280.0090.00915.82
7.1.270.0060.00315.88
7.1.260.0040.01115.61
7.1.250.0090.00515.71
7.1.70.0070.00317.09
7.1.60.0030.01017.12
7.1.50.0070.01417.06
7.1.00.0000.08322.45
7.0.200.0090.00616.75
7.0.140.0030.07321.92
7.0.60.0070.08019.81
7.0.50.0030.04317.91
7.0.40.0130.03320.30
7.0.30.0300.06720.33
7.0.20.0170.04320.07
7.0.10.0030.08020.23
7.0.00.0100.04720.05
5.6.280.0100.06720.91
5.6.210.0070.04020.52
5.6.200.0070.03718.16
5.6.190.0070.08020.50
5.6.180.3430.05020.57
5.6.170.0300.03720.51
5.6.160.0170.07320.46
5.6.150.0000.04318.19
5.6.140.0070.08318.14
5.6.130.0070.08718.15
5.6.120.0030.04720.88
5.6.110.0130.07721.13
5.6.100.0130.07721.02
5.6.90.0070.06721.09
5.6.80.0070.08020.38
5.6.70.0330.05320.38
5.5.350.0270.07320.50
5.5.340.0030.05717.98
5.5.330.0000.06720.27
5.5.320.0270.04720.29
5.5.310.0370.07320.30
5.5.300.0070.05717.95
5.5.290.0170.03717.96
5.5.280.0070.07320.77
5.5.270.0070.08320.78
5.5.260.0070.04020.77
5.5.250.0100.06320.68
5.5.240.0300.07320.36
5.4.450.0930.07019.45
5.4.440.0270.05719.61
5.4.430.0170.06019.63
5.4.420.0270.06319.57
5.4.410.0300.04319.57
5.4.400.0300.05718.62
5.4.390.0230.05718.77
5.4.380.0230.05318.75
5.4.370.0200.04718.46
5.4.360.0170.05018.50
5.4.350.0060.04212.04
5.4.340.0070.03712.04
5.4.320.0080.04312.51
5.4.310.0060.04512.51
5.4.300.0060.04612.52
5.4.290.0080.05612.51
5.4.280.0030.03912.41
5.4.270.0040.03812.41
5.4.260.0050.04712.41
5.4.250.0070.05319.09
5.4.240.0130.06719.04
5.4.230.0070.05019.01
5.4.220.0030.06018.98
5.4.210.0130.04718.96
5.4.200.0070.05018.64
5.4.190.0130.04718.73
5.4.180.0170.04318.78
5.4.170.0100.06318.89
5.4.160.0030.05318.78
5.4.150.0070.05318.88
5.4.140.0100.04316.60
5.4.130.0100.04716.57
5.4.120.0030.05016.50
5.4.110.0130.04316.57
5.4.100.0130.04016.51
5.4.90.0030.05016.50
5.4.80.0070.04716.63
5.4.70.0100.04716.46
5.4.60.0070.05016.55
5.4.50.0130.05016.39
5.4.40.0070.05016.50
5.4.30.0100.05316.50
5.4.20.0070.05016.61
5.4.10.0130.04316.52
5.4.00.0070.05015.88
5.3.290.0090.03912.80
5.3.280.0030.05014.66
5.3.270.0070.05314.69
5.3.260.0030.05314.63
5.3.250.0000.06014.70
5.3.240.0070.04714.52
5.3.230.0130.04314.76
5.3.220.0170.04714.75
5.3.210.0030.05314.57
5.3.200.0030.05314.66
5.3.190.0070.05014.67
5.3.180.0100.04714.61
5.3.170.0130.04314.59
5.3.160.0030.05014.74
5.3.150.0100.04714.67
5.3.140.0100.05314.55
5.3.130.0030.05314.56
5.3.120.0070.05714.65
5.3.110.0130.04314.55
5.3.100.0130.05014.13
5.3.90.0070.05014.25
5.3.80.0070.05014.05
5.3.70.0070.06314.02
5.3.60.0100.04714.09
5.3.50.0030.05013.96
5.3.40.0070.04714.15
5.3.30.0130.04013.94
5.3.20.0030.05013.78
5.3.10.0070.04713.89
5.3.00.0130.04013.73
5.2.170.0070.04011.37
5.2.160.0100.03311.24
5.2.150.0070.03711.14
5.2.140.0070.04711.25
5.2.130.0170.04711.27
5.2.120.0030.04010.94
5.2.110.0070.03711.07
5.2.100.0030.05311.12
5.2.90.0070.04711.19
5.2.80.0030.06011.07
5.2.70.0030.04011.16
5.2.60.0000.04311.02
5.2.50.0000.04311.12
5.2.40.0030.04011.07
5.2.30.0100.03711.04
5.2.20.0070.03311.05
5.2.10.0030.04010.87
5.2.00.0070.04010.81
5.1.60.0000.0379.93
5.1.50.0100.03010.21
5.1.40.0070.0309.91
5.1.30.0000.03710.56
5.1.20.0000.04010.45
5.1.10.0030.0379.92
5.1.00.0070.03310.17
5.0.50.0000.0308.75
5.0.40.0000.0308.39
5.0.30.0000.0438.20
5.0.20.0000.0378.18
5.0.10.0030.0308.22
5.0.00.0030.0438.22
4.4.90.0000.0237.33
4.4.80.0070.0177.33
4.4.70.0030.0207.33
4.4.60.0000.0237.33
4.4.50.0000.0237.33
4.4.40.0000.0377.33
4.4.30.0070.0177.33
4.4.20.0070.0207.33
4.4.10.0000.0237.33
4.4.00.0030.0307.33
4.3.110.0030.0207.33
4.3.100.0070.0277.33
4.3.90.0000.0207.33
4.3.80.0130.0307.33
4.3.70.0070.0177.33
4.3.60.0000.0237.33
4.3.50.0000.0237.33
4.3.40.0000.0337.33
4.3.30.0030.0207.33
4.3.20.0030.0207.33
4.3.10.0000.0237.33
4.3.00.0130.0237.23

preferences:
42.09 ms | 401 KiB | 5 Q