3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @property stdClass $x * @property stdClass $y */ class C { private $buffer = array(); function __get($key) { if (array_key_exists($key, $this->buffer)) { return $this->buffer[$key]; } $f = 'calc_' . $key; $v = $this->$f(); if (array_key_exists($key, $this->buffer)) { return $this->buffer[$key]; } return $this->buffer[$key] = $v; } function calc_x() {print __METHOD__ . "\n"; $x = new stdClass; $x->y = $this->__get('y'); return $x; } function calc_y() {print __METHOD__ . "\n"; $y = new stdClass; // Set a stub to avoid infinite recursion. $this->buffer['y'] = $y; $y->x = $this->__get('x'); return $y; } } $c = new C; $x = $c->x; $y = $c->y; var_dump($x->y === $y, $y->x === $x); print "\n"; $c = new C; $y = $c->y; $x = $c->x; var_dump($x->y === $y, $y->x === $x);

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.1.130.0040.00417.64
8.1.120.0030.00517.41
8.1.110.0040.00417.23
8.1.100.0050.00317.42
8.1.90.0000.00717.28
8.1.80.0000.00717.39
8.1.70.0030.00317.34
8.1.60.0000.00917.48
8.1.50.0050.00317.46
8.1.40.0030.00617.52
8.1.30.0000.00917.55
8.1.20.0030.00617.64
8.1.10.0000.00817.59
8.1.00.0040.00417.48
8.0.260.0000.00617.26
8.0.250.0030.00316.92
8.0.240.0000.00717.01
8.0.230.0030.00316.92
8.0.220.0070.00016.95
8.0.210.0000.00716.91
8.0.200.0000.00616.93
8.0.190.0000.00816.88
8.0.180.0040.00416.89
8.0.170.0080.00016.96
8.0.160.0000.00716.90
8.0.150.0050.00316.84
8.0.140.0040.00416.89
8.0.130.0030.00313.33
8.0.120.0030.00516.92
8.0.110.0000.00816.88
8.0.100.0030.00616.95
8.0.90.0040.00416.96
8.0.80.0000.01516.77
8.0.70.0000.00716.89
8.0.60.0000.00716.75
8.0.50.0020.00516.74
8.0.30.0160.00017.26
8.0.20.0110.00917.40
8.0.10.0070.00016.78
8.0.00.0100.00916.85
7.4.330.0020.00216.79
7.4.320.0030.00316.61
7.4.300.0040.00416.50
7.4.290.0040.00416.61
7.4.280.0060.00316.65
7.4.270.0000.00716.53
7.4.260.0030.00716.47
7.4.250.0050.00216.47
7.4.240.0040.00416.56
7.4.230.0000.00816.59
7.4.220.0060.01616.55
7.4.210.0060.00916.58
7.4.200.0000.00716.41
7.4.160.0060.01116.67
7.4.150.0110.00717.40
7.4.140.0030.01617.86
7.4.130.0080.00916.57
7.4.120.0080.00816.56
7.4.110.0140.00716.60
7.4.100.0100.00716.49
7.4.90.0070.01016.39
7.4.80.0090.01619.39
7.4.70.0040.01216.44
7.4.60.0070.01116.42
7.4.50.0030.00916.47
7.4.40.0100.00616.31
7.4.30.0120.00616.54
7.4.00.0060.00614.71
7.3.330.0040.00413.20
7.3.320.0030.00313.24
7.3.310.0070.00016.25
7.3.300.0000.00716.42
7.3.290.0030.00316.24
7.3.280.0110.00516.34
7.3.270.0090.00917.40
7.3.260.0140.00416.52
7.3.250.0100.00716.54
7.3.240.0160.00316.48
7.3.230.0120.00616.39
7.3.210.0140.00316.34
7.3.200.0110.01119.39
7.3.190.0100.00616.24
7.3.180.0160.00016.49
7.3.170.0070.01016.44
7.3.160.0120.00416.64
7.2.330.0060.01516.63
7.2.320.0180.00916.68
7.2.310.0080.00816.71
7.2.300.0060.01516.55
7.2.290.0120.00916.87
7.2.60.0110.00717.14
7.2.00.0090.00019.33
7.1.200.0060.00615.79
7.1.100.0040.00818.18
7.1.70.0040.01117.09
7.1.60.0140.01019.18
7.1.50.0160.00516.67
7.1.00.0100.06722.40
7.0.200.0540.00715.05
7.0.100.0000.08021.70
7.0.90.0000.08021.67
7.0.80.0130.06321.73
7.0.70.0070.08021.72
7.0.60.0130.07321.75
7.0.50.0070.08022.05
7.0.40.0070.08019.96
7.0.30.0000.06020.10
7.0.20.0030.08320.11
7.0.10.0070.08020.05
7.0.00.0100.08020.18
5.6.280.0130.05321.12
5.6.250.0030.07320.67
5.6.240.0000.05720.68
5.6.230.0000.09020.70
5.6.220.0070.06720.68
5.6.210.0030.07020.60
5.6.200.0000.08021.05
5.6.190.0130.07321.04
5.6.180.0100.07021.18
5.6.170.0030.08321.12
5.6.160.0100.07021.07
5.6.150.0070.07321.11
5.6.140.0100.07720.95
5.6.130.0030.07721.07
5.6.120.0100.06720.95
5.6.110.0000.05021.05
5.6.100.0070.07721.08
5.6.90.0000.08021.05
5.6.80.0030.08020.34
5.6.70.0030.07320.49
5.6.60.0070.04020.43
5.6.50.0000.04320.44
5.6.40.0000.04320.39
5.6.30.0030.05320.36
5.6.20.0000.04720.41
5.6.10.0030.04320.25
5.6.00.0030.04020.37
5.5.380.0130.07020.39
5.5.370.0030.07720.39
5.5.360.0100.07020.57
5.5.350.0000.06320.47
5.5.340.0030.08320.90
5.5.330.0070.08020.74
5.5.320.0070.07720.92
5.5.310.0130.05320.89
5.5.300.0100.07020.90
5.5.290.0000.08020.72
5.5.280.0100.08020.89
5.5.270.0030.08320.75
5.5.260.0000.06720.79
5.5.250.0130.07320.68
5.5.240.0100.07020.13
5.5.230.0000.06720.30
5.5.220.0000.04020.27
5.5.210.0100.03720.22
5.5.200.0030.04320.10
5.5.190.0000.04320.16
5.5.180.0030.04720.00
5.5.160.0030.04319.98
5.5.150.0030.03720.18
5.5.140.0000.04720.22
5.5.130.0070.07320.23
5.5.120.0000.06720.14
5.5.110.0000.05320.21
5.5.100.0070.04320.17
5.5.90.0100.02720.11
5.5.80.0130.07020.08
5.5.70.0000.04020.11
5.5.60.0100.06019.98
5.5.50.0100.05320.04
5.5.40.0030.04020.08
5.5.30.0070.03320.02
5.5.20.0030.05320.06
5.5.10.0000.07720.08
5.5.00.0000.03720.12

preferences:
12.45 ms | 406 KiB | 5 Q