3v4l.org

run code in 300+ PHP versions simultaneously
<?php // from http://stackoverflow.com/a/3764809/4251625 function refcount($var) { ob_start(); debug_zval_dump($var); $dump = ob_get_clean(); $matches = array(); preg_match('/refcount\(([0-9]+)/', $dump, $matches); $count = $matches[1]; //3 references are added, including when calling debug_zval_dump() return $count - 3; } class SomethingBuilder { protected $value; protected $listeners = []; protected function dispatchEvent($evt){ foreach($this->listeners as $listener) $listener($evt); } function addEventListener($listener){ $this->listeners[] = $listener; } function getValue(){ return $this->value; } function setValue($value){ $this->dispatchEvent('beforechange'); $this->value = $value; } function freeze(){ return new SomethingFinalBuilderWrapper($this); } } class SomethingFinalBuilderWrapper { protected $builder; function __construct(SomethingBuilder $builder){ $this->builder = $builder; $this->builder->addEventListener(function($evt){ if($evt !== 'beforechange') return; echo refcount($this->builder); // if(refcount($this->builder) > 1) $this->builder = clone $this->builder; echo "clone happened\n"; }); } function getValue(){ return $this->builder->getValue(); } } $x = new SomethingBuilder(); $x->setValue(10); echo $x->getValue() . "\n"; $y = $x->freeze(); $x->setValue(20); echo $y->getValue() . "\n"; echo $x->getValue() . "\n"; $y = $x->freeze(); $z = $x->freeze(); $x->setValue(20); echo $y->getValue() . "\n"; echo $x->getValue() . "\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.4.20.0040.01817.91
8.4.10.0100.01017.64
8.3.150.0110.00818.59
8.3.140.0030.00617.48
8.3.130.0130.00318.36
8.3.120.0100.00020.63
8.3.110.0060.00620.94
8.3.100.0080.00024.06
8.3.90.0140.00026.77
8.3.80.0060.00317.97
8.3.70.0130.01016.86
8.3.60.0110.00718.43
8.3.50.0120.01021.24
8.3.40.0060.00919.09
8.3.30.0120.00319.18
8.3.20.0080.00020.29
8.3.10.0040.00423.52
8.3.00.0030.00619.78
8.2.260.0100.01018.57
8.2.250.0000.00816.66
8.2.240.0090.00017.20
8.2.230.0040.00422.58
8.2.220.0060.00337.54
8.2.210.0070.01126.77
8.2.200.0090.00016.88
8.2.190.0150.00618.67
8.2.180.0110.00725.92
8.2.170.0070.01322.96
8.2.160.0070.00720.43
8.2.150.0040.00424.18
8.2.140.0090.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00320.35
8.2.110.0030.00619.25
8.2.100.0060.00617.97
8.2.90.0050.00318.03
8.2.80.0000.00819.15
8.2.70.0050.00317.88
8.2.60.0040.00417.93
8.2.50.0000.00818.07
8.2.40.0080.00018.28
8.2.30.0060.00618.27
8.2.20.0040.00418.13
8.2.10.0070.00018.26
8.2.00.0000.00718.25
8.1.310.0050.00518.69
8.1.300.0030.00518.04
8.1.290.0070.00330.84
8.1.280.0130.00325.92
8.1.270.0050.00320.51
8.1.260.0060.00326.35
8.1.250.0050.00328.09
8.1.240.0070.00319.59
8.1.230.0030.00921.16
8.1.220.0030.00617.89
8.1.210.0030.00518.77
8.1.200.0030.00517.60
8.1.190.0000.00817.60
8.1.180.0000.00818.10
8.1.170.0030.00618.82
8.1.160.0000.00822.14
8.1.150.0050.00319.00
8.1.140.0050.00317.51
8.1.130.0000.00817.96
8.1.120.0040.00417.69
8.1.110.0040.00417.63
8.1.100.0070.00017.62
8.1.90.0060.00317.70
8.1.80.0000.00817.66
8.1.70.0040.00417.64
8.1.60.0040.00417.80
8.1.50.0000.00817.62
8.1.40.0000.00817.71
8.1.30.0000.00817.92
8.1.20.0040.00417.93
8.1.10.0040.00417.73
8.1.00.0050.00317.73
8.0.300.0000.00820.40
8.0.290.0100.00016.88
8.0.280.0000.00718.46
8.0.270.0050.00218.18
8.0.260.0000.00617.23
8.0.250.0030.00317.18
8.0.240.0000.00717.24
8.0.230.0040.00417.23
8.0.220.0000.00717.13
8.0.210.0030.00317.17
8.0.200.0030.00317.18
8.0.190.0070.00017.26
8.0.180.0000.00817.16
8.0.170.0030.00617.08
8.0.160.0000.00817.07
8.0.150.0070.00017.06
8.0.140.0040.00417.13
8.0.130.0000.00613.54
8.0.120.0030.00516.97
8.0.110.0000.00816.99
8.0.100.0080.00017.18
8.0.90.0030.00617.17
8.0.80.0130.00917.14
8.0.70.0030.00517.11
8.0.60.0000.00717.18
8.0.50.0000.00817.03
8.0.30.0090.00917.38
8.0.20.0230.01717.40
8.0.10.0050.00317.39
8.0.00.0080.01116.99
7.4.330.0030.00315.03
7.4.320.0000.00716.77
7.4.300.0030.00316.81
7.4.290.0070.00016.78
7.4.280.0060.00316.86
7.4.270.0000.00716.85
7.4.260.0000.00716.65
7.4.250.0000.00716.83
7.4.240.0010.00716.75
7.4.230.0030.00416.97
7.4.220.0100.00716.79
7.4.210.0060.01616.97
7.4.200.0040.00416.90
7.4.160.0100.00716.86
7.4.150.0070.01117.40
7.4.140.0160.00517.86
7.4.130.0090.00916.81
7.4.120.0090.01116.86
7.4.110.0120.00616.86
7.4.100.0120.01216.71
7.4.90.0030.01416.72
7.4.80.0180.00619.39
7.4.70.0090.00916.87
7.4.60.0090.01516.73
7.4.50.0070.00016.79
7.4.40.0060.00916.81
7.4.30.0080.00816.62
7.4.10.0060.01215.37
7.4.00.0080.00915.23
7.3.330.0060.00013.59
7.3.320.0030.00313.54
7.3.310.0040.00416.69
7.3.300.0070.00016.53
7.3.290.0070.00916.58
7.3.280.0120.00716.51
7.3.270.0070.01017.40
7.3.260.0110.01016.60
7.3.250.0050.01216.86
7.3.240.0100.00716.90
7.3.230.0140.00316.83
7.3.210.0100.00716.63
7.3.200.0180.00619.39
7.3.190.0060.00916.93
7.3.180.0090.00616.66
7.3.170.0080.00816.73
7.3.160.0030.01516.59
7.3.130.0060.01015.29
7.3.120.0060.01015.02
7.3.110.0070.00714.96
7.3.100.0050.01115.06
7.3.90.0050.01015.21
7.3.80.0030.01215.26
7.3.70.0070.00715.03
7.3.60.0090.00415.15
7.3.50.0070.01015.16
7.3.40.0020.01515.16
7.3.30.0050.01015.18
7.3.20.0020.01416.81
7.3.10.0030.01316.90
7.3.00.0030.00616.95
7.2.330.0100.01016.85
7.2.320.0110.01116.99
7.2.310.0040.01417.02
7.2.300.0110.00517.03
7.2.290.0090.00916.88
7.2.260.0130.00315.39
7.2.250.0090.01015.39
7.2.240.0080.00915.28
7.2.230.0050.01115.32
7.2.220.0130.00315.22
7.2.210.0100.00615.39
7.2.200.0080.00615.47
7.2.190.0030.01415.25
7.2.180.0060.00815.16
7.2.170.0080.00815.36
7.2.160.0110.00615.27
7.2.150.0070.01117.13
7.2.140.0030.00617.16
7.2.130.0000.01217.13
7.2.120.0030.01017.16
7.2.110.0090.00616.93
7.2.100.0000.01417.18
7.2.90.0040.00817.15
7.2.80.0000.01216.96
7.2.70.0070.00417.12
7.2.60.0050.01117.09
7.2.50.0040.01517.05
7.2.40.0040.00717.10
7.2.30.0070.00717.02
7.2.20.0090.00316.82
7.2.10.0000.01016.99
7.2.00.0040.01217.13
7.1.330.0040.01115.96
7.1.320.0090.00315.92
7.1.310.0060.01115.96
7.1.300.0100.00516.08
7.1.290.0060.00615.76
7.1.280.0060.01116.11
7.1.270.0080.00815.89
7.1.260.0040.01115.83
7.1.250.0040.00816.02
7.1.240.0060.00616.00
7.1.230.0030.01015.81
7.1.220.0070.01016.04
7.1.210.0090.00016.15
7.1.200.0020.01315.87
7.1.190.0000.01316.08
7.1.180.0060.01215.93
7.1.170.0030.00915.96
7.1.160.0040.00715.98
7.1.150.0090.00616.23
7.1.140.0060.00316.13
7.1.130.0080.00316.02
7.1.120.0030.00715.91
7.1.110.0070.00716.16
7.1.100.0060.00916.03
7.1.90.0070.00315.88
7.1.80.0130.00016.00
7.1.70.0060.00616.65
7.1.60.0050.01517.82
7.1.50.0080.01016.68
7.1.40.0120.00315.77
7.1.30.0120.00615.76
7.1.20.0040.01416.05
7.1.10.0090.00616.04
7.1.00.0030.04319.12
7.0.330.0040.00815.76
7.0.320.0110.00315.45
7.0.310.0030.01015.55
7.0.300.0120.00615.41
7.0.290.0060.00615.65
7.0.280.0030.01215.72
7.0.270.0000.01215.72
7.0.260.0110.00415.77
7.0.250.0090.00615.66
7.0.240.0000.00915.68
7.0.230.0070.00315.55
7.0.220.0030.01015.73
7.0.210.0090.00615.43
7.0.200.0120.01215.35
7.0.190.0120.00415.51
7.0.180.0000.01415.43
7.0.170.0070.00315.77
7.0.160.0030.01115.45
7.0.150.0070.00715.43
7.0.140.0030.01015.41
7.0.130.0000.01615.74
7.0.120.0070.01015.41
7.0.110.0030.01315.61
7.0.100.0040.00715.59
7.0.90.0070.00715.57
7.0.80.0060.01015.47
7.0.70.0070.00715.73
7.0.60.0000.05017.78
7.0.50.0020.05216.77
7.0.40.0100.04216.99
7.0.30.0150.02716.83
7.0.20.0150.02716.78
7.0.10.0070.04716.93
7.0.00.0050.02416.96
5.6.400.0090.00614.71
5.6.390.0080.00614.79
5.6.380.0070.01014.56
5.6.370.0070.00714.65
5.6.360.0030.01414.96
5.6.350.0040.01114.46
5.6.340.0110.00314.96
5.6.330.0030.00614.56
5.6.320.0030.01314.94
5.6.310.0030.00714.38
5.6.300.0060.00614.37
5.6.290.0090.00614.68
5.6.280.0060.03817.86
5.6.270.0030.01014.83
5.6.260.0000.01214.31
5.6.250.0070.00314.55
5.6.240.0120.00314.59
5.6.230.0030.00714.60
5.6.220.0000.01414.80
5.6.210.0100.04417.68
5.6.200.0050.02816.41
5.6.190.0030.05317.63
5.6.180.0280.04117.58
5.6.170.0140.02217.53
5.6.160.0020.04917.57
5.6.150.0030.04916.51
5.6.140.0120.04316.49
5.6.130.0050.03216.60
5.6.120.0020.02817.90
5.6.110.0090.03417.72
5.6.100.0030.04717.73
5.6.90.0030.02817.91
5.6.80.0070.03517.43
5.6.70.0040.01214.55
5.6.60.0040.00714.53
5.6.50.0040.01114.46
5.6.40.0120.00014.52
5.6.30.0120.00314.49
5.6.20.0040.00714.68
5.6.10.0090.00614.57
5.6.00.0030.00714.44
5.5.380.0070.00714.62
5.5.370.0030.00714.63
5.5.360.0030.01414.75
5.5.350.0140.02317.61
5.5.340.0070.03816.39
5.5.330.0130.02117.50
5.5.320.0190.03817.31
5.5.310.0220.04717.48
5.5.300.0080.04216.41
5.5.290.0080.03116.40
5.5.280.0080.04217.72
5.5.270.0070.04417.63
5.5.260.0020.02717.60
5.5.250.0100.02617.55
5.5.240.0060.04017.20
5.5.230.0030.01014.30
5.5.220.0000.01514.69
5.5.210.0070.00714.47
5.5.200.0080.00414.30
5.5.190.0090.00614.52
5.5.180.0060.01014.59
5.5.170.0090.00614.51
5.5.160.0040.01214.28
5.5.150.0040.01114.38
5.5.140.0060.01014.29
5.5.130.0070.01014.60
5.5.120.0040.01414.52
5.5.110.0080.00414.50
5.5.100.0060.00614.45
5.5.90.0040.01114.41
5.5.80.0030.00614.43
5.5.70.0100.00714.35
5.5.60.0160.00314.31
5.5.50.0120.00614.50
5.5.40.0030.00714.72
5.5.30.0030.01014.46
5.5.20.0030.01214.53
5.5.10.0000.01614.18
5.5.00.0000.01114.47
5.4.450.0160.02815.67
5.4.440.0350.03515.35
5.4.430.0070.03215.34
5.4.420.0080.02915.46
5.4.410.0070.02915.41
5.4.400.0030.03215.21
5.4.390.0100.02615.07
5.4.380.0100.02715.09
5.4.370.0050.02815.12
5.4.360.0100.02715.17
5.4.350.0140.02315.14
5.4.340.0020.03315.18
5.4.330.0030.00310.96
5.4.320.0040.03215.17
5.4.310.0100.02615.11
5.4.300.0120.02315.27
5.4.290.0080.02815.22
5.4.280.0060.03315.16
5.4.270.0030.03515.04
5.4.260.0080.02915.20
5.4.250.0120.02515.21
5.4.240.0100.02815.18
5.4.230.0080.02815.23
5.4.220.0100.02815.05
5.4.210.0090.02915.12
5.4.200.0080.02714.02
5.4.190.0050.03215.16
5.4.180.0100.02615.15
5.4.170.0070.03215.16
5.4.160.0030.03215.18
5.4.150.0090.02715.24
5.4.140.0040.02913.91
5.4.130.0140.01813.85
5.4.120.0080.02613.83
5.4.110.0070.02813.95
5.4.100.0080.03113.85
5.4.90.0080.02813.76
5.4.80.0080.02813.92
5.4.70.0080.02513.92
5.4.60.0030.03213.69
5.4.50.0100.02513.84
5.4.40.0020.03413.82
5.4.30.0050.03713.62
5.4.20.0030.03113.94
5.4.10.0030.02914.00
5.4.00.0030.02813.62
5.3.290.0070.05714.74
5.3.280.0070.05314.73
5.3.270.0100.05014.73
5.3.260.0100.05314.59
5.3.250.0070.05014.64
5.3.240.0130.05014.55
5.3.230.0070.05014.51
5.3.220.0130.04314.70
5.3.210.0070.05714.65
5.3.200.0170.04014.65
5.3.190.0170.04314.65
5.3.180.0070.05314.68
5.3.170.0070.05314.59
5.3.160.0100.05014.54
5.3.150.0130.04714.59
5.3.140.0130.04714.60
5.3.130.0070.05314.57
5.3.120.0070.05714.61
5.3.110.0130.05014.45
5.3.100.0070.05014.16
5.3.90.0130.04313.94
5.3.80.0200.03713.95
5.3.70.0000.05713.98
5.3.60.0070.05314.07
5.3.50.0200.04713.86
5.3.40.0070.06314.05
5.3.30.0170.04313.85
5.3.20.0170.05313.84
5.3.10.0100.04713.81
5.3.00.0200.03713.62
5.2.170.0030.04711.10
5.2.160.0130.03311.05
5.2.150.0130.04311.04
5.2.140.0030.05311.00
5.2.130.0030.04011.09
5.2.120.0030.04311.24
5.2.110.0030.04710.96
5.2.100.0000.04311.02
5.2.90.0030.04311.09
5.2.80.0070.04011.02
5.2.70.0030.04311.01
5.2.60.0100.05011.01
5.2.50.0030.04310.96
5.2.40.0000.04711.09
5.2.30.0200.03010.96
5.2.20.0030.04310.91
5.2.10.0000.04310.98
5.2.00.0000.04310.68
5.1.60.0000.03710.03
5.1.50.0000.04010.03
5.1.40.0130.02310.00
5.1.30.0030.04010.32
5.1.20.0030.03710.49
5.1.10.0100.03010.05
5.1.00.0000.04010.07
5.0.50.0000.0308.68
5.0.40.0000.0308.42
5.0.30.0070.0408.25
5.0.20.0030.0278.18
5.0.10.0030.0278.10
5.0.00.0030.0438.16
4.4.90.0070.0235.79
4.4.80.0100.0175.82
4.4.70.0070.0175.87
4.4.60.0000.0235.90
4.4.50.0000.0235.94
4.4.40.0070.0305.93
4.4.30.0000.0235.87
4.4.20.0070.0175.92
4.4.10.0070.0175.99
4.4.00.0030.0335.80
4.3.110.0000.0235.69
4.3.100.0030.0205.70
4.3.90.0070.0175.77
4.3.80.0000.0375.70
4.3.70.0030.0205.84
4.3.60.0030.0205.84
4.3.50.0000.0235.77
4.3.40.0030.0335.63
4.3.30.0030.0204.47
4.3.20.0000.0234.41
4.3.10.0000.0234.37
4.3.00.0030.0237.14

preferences:
74.1 ms | 403 KiB | 5 Q