3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection { function attach() { }} class Link {} class Node { private $label = '_'; private $links; private $attrs; public function __construct($label = '_') { $this -> setLabel($label); } public function getLabel() { return $this -> label; } public function setLabel($label) { if (!is_scalar($label)) { throw new ErrorException("Error Processing Request", 1); } $this -> label = $label; return $this -> getLabel(); } public function __get($name) { if (isset($this -> links -> $name)) { return $this -> links -> $name; } elseif (isset($this -> attrs -> $name)) { return $this -> attrs -> $name; } else { throw new ErrorException("Error Processing Request", 1); } } public function __set($name, $value) { if ($name == '_' && !($value instanceof Node || $value instanceof Link || $value instanceof Collection)) { throw new ErrorException("Error Processing Request", 1); } $name_type = ( (1 * (isset($this -> links -> $name) && count($this -> links -> $name) == 1)) | (2 * (isset($this -> links -> $name) && count($this -> links -> $name) <> 1)) | (3 * isset($this -> attrs -> $name)) | (13 * !(isset($this -> attrs -> $name) || isset($this -> links -> $name))) ); $value_type = ( (5 * ($value instanceof Collection)) | (7 * ($value instanceof Node)) | (17 * ($value instanceof Link)) | (11 * !($value instanceof Node || $value instanceof Link || $value instanceof Collection)) ); switch ($name_type * $value_type) { case 5: case 10: { foreach ($value as $node) { $this -> links -> {$name} -> attach($node); } break; } case 7: case 14: { $this -> links -> {$name} -> attach($value); break; } case 11: case 22: { trigger_error('Converting ' . $name . ' from ' . ((count($this -> links -> $name) <> 1) ? 'Collection' : 'Node') . ' to property', E_USER_WARNING); unset($this -> links -> $name); $this -> attrs -> $name = $value; break; } case 15: { trigger_error('Converting ' . $name . ' from property to Collection', E_USER_WARNING); unset($this -> attrs -> $name); $this -> links -> $name = $value; break; } case 21: { trigger_error('Converting ' . $name . ' from property to Node', E_USER_WARNING); unset($this -> attrs -> $name); $this -> links -> $name = new Collection; $this -> links -> {$name} -> attach($value); break; } case 33: case 143: { $this -> attrs -> $name = $value; break; } case 65: { $this -> links -> $name = $value; break; } case 91: { $this -> links -> $name = new Collection; $this -> links -> {$name} -> attach($value); break; } case 17: case 34: { $this -> links -> {$name} -> attach($value -> getTail()); $this -> links -> {$name} -> attach($value -> getHead()); break; } case 51: { trigger_error('Converting ' . $name . ' from property to Collection', E_USER_WARNING); unset($this -> attrs -> $name); $this -> links -> $name = new Collection; $this -> links -> {$name} -> attach($value -> getTail()); $this -> links -> {$name} -> attach($value -> getHead()); break; } case 221: { $this -> links -> $name = new Collection; $this -> links -> {$name} -> attach($value -> getTail()); $this -> links -> {$name} -> attach($value -> getHead()); break; } default: { throw new ErrorException("Error Processing Request", 1); // no break } } } public function __isset($name) { return (isset($this -> links -> $name) || isset($this -> attrs -> $name)); } public function __unset($name) { unset($this -> links -> $name, $this -> attrs -> $name); } public function serialize() { return serialize(array( 'label' => $this -> getLabel(), 'links' => $this -> links, 'attrs' => $this -> attrs )); } public function unserialize($serialized) { $unserialized = unserialize($serialized); $this -> setLabel($unserialized['label']); $this -> links = $unserialized['links']; $this -> attrs = $unserialized['attrs']; } } $node = new Node; $node->self = $node; echo serialize($node);

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.0080.01118.65
8.3.50.0120.00522.11
8.3.40.0110.00319.04
8.3.30.0110.00719.08
8.3.20.0000.00820.46
8.3.10.0080.00022.09
8.3.00.0030.00622.43
8.2.180.0090.00616.63
8.2.170.0080.00822.96
8.2.160.0070.00720.77
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0090.00019.51
8.2.110.0100.00019.33
8.2.100.0040.01118.09
8.2.90.0000.00819.33
8.2.80.0040.00418.18
8.2.70.0070.00317.63
8.2.60.0030.00618.05
8.2.50.0000.00818.07
8.2.40.0070.00318.07
8.2.30.0040.00418.20
8.2.20.0000.00817.87
8.2.10.0050.00317.86
8.2.00.0080.00017.93
8.1.280.0110.00725.92
8.1.270.0030.00623.91
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0060.00322.19
8.1.230.0040.00719.08
8.1.220.0000.00817.79
8.1.210.0060.00318.77
8.1.200.0000.00917.48
8.1.190.0040.00417.66
8.1.180.0000.00818.10
8.1.170.0030.00518.84
8.1.160.0040.00422.06
8.1.150.0000.00818.77
8.1.140.0090.00017.50
8.1.130.0030.00317.95
8.1.120.0050.00217.59
8.1.110.0000.00817.66
8.1.100.0040.00417.48
8.1.90.0000.00817.59
8.1.80.0040.00417.56
8.1.70.0070.00017.52
8.1.60.0060.00317.71
8.1.50.0100.00017.54
8.1.40.0030.00517.66
8.1.30.0050.00317.75
8.1.20.0040.00417.78
8.1.10.0030.00517.71
8.1.00.0060.00317.61
8.0.300.0040.00418.84
8.0.290.0000.00717.16
8.0.280.0040.00418.57
8.0.270.0030.00317.25
8.0.260.0000.00717.01
8.0.250.0030.00517.19
8.0.240.0000.00717.14
8.0.230.0030.00517.04
8.0.220.0000.00717.13
8.0.210.0000.00817.07
8.0.200.0000.00717.14
8.0.190.0080.00017.07
8.0.180.0060.00317.10
8.0.170.0030.00617.11
8.0.160.0040.00417.04
8.0.150.0000.00816.94
8.0.140.0040.00417.04
8.0.130.0060.00013.53
8.0.120.0030.00517.07
8.0.110.0000.00717.01
8.0.100.0050.00216.97
8.0.90.0020.00517.03
8.0.80.0060.00916.96
8.0.70.0030.00617.12
8.0.60.0000.00816.89
8.0.50.0000.00816.86
8.0.30.0060.01317.19
8.0.20.0110.01117.40
8.0.10.0040.00416.99
8.0.00.0090.01516.87
7.4.330.0050.00015.00
7.4.320.0030.00316.72
7.4.300.0020.00516.56
7.4.290.0030.00316.73
7.4.280.0000.00716.73
7.4.270.0000.00716.56
7.4.260.0040.00416.52
7.4.250.0050.00216.73
7.4.240.0000.00816.77
7.4.230.0040.00416.54
7.4.220.0090.00916.57
7.4.210.0100.00516.64
7.4.200.0000.00716.56
7.4.190.0030.00516.77
7.4.160.0100.00616.64
7.4.150.0090.00817.40
7.4.140.0080.01117.86
7.4.130.0120.00616.71
7.4.120.0110.00616.61
7.4.110.0110.00716.68
7.4.100.0070.01716.46
7.4.90.0180.00616.73
7.4.80.0140.00716.58
7.4.70.0100.01316.62
7.4.60.0070.01016.64
7.4.50.0020.00216.63
7.4.40.0070.01022.77
7.4.30.0070.01016.71
7.4.10.0050.01215.32
7.4.00.0070.01014.99
7.3.330.0000.00613.51
7.3.320.0050.00013.58
7.3.310.0070.00016.46
7.3.300.0030.00316.42
7.3.290.0070.00716.53
7.3.280.0110.01116.55
7.3.270.0070.01117.40
7.3.260.0080.01216.71
7.3.250.0110.00816.49
7.3.240.0090.01416.59
7.3.230.0120.00616.52
7.3.210.0130.00316.71
7.3.200.0080.01119.39
7.3.190.0110.01116.63
7.3.180.0030.01616.78
7.3.170.0060.01316.65
7.3.160.0140.00416.72
7.3.130.0090.01015.06
7.3.120.0070.01115.08
7.3.110.0070.01115.03
7.3.100.0060.00714.95
7.3.90.0080.00615.13
7.3.80.0040.00914.96
7.3.70.0050.00915.06
7.3.60.0050.00914.75
7.3.50.0060.00615.00
7.3.40.0040.00515.01
7.3.30.0030.01114.97
7.3.20.0050.00516.59
7.3.10.0060.00916.51
7.3.00.0070.00716.50
7.2.330.0090.00916.68
7.2.320.0070.01016.89
7.2.310.0140.00716.89
7.2.300.0130.00316.93
7.2.290.0150.00616.70
7.2.260.0070.01315.22
7.2.250.0060.01415.11
7.2.240.0090.00715.16
7.2.230.0070.00815.14
7.2.220.0030.01314.96
7.2.210.0040.00715.12
7.2.200.0060.00715.01
7.2.190.0030.01215.21
7.2.180.0040.00915.22
7.2.170.0040.00915.18
7.2.160.0040.01115.14
7.2.150.0030.01216.81
7.2.140.0050.01116.90
7.2.130.0100.00416.86
7.2.120.0090.00516.67
7.2.110.0050.00916.68
7.2.100.0060.00816.78
7.2.90.0040.01016.90
7.2.80.0050.01116.89
7.2.70.0060.01117.08
7.2.60.0100.00816.73
7.2.50.0080.00816.83
7.2.40.0060.01116.72
7.2.30.0070.00916.72
7.2.20.0030.01016.90
7.2.10.0070.00716.79
7.2.00.0050.00717.48
7.1.330.0030.00815.73
7.1.320.0040.00915.91
7.1.310.0050.00715.88
7.1.300.0070.00715.76
7.1.290.0060.00615.69
7.1.280.0020.01015.79
7.1.270.0030.00915.65
7.1.260.0090.00515.88
7.1.250.0020.01215.77
7.1.240.0000.01615.67
7.1.230.0060.00815.91
7.1.220.0020.01015.79
7.1.210.0030.00815.87
7.1.200.0050.00615.77
7.1.190.0050.00515.86
7.1.180.0030.00815.82
7.1.170.0060.00615.88
7.1.160.0070.00815.83
7.1.150.0070.00815.91
7.1.140.0050.01115.88
7.1.130.0020.01015.81
7.1.120.0090.00515.82
7.1.110.0030.00815.72
7.1.100.0050.00816.67
7.1.90.0060.00815.85
7.1.80.0020.01315.60
7.1.70.0030.01116.33
7.1.60.0060.00717.13
7.1.50.0060.01116.13
7.1.40.0060.00615.78
7.1.30.0030.00915.68
7.1.20.0080.00515.98
7.1.10.0080.00515.79
7.1.00.0100.02717.93
7.0.330.0020.00715.38
7.0.320.0020.01115.52
7.0.310.0070.00815.44
7.0.300.0050.00715.39
7.0.290.0070.00715.29
7.0.280.0030.01015.39
7.0.270.0050.00815.25
7.0.260.0070.00715.31
7.0.250.0040.00715.46
7.0.240.0050.00715.39
7.0.230.0060.00315.27
7.0.220.0100.00515.55
7.0.210.0030.00915.49
7.0.200.0040.00715.94
7.0.190.0050.00715.39
7.0.180.0060.00915.47
7.0.170.0020.01015.38
7.0.160.0020.01115.39
7.0.150.0070.00615.43
7.0.140.0060.02817.58
7.0.130.0090.00115.45
7.0.120.0090.00515.45
7.0.110.0060.01516.97
7.0.100.0020.02016.98
7.0.90.0050.02217.03
7.0.80.0050.02716.97
7.0.70.0090.01616.98
7.0.60.0000.02616.92
7.0.50.0030.02116.98
7.0.40.0050.01715.48
7.0.30.0060.01715.51
7.0.20.0080.01515.62
7.0.10.0090.01715.55
7.0.00.0040.02015.46
5.6.400.0030.00914.61
5.6.390.0110.00514.37
5.6.380.0080.00714.60
5.6.370.0020.01114.46
5.6.360.0040.01314.60
5.6.350.0080.00414.67
5.6.340.0030.00714.61
5.6.330.0030.01014.47
5.6.320.0040.00714.45
5.6.310.0050.00914.54
5.6.300.0030.01014.51
5.6.290.0050.01014.47
5.6.280.0040.03016.72
5.6.270.0060.00614.53
5.6.260.0080.01916.64
5.6.250.0040.01816.47
5.6.240.0070.02616.58
5.6.230.0060.02316.58
5.6.220.0070.01516.73
5.6.210.0040.01916.50
5.6.200.0040.02016.68
5.6.190.0060.01916.47
5.6.180.0040.03216.54
5.6.170.0020.02516.56
5.6.160.0050.01916.35
5.6.150.0060.01816.57
5.6.140.0070.02116.44
5.6.130.0060.01416.51
5.6.120.0040.01916.69
5.6.110.0060.02016.47
5.6.100.0080.01516.63
5.6.90.0020.02016.58
5.6.80.0030.01516.28
5.6.70.0040.02416.32
5.6.60.0040.02116.36
5.6.50.0070.01716.24
5.6.40.0050.01916.34
5.6.30.0050.01816.36
5.6.20.0010.02216.25
5.6.10.0030.02116.17
5.6.00.0090.01816.29
5.5.380.0070.02515.54
5.5.370.0050.02715.51
5.5.360.0040.01815.48
5.5.350.0010.02315.60
5.5.340.0060.02315.68
5.5.330.0050.01715.68
5.5.320.0050.02015.58
5.5.310.0030.01615.77
5.5.300.0040.02015.64
5.5.290.0080.01915.50
5.5.280.0070.01915.65
5.5.270.0030.01815.60
5.5.260.0060.01915.65
5.5.250.0020.02315.52
5.5.240.0040.01715.42
5.5.230.0040.02515.44
5.5.220.0020.01915.53
5.5.210.0070.01615.39
5.5.200.0020.02115.54
5.5.190.0090.01515.31
5.5.180.0060.02115.42
5.5.170.0050.00914.54
5.5.160.0100.02015.33
5.5.150.0040.01915.38
5.5.140.0080.01715.35
5.5.130.0030.01915.40
5.5.120.0070.02315.45
5.5.110.0020.02715.47
5.5.100.0050.01915.36
5.5.90.0030.02915.37
5.5.80.0040.02415.34
5.5.70.0060.01515.18
5.5.60.0030.01915.31
5.5.50.0090.01415.34
5.5.40.0030.02715.32
5.5.30.0090.01515.24
5.5.20.0070.02415.36
5.5.10.0060.01515.31
5.5.00.0050.01915.10
5.4.450.0070.02614.59
5.4.440.0030.01914.63
5.4.430.0060.01614.64
5.4.420.0060.01714.52
5.4.410.0030.02014.43
5.4.400.0060.01514.47
5.4.390.0010.02114.45
5.4.380.0070.02014.36
5.4.370.0050.01614.47
5.4.360.0070.01614.43
5.4.350.0010.02014.34
5.4.340.0010.02114.39
5.4.330.0000.01211.93
5.4.320.0040.01914.39
5.4.310.0010.02414.49
5.4.300.0080.01214.43
5.4.290.0050.03114.33
5.4.280.0070.02814.43
5.4.270.0060.01914.31
5.4.260.0030.01914.43
5.4.250.0060.01514.46
5.4.240.0020.02114.53
5.4.230.0030.01514.45
5.4.220.0050.02214.32
5.4.210.0110.01114.32
5.4.200.0040.01814.36
5.4.190.0060.01614.38
5.4.180.0030.01814.43
5.4.170.0050.01614.45
5.4.160.0010.02014.34
5.4.150.0040.02714.34
5.4.140.0020.02313.56
5.4.130.0040.02013.61
5.4.120.0040.01913.61
5.4.110.0030.02313.58
5.4.100.0060.01313.61
5.4.90.0020.02013.56
5.4.80.0030.01713.59
5.4.70.0090.01313.50
5.4.60.0040.01913.51
5.4.50.0060.01513.48
5.4.40.0050.01413.52
5.4.30.0040.01613.59
5.4.20.0040.01513.60
5.4.10.0070.01913.59
5.4.00.0040.01813.36
5.3.290.0010.02112.81
5.3.280.0000.01912.79
5.3.270.0030.01812.85
5.3.260.0040.01712.70
5.3.250.0030.03012.75
5.3.240.0040.01712.82
5.3.230.0020.02212.76
5.3.220.0020.02312.80
5.3.210.0060.01812.70
5.3.200.0010.02112.59
5.3.190.0020.01912.80
5.3.180.0030.02612.76
5.3.170.0040.01512.70
5.3.160.0040.01712.70
5.3.150.0050.01712.80
5.3.140.0030.01812.79
5.3.130.0010.01912.71
5.3.120.0030.01912.74
5.3.110.0030.01712.74
5.3.100.0020.01612.67
5.3.90.0050.01412.57
5.3.80.0040.01612.50
5.3.70.0050.01412.58
5.3.60.0060.01412.59
5.3.50.0070.02112.66
5.3.40.0040.01612.60
5.3.30.0020.01912.52
5.3.20.0040.01512.51
5.3.10.0040.01412.36
5.3.00.0040.02512.40

preferences:
42.62 ms | 401 KiB | 5 Q