3v4l.org

run code in 300+ PHP versions simultaneously
<?php // note that copy() is a proper alternative to __clone() interface Any { function getHash(); function equals($other); } class Mutable implements Any { protected $baz; function __construct(string $baz){ $this->setBaz($baz); } function setBaz(string $baz){ $this->baz = $baz; } function getBaz(){ return $this->baz; } function getHash(){ return Immutable::CLASS . "|" . spl_object_hash($this); } function equals($other){ return $this->getHash() === $other->getHash(); } function copy(){ return new static($this->baz); } } class Immutable implements Any { protected $baz; function __construct(string $baz){ $this->baz = $baz; } function getHash(){ return Mutable::CLASS . "|" . $this->baz; } function equals($other){ return $this->getHash() === $other->getHash(); } function copy(){ return $this; } } var_dump((new Immutable("baz"))->equals(new Immutable("baz"))); // true var_dump((new Immutable("bar"))->equals(new Immutable("bar"))); // true var_dump((new Mutable("baz"))->equals(new Mutable("baz"))); // false var_dump((new Mutable("bar"))->equals(new Mutable("bar"))); // false

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.0150.00618.31
8.3.50.0070.01316.63
8.3.40.0170.00318.80
8.3.30.0100.00718.71
8.3.20.0040.00420.20
8.3.10.0080.00023.48
8.3.00.0040.00422.46
8.2.180.0150.00416.75
8.2.170.0120.00322.96
8.2.160.0130.00020.39
8.2.150.0050.00324.18
8.2.140.0000.00724.66
8.2.130.0110.00726.16
8.2.120.0000.00817.75
8.2.110.0030.00621.25
8.2.100.0090.00317.63
8.2.90.0030.00519.24
8.2.80.0000.00817.97
8.2.70.0080.00017.50
8.2.60.0040.00417.93
8.2.50.0040.00418.07
8.2.40.0080.00021.09
8.2.30.0040.00419.91
8.2.20.0000.00817.63
8.2.10.0040.00417.96
8.2.00.0040.00417.97
8.1.280.0140.00725.92
8.1.270.0060.00320.43
8.1.260.0100.00026.35
8.1.250.0050.00228.09
8.1.240.0100.00019.22
8.1.230.0000.01217.48
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0030.00617.35
8.1.190.0040.00417.35
8.1.180.0030.00618.10
8.1.170.0050.00318.66
8.1.160.0040.00422.09
8.1.150.0000.00818.84
8.1.140.0030.00517.39
8.1.130.0000.00717.59
8.1.120.0050.00317.37
8.1.110.0000.00817.41
8.1.100.0070.00017.48
8.1.90.0040.00417.54
8.1.80.0040.00417.53
8.1.70.0000.00717.50
8.1.60.0000.00817.68
8.1.50.0060.00317.59
8.1.40.0000.00817.59
8.1.30.0040.00417.67
8.1.20.0050.00317.52
8.1.10.0030.00617.51
8.1.00.0000.00817.46
8.0.300.0040.00418.77
8.0.290.0000.00716.75
8.0.280.0030.00318.36
8.0.270.0000.00717.29
8.0.260.0040.00417.34
8.0.250.0040.00417.04
8.0.240.0030.00516.99
8.0.230.0030.00316.95
8.0.220.0080.00016.80
8.0.210.0000.00716.86
8.0.200.0030.00316.82
8.0.190.0030.00616.95
8.0.180.0080.00016.78
8.0.170.0000.00916.88
8.0.160.0070.00016.84
8.0.150.0000.00716.70
8.0.140.0070.00016.83
8.0.130.0000.00613.32
8.0.120.0040.00416.75
8.0.110.0000.00717.00
8.0.100.0030.00616.71
8.0.90.0000.00816.75
8.0.80.0120.00316.81
8.0.70.0070.00016.73
8.0.60.0000.00716.83
8.0.50.0040.00416.87
8.0.30.0130.00616.99
8.0.20.0060.01217.40
8.0.10.0000.00817.14
8.0.00.0090.00816.85
7.4.330.0050.00015.08
7.4.320.0000.00716.59
7.4.300.0090.00016.48
7.4.290.0000.00716.41
7.4.280.0050.00316.57
7.4.270.0070.00016.50
7.4.260.0000.00716.49
7.4.250.0000.00816.42
7.4.240.0010.00616.55
7.4.230.0000.00816.63
7.4.220.0130.00316.51
7.4.210.0070.01016.65
7.4.200.0030.00316.68
7.4.160.0030.01316.66
7.4.150.0060.01117.40
7.4.140.0130.00717.86
7.4.130.0160.00216.60
7.4.120.0100.01016.71
7.4.110.0120.01216.58
7.4.100.0090.00916.62
7.4.90.0040.01316.51
7.4.80.0100.00719.39
7.4.70.0130.00716.56
7.4.60.0030.01216.70
7.4.50.0030.00316.41
7.4.40.0080.01216.48
7.4.30.0060.01216.63
7.4.00.0070.01014.95
7.3.330.0050.00013.28
7.3.320.0000.00613.32
7.3.310.0030.00316.14
7.3.300.0030.00316.34
7.3.290.0080.00916.33
7.3.280.0070.00916.36
7.3.270.0000.01717.40
7.3.260.0090.00916.46
7.3.250.0090.01016.49
7.3.240.0030.01416.58
7.3.230.0110.00816.55
7.3.210.0060.01516.08
7.3.200.0030.01719.39
7.3.190.0030.01316.67
7.3.180.0030.01316.38
7.3.170.0030.01316.38
7.3.160.0040.01916.30
7.3.120.0060.01214.59
7.3.110.0170.00314.78
7.3.100.0040.00814.72
7.3.90.0060.00614.69
7.3.80.0140.00414.60
7.3.70.0070.00714.69
7.3.60.0120.00614.52
7.3.50.0080.00314.81
7.3.40.0030.00614.74
7.3.30.0030.00514.91
7.3.20.0060.00616.39
7.3.10.0070.00616.33
7.3.00.0030.00916.47
7.2.330.0040.01316.79
7.2.320.0130.00616.68
7.2.310.0030.01316.82
7.2.300.0070.01716.57
7.2.290.0100.01316.79
7.2.240.0140.00715.08
7.2.230.0040.00815.03
7.2.220.0030.00914.92
7.2.210.0040.00815.19
7.2.200.0000.00814.86
7.2.190.0060.00615.19
7.2.180.0000.01115.11
7.2.170.0100.00315.23
7.2.160.0030.00814.75
7.2.150.0130.00016.72
7.2.140.0080.00616.90
7.2.130.0030.01016.96
7.2.120.0030.00916.86
7.2.110.0090.00916.95
7.2.100.0070.00916.75
7.2.90.0040.01116.96
7.2.80.0060.01016.58
7.2.70.0060.00916.75
7.2.60.0080.00816.88
7.2.50.0030.00817.06
7.2.40.0050.00716.87
7.2.30.0030.00916.83
7.2.20.0090.00316.67
7.2.10.0120.00516.90
7.2.00.0080.00617.84
7.1.330.0090.00615.39
7.1.320.0030.01015.47
7.1.310.0070.00315.78
7.1.300.0000.00815.62
7.1.290.0040.00815.77
7.1.280.0030.00715.73
7.1.270.0030.01015.68
7.1.260.0070.00715.87
7.1.250.0080.00515.64
7.1.200.0040.01115.88
7.1.100.0080.01218.15
7.1.70.0040.00416.82
7.1.60.0090.01220.03
7.1.50.0040.00716.91
7.1.00.0030.07722.30
7.0.200.0130.00616.39
7.0.60.0130.07719.91
7.0.50.0230.07018.00
7.0.40.0100.06020.39
7.0.30.0430.06320.21
7.0.20.0370.07320.24
7.0.10.0070.08020.16
7.0.00.0000.09020.24
5.6.280.0030.06720.89
5.6.210.0070.05720.52
5.6.200.0070.05718.19
5.6.190.0170.05020.28
5.6.180.3770.04720.39
5.6.170.0330.05320.50
5.6.160.0070.08320.48
5.6.150.0070.04018.18
5.6.140.0100.03718.21
5.6.130.0070.05318.18
5.6.120.0100.05321.02
5.6.110.0130.07321.02
5.6.100.0030.09020.94
5.6.90.0070.09021.11
5.6.80.0100.03320.37
5.6.70.4530.03720.37
5.5.350.0200.04720.54
5.5.340.0170.04718.04
5.5.330.0000.05320.43
5.5.320.0500.06720.22
5.5.310.0230.08320.39
5.5.300.0000.04718.08
5.5.290.0100.05017.95
5.5.280.0070.06320.79
5.5.270.0100.07720.91
5.5.260.0130.07020.91
5.5.250.0100.03320.72
5.5.240.0130.08020.25
5.4.450.0700.07019.59
5.4.440.0700.06319.47
5.4.430.0670.05319.29
5.4.420.0630.06019.33
5.4.410.0700.07019.26
5.4.400.0800.06319.25
5.4.390.0730.06019.25
5.4.380.0800.04719.29
5.4.370.0800.05019.22
5.4.360.0770.07719.13
5.4.350.0670.05319.13
5.4.340.0670.04319.29
5.4.320.0670.06319.23
5.4.310.0700.05319.33
5.4.300.0700.06019.07
5.4.290.0700.04719.12
5.4.280.0670.05319.13
5.4.270.0770.05018.85
5.4.260.0700.05019.32
5.4.250.0670.05319.13
5.4.240.0630.05718.84
5.4.230.0770.06319.13
5.4.220.0670.05319.23
5.4.210.0700.05318.99
5.4.200.0770.04716.84
5.4.190.0700.05019.09
5.4.180.0630.06319.08
5.4.170.0730.05319.09
5.4.160.0770.04718.99
5.4.150.0930.03319.16
5.4.140.0870.03316.47
5.4.130.0930.03716.36
5.4.120.0770.04716.49
5.4.110.0600.05716.38
5.4.100.0800.05316.50
5.4.90.0700.05016.40
5.4.80.0700.05016.60
5.4.70.0670.05716.48
5.4.60.0170.03716.38
5.4.50.0000.07316.34
5.4.40.0270.04016.35
5.4.30.0300.03016.55
5.4.20.0330.06716.55

preferences:
50.03 ms | 400 KiB | 5 Q