3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ImmutableObject { private $property; public function __construct($property) { $this->property = $property; } public function withProperty($property) { $clone = clone($this); $clone->property = $property; return $clone; } public function getProperty() { return $this->property; } } class BrokenImmutableObject { private $property; public function __construct($property) { $this->property = $property; } public function withProperty($property) { if ($property == $this->property) { return $this; } $clone = clone($this); $clone->property = $property; return $clone; } public function getProperty() { return $this->property; } } function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);} foreach (array('ImmutableObject', 'BrokenImmutableObject') as $class) { print "\n".$class."\n".str_repeat('=', strlen($class))."\n\n"; // Expectation, $start will always have value 'start' $start = new $class('start'); // Expectation, $next is an immutable copy of $start with value 'start' $next = $start->withProperty('start'); // Expectation, $end is an immutable copy of $start with value 'end' $end = $start->withProperty('end'); it('has the value "start" (has value "'.$start->getProperty().'")', 'start' === $start->getProperty()); it('has the value "start" (has value "'.$next->getProperty().'")', 'start' === $next->getProperty()); it('has the value "end" (has value "'.$end->getProperty().'")', 'end' === $end->getProperty()); print "\n"; }

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.0070.01018.30
8.3.50.0150.00622.05
8.3.40.0070.00718.61
8.3.30.0060.00919.04
8.3.20.0040.00420.21
8.3.10.0000.00823.48
8.3.00.0040.00419.03
8.2.180.0000.01418.30
8.2.170.0070.01422.96
8.2.160.0100.00322.04
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0040.00421.07
8.2.110.0030.00621.89
8.2.100.0090.00319.58
8.2.90.0000.00719.05
8.2.80.0030.00617.97
8.2.70.0060.00317.75
8.2.60.0000.00818.03
8.2.50.0000.00818.07
8.2.40.0070.00318.22
8.2.30.0000.00718.16
8.2.20.0090.00017.72
8.2.10.0040.00418.04
8.2.00.0000.00817.73
8.1.280.0080.00825.92
8.1.270.0040.00418.75
8.1.260.0000.00726.35
8.1.250.0070.00028.09
8.1.240.0080.00023.84
8.1.230.0100.00019.10
8.1.220.0080.00017.74
8.1.210.0080.00018.77
8.1.200.0070.00317.35
8.1.190.0000.00817.22
8.1.180.0050.00318.10
8.1.170.0000.00818.57
8.1.160.0050.00222.00
8.1.150.0040.00418.91
8.1.140.0000.00819.15
8.1.130.0070.00017.84
8.1.120.0000.00717.54
8.1.110.0020.00517.52
8.1.100.0000.00717.52
8.1.90.0000.00717.34
8.1.80.0030.00317.50
8.1.70.0060.00317.41
8.1.60.0090.00317.52
8.1.50.0040.00417.48
8.1.40.0070.00017.49
8.1.30.0000.00817.54
8.1.20.0050.00217.71
8.1.10.0070.00317.61
8.1.00.0000.00817.47
8.0.300.0040.00418.77
8.0.290.0000.00816.75
8.0.280.0000.00718.50
8.0.270.0030.00317.31
8.0.260.0030.00317.27
8.0.250.0050.00317.02
8.0.240.0050.00316.96
8.0.230.0040.00416.97
8.0.220.0000.00716.84
8.0.210.0000.00716.97
8.0.200.0030.00517.07
8.0.190.0050.00317.01
8.0.180.0040.00416.97
8.0.170.0040.00416.95
8.0.160.0030.00516.91
8.0.150.0030.00416.91
8.0.140.0070.00016.81
8.0.130.0030.00313.38
8.0.120.0080.00016.94
8.0.110.0040.00416.86
8.0.100.0030.00517.01
8.0.90.0070.00016.79
8.0.80.0080.00716.98
8.0.70.0040.00416.82
8.0.60.0080.00017.01
8.0.50.0070.00016.73
8.0.30.0110.01317.09
8.0.20.0070.01317.40
8.0.10.0050.00317.01
8.0.00.0090.00916.75
7.4.330.0060.00015.08
7.4.320.0000.00616.45
7.4.300.0060.00016.56
7.4.290.0080.00016.56
7.4.280.0040.00416.61
7.4.270.0000.00816.58
7.4.260.0030.00616.53
7.4.250.0000.00816.47
7.4.240.0050.00216.60
7.4.230.0000.00716.63
7.4.220.0170.01016.63
7.4.210.0090.00616.63
7.4.200.0050.00216.70
7.4.160.0100.01316.68
7.4.150.0030.01517.40
7.4.140.0110.00717.86
7.4.130.0100.01116.55
7.4.120.0140.00616.67
7.4.110.0180.00316.57
7.4.100.0120.00616.48
7.4.90.0070.01016.63
7.4.80.0100.01419.39
7.4.70.0040.01216.68
7.4.60.0130.01016.48
7.4.50.0050.00316.43
7.4.40.0100.00716.51
7.4.30.0110.01216.61
7.4.00.0090.00314.89
7.3.330.0000.00613.39
7.3.320.0000.00613.37
7.3.310.0070.00016.42
7.3.300.0000.00716.24
7.3.290.0060.00816.37
7.3.280.0070.01216.38
7.3.270.0070.01117.40
7.3.260.0080.00916.63
7.3.250.0040.01516.62
7.3.240.0090.00916.38
7.3.230.0090.01116.67
7.3.210.0110.00716.44
7.3.200.0100.00619.39
7.3.190.0090.00616.59
7.3.180.0030.01316.37
7.3.170.0040.01216.48
7.3.160.0100.00716.37
7.3.10.0070.00416.70
7.3.00.0000.00916.37
7.2.330.0130.00716.66
7.2.320.0040.01416.93
7.2.310.0000.01716.77
7.2.300.0080.01216.64
7.2.290.0130.01016.76
7.2.130.0030.01016.67
7.2.120.0060.00917.03
7.2.110.0060.01016.90
7.2.100.0060.00716.93
7.2.90.0030.01016.82
7.2.80.0070.01017.13
7.2.70.0040.00817.15
7.2.60.0050.00916.82
7.2.50.0070.00716.97
7.2.40.0030.00717.01
7.2.30.0060.00616.91
7.2.20.0070.01016.98
7.2.10.0100.00317.01
7.2.00.0050.01018.31
7.1.250.0000.00915.72
7.1.200.0120.00315.82
7.1.100.0000.01118.17
7.1.70.0000.00717.34
7.1.60.0060.01919.46
7.1.50.0070.01317.01
7.1.00.0130.06322.35
7.0.200.0000.00916.89
7.0.140.0030.03321.97
7.0.110.0070.05020.09
7.0.100.0130.06719.91
7.0.90.0070.09320.08
7.0.80.0130.07019.95
7.0.70.0170.03719.98
7.0.60.0100.07720.06
7.0.50.0170.08019.90
7.0.40.0070.07319.85
7.0.30.0000.04319.84
7.0.20.0070.03719.70
7.0.10.0100.08319.74
7.0.00.0070.03719.68
5.6.280.0030.07321.01
5.6.260.0030.05320.63
5.6.250.0070.04720.74
5.6.240.0100.05020.56
5.6.230.0170.05020.56
5.6.220.0070.07320.85
5.6.210.0000.08720.60
5.6.200.0100.07320.56
5.6.190.0070.07720.59
5.6.180.0130.06720.58
5.6.170.0000.06720.67
5.6.160.0100.07720.63
5.6.150.0100.06020.56
5.6.140.0030.04320.48
5.6.130.0070.04320.86
5.6.120.0130.07320.70
5.6.110.0100.07720.47
5.6.100.0030.08720.62
5.6.90.0000.04320.64
5.6.80.0100.03019.93
5.6.70.0030.03719.96
5.6.60.0070.05319.85
5.6.50.0030.03719.95
5.6.40.0030.03719.93
5.6.30.0070.03720.03
5.6.20.0030.05020.08
5.6.10.0070.03719.95
5.6.00.0030.04019.93
5.5.380.0070.06717.65
5.5.370.0100.07317.72
5.5.360.0030.04717.55
5.5.350.0030.05017.57
5.5.340.0070.04017.96
5.5.330.0100.04318.23
5.5.320.0070.08017.96
5.5.310.0100.05717.84
5.5.300.0070.08318.22
5.5.290.0030.07318.09
5.5.280.0100.03317.85
5.5.270.0070.07318.09
5.5.260.0070.04018.21
5.5.250.0070.06317.86
5.5.240.0070.03717.32
5.5.230.0070.05317.29
5.5.220.0030.03317.63
5.5.210.0100.06717.29
5.5.200.0000.04317.45
5.5.190.0000.04317.60
5.5.180.0030.08017.45
5.5.160.0130.03317.48
5.5.150.0070.07317.45
5.5.140.0030.03717.40
5.5.130.0030.04317.45
5.5.120.0070.04317.26
5.5.110.0030.03317.45
5.5.100.0070.03717.19
5.5.90.0070.03317.21
5.5.80.0030.03317.18
5.5.70.0070.03317.34
5.5.60.0000.04317.46
5.5.50.0030.03717.19
5.5.40.0030.03317.34
5.5.30.0000.03317.15
5.5.20.0070.03717.37
5.5.10.0030.03017.07
5.5.00.0070.07017.36
5.4.450.0030.07319.36
5.4.440.0070.08319.42
5.4.430.0100.03019.27
5.4.420.0030.07019.49
5.4.410.0030.04019.19
5.4.400.0070.06319.00
5.4.390.0030.04719.14
5.4.380.0130.07019.04
5.4.370.0170.03318.98
5.4.360.0000.04019.14
5.4.350.0100.05019.30
5.4.340.0000.08019.24
5.4.320.0070.03319.00
5.4.310.0030.04319.16
5.4.300.0100.03319.24
5.4.290.0070.05718.98
5.4.280.0000.03719.18
5.4.270.0030.03719.24
5.4.260.0030.03318.99
5.4.250.0030.03319.02
5.4.240.0100.03719.02
5.4.230.0100.04019.13
5.4.220.0000.04019.16
5.4.210.0000.03319.04
5.4.200.0000.03719.00
5.4.190.0030.03019.31
5.4.180.0000.03719.08
5.4.170.0030.04018.99
5.4.160.0070.03018.98
5.4.150.0030.04319.22
5.4.140.0100.05016.44
5.4.130.0000.03316.56
5.4.120.0030.03716.40
5.4.110.0030.03316.60
5.4.100.0000.03716.63
5.4.90.0030.04016.46
5.4.80.0100.04316.57
5.4.70.0030.03716.52
5.4.60.0030.04016.39
5.4.50.0100.02716.41
5.4.40.0000.03316.58
5.4.30.0130.05716.48
5.4.20.0070.05716.62
5.4.10.0070.05716.48
5.4.00.0000.03716.00
5.3.290.0100.04014.91
5.3.280.0030.03714.63
5.3.270.0000.03714.87
5.3.260.0030.03314.62
5.3.250.0030.04014.63
5.3.240.0030.03314.86
5.3.230.0070.03714.75
5.3.220.0030.03314.62
5.3.210.0000.04314.45
5.3.200.0030.09314.59
5.3.190.0030.03714.58
5.3.180.0030.04014.82
5.3.170.0030.04314.56
5.3.160.0070.05014.60
5.3.150.0100.06714.61
5.3.140.0030.03314.61
5.3.130.0100.02714.66
5.3.120.0030.03714.53
5.3.110.0070.03314.55
5.3.100.0070.04313.91
5.3.90.0130.05714.01
5.3.80.0000.09314.07
5.3.70.0030.08014.03
5.3.60.0070.07714.08
5.3.50.0130.06313.98
5.3.40.0070.07014.06
5.3.30.0030.03313.78
5.3.20.0070.07313.71
5.3.10.0000.05013.68
5.3.00.0030.07313.76
5.2.170.0070.05311.91
5.2.160.0100.05711.91
5.2.150.0100.05311.91
5.2.140.0030.04711.91
5.2.130.0000.02711.91
5.2.120.0030.03711.91
5.2.110.0000.05711.91
5.2.100.0000.05711.91
5.2.90.0030.02711.91
5.2.80.0100.04711.91
5.2.70.0030.05011.91
5.2.60.0030.02711.91
5.2.50.0070.06011.91
5.2.40.0070.03311.91
5.2.30.0000.06711.91
5.2.20.0070.07311.91
5.2.10.0070.05011.91
5.2.00.0130.01311.91
5.1.60.0030.04311.91
5.1.50.0030.05711.91
5.1.40.0030.04711.91
5.1.30.0000.04311.91
5.1.20.0030.04311.91
5.1.10.0000.04711.91
5.1.00.0000.05711.91
5.0.50.0000.02311.91
5.0.40.0070.03011.91
5.0.30.0030.06011.91
5.0.20.0000.04011.91
5.0.10.0000.04011.91
5.0.00.0070.06011.91
4.4.90.0070.02311.91
4.4.80.0030.02011.91
4.4.70.0070.03011.91
4.4.60.0070.02311.91
4.4.50.0030.03011.91
4.4.40.0030.05011.91
4.4.30.0000.03011.91
4.4.20.0000.01711.91
4.4.10.0000.03711.91
4.4.00.0000.05711.91
4.3.110.0030.02011.91
4.3.100.0000.03011.91
4.3.90.0030.02311.91
4.3.80.0030.05311.91
4.3.70.0030.01311.91
4.3.60.0030.03011.91
4.3.50.0000.04011.91
4.3.40.0000.03311.91
4.3.30.0000.01311.91
4.3.20.0000.01311.91
4.3.10.0000.02711.91
4.3.00.0000.03311.91

preferences:
45.86 ms | 401 KiB | 5 Q