3v4l.org

run code in 300+ PHP versions simultaneously
<?php 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.0090.00918.30
8.3.50.0070.01222.11
8.3.40.0230.00018.95
8.3.30.0130.00319.19
8.3.20.0070.00020.50
8.3.10.0000.00821.98
8.3.00.0040.00422.28
8.2.180.0120.00616.75
8.2.170.0040.01522.96
8.2.160.0110.00320.75
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0000.00820.73
8.2.110.0040.00720.98
8.2.100.0090.00318.16
8.2.90.0050.00318.15
8.2.80.0040.00418.05
8.2.70.0050.00318.16
8.2.60.0000.00818.28
8.2.50.0030.00618.10
8.2.40.0050.00320.67
8.2.30.0030.00618.18
8.2.20.0030.00517.80
8.2.10.0000.00817.95
8.2.00.0050.00317.78
8.1.280.0110.00725.92
8.1.270.0080.00023.99
8.1.260.0120.00326.35
8.1.250.0030.00528.09
8.1.240.0060.00324.02
8.1.230.0110.00022.82
8.1.220.0050.00320.95
8.1.210.0000.00818.91
8.1.200.0080.00617.35
8.1.190.0060.00317.48
8.1.180.0040.00418.10
8.1.170.0030.00618.69
8.1.160.0070.00322.14
8.1.150.0050.00318.68
8.1.140.0050.00217.48
8.1.130.0080.00017.88
8.1.120.0000.00817.52
8.1.110.0000.00717.54
8.1.100.0030.00517.55
8.1.90.0000.00817.55
8.1.80.0050.00317.50
8.1.70.0030.00317.55
8.1.60.0050.00517.59
8.1.50.0000.00817.60
8.1.40.0040.00417.62
8.1.30.0080.00017.68
8.1.20.0040.00417.84
8.1.10.0030.00617.74
8.1.00.0040.00417.65
8.0.300.0040.00419.91
8.0.290.0060.00316.88
8.0.280.0000.00718.57
8.0.270.0000.00717.43
8.0.260.0030.00617.05
8.0.250.0000.00717.02
8.0.240.0000.00717.07
8.0.230.0030.00317.10
8.0.220.0030.00317.04
8.0.210.0040.00417.04
8.0.200.0070.00017.20
8.0.190.0040.00417.13
8.0.180.0050.00317.01
8.0.170.0080.00017.08
8.0.160.0000.00717.07
8.0.150.0040.00417.03
8.0.140.0000.00717.08
8.0.130.0000.00813.47
8.0.120.0000.00817.04
8.0.110.0080.00017.10
8.0.100.0050.00317.11
8.0.90.0030.00517.03
8.0.80.0030.01217.03
8.0.70.0040.00416.87
8.0.60.0070.00016.95
8.0.50.0040.00416.96
8.0.30.0230.00217.46
8.0.20.0080.01017.40
8.0.10.0040.00417.12
8.0.00.0070.01217.01
7.4.330.0060.00015.14
7.4.320.0000.00616.58
7.4.300.0070.00016.73
7.4.290.0000.00716.47
7.4.280.0030.00416.73
7.4.270.0040.00416.72
7.4.260.0040.00416.66
7.4.250.0000.00716.73
7.4.240.0020.00616.66
7.4.230.0040.00416.73
7.4.220.0100.00716.69
7.4.210.0050.01016.65
7.4.200.0030.00316.75
7.4.190.0040.00416.77
7.4.160.0110.00416.51
7.4.150.0120.00617.40
7.4.140.0130.00817.86
7.4.130.0080.00916.53
7.4.120.0110.00616.61
7.4.110.0120.01216.63
7.4.100.0170.00716.75
7.4.90.0130.00616.56
7.4.80.0150.00316.61
7.4.70.0090.00916.72
7.4.60.0130.00316.64
7.4.50.0000.01016.72
7.4.40.0000.01522.77
7.4.30.0070.01016.68
7.4.10.0130.00715.02
7.4.00.0070.01015.16
7.3.330.0030.00313.55
7.3.320.0000.00513.49
7.3.310.0040.00416.59
7.3.300.0030.00316.41
7.3.290.0090.00616.55
7.3.280.0120.00916.54
7.3.270.0070.01017.40
7.3.260.0090.00916.54
7.3.250.0130.00516.56
7.3.240.0150.00916.62
7.3.230.0070.01016.59
7.3.210.0060.01216.63
7.3.200.0090.00919.39
7.3.190.0110.01116.76
7.3.180.0090.00916.77
7.3.170.0030.01416.58
7.3.160.0070.01516.53
7.3.130.0110.00715.03
7.3.120.0080.01015.00
7.3.110.0060.01314.77
7.3.100.0060.00615.19
7.3.90.0040.00814.68
7.3.80.0070.01015.08
7.3.70.0040.00714.86
7.3.60.0000.01215.00
7.3.50.0030.00814.98
7.3.40.0130.00014.66
7.3.30.0000.00914.88
7.3.20.0120.00416.85
7.3.10.0060.00616.60
7.3.00.0050.00816.81
7.2.330.0090.00916.91
7.2.320.0090.00916.55
7.2.310.0090.00916.61
7.2.300.0130.00316.95
7.2.290.0030.01316.85
7.2.260.0060.00915.25
7.2.250.0080.01214.79
7.2.240.0060.00915.37
7.2.230.0090.00615.21
7.2.220.0030.01315.07
7.2.210.0060.00915.41
7.2.200.0090.00615.32
7.2.190.0030.01015.18
7.2.180.0060.00315.19
7.2.170.0090.00615.11
7.2.160.0030.01015.05
7.2.150.0030.00616.98
7.2.140.0000.01116.99
7.2.130.0040.01117.00
7.2.120.0040.01416.87
7.2.110.0100.00516.99
7.2.100.0080.00917.08
7.2.90.0110.00916.97
7.2.80.0030.00916.89
7.2.70.0000.01316.83
7.2.60.0040.01016.94
7.2.50.0070.00716.84
7.2.40.0030.00817.11
7.2.30.0020.00817.05
7.2.20.0070.00616.90
7.2.10.0040.00816.99
7.2.00.0060.00917.77
7.1.330.0030.01015.49
7.1.320.0080.00415.88
7.1.310.0110.00415.84
7.1.300.0030.01015.84
7.1.290.0040.00415.85
7.1.280.0040.01115.66
7.1.270.0040.00715.78
7.1.260.0030.00615.68
7.1.250.0100.00315.94
7.1.240.0030.00815.71
7.1.230.0030.01215.70
7.1.220.0080.00315.75
7.1.210.0040.01315.79
7.1.200.0050.00915.73
7.1.190.0040.00915.84
7.1.180.0030.01015.77
7.1.170.0050.00915.76
7.1.160.0000.01315.76
7.1.150.0020.00915.79
7.1.140.0050.00815.81
7.1.130.0110.00515.79
7.1.120.0070.00915.66
7.1.110.0060.00815.87
7.1.100.0060.00816.53
7.1.90.0020.01515.74
7.1.80.0020.01015.83
7.1.70.0030.01016.30
7.1.60.0070.00817.22
7.1.50.0110.00516.21
7.1.40.0030.01115.79
7.1.30.0080.00615.71
7.1.20.0050.00515.80
7.1.10.0060.01115.94
7.1.00.0090.02817.97
7.0.330.0030.00915.35
7.0.320.0050.00815.52
7.0.310.0050.00715.24
7.0.300.0100.00515.46
7.0.290.0080.00615.35
7.0.280.0100.00315.31
7.0.270.0060.00615.48
7.0.260.0020.01115.40
7.0.250.0070.00715.39
7.0.240.0030.01215.52
7.0.230.0050.01115.38
7.0.220.0050.00915.48
7.0.210.0050.00715.39
7.0.200.0100.00315.93
7.0.190.0000.01615.40
7.0.180.0030.01215.33
7.0.170.0050.00915.30
7.0.160.0060.00715.46
7.0.150.0050.00415.32
7.0.140.0080.02617.63
7.0.130.0050.01015.34
7.0.120.0060.00615.45
7.0.110.0030.01115.38
7.0.100.0090.02516.95
7.0.90.0100.02316.86
7.0.80.0080.01517.04
7.0.70.0070.01817.01
7.0.60.0090.01416.98
7.0.50.0080.02417.21
7.0.40.0060.02015.75
7.0.30.0030.02115.71
7.0.20.0060.01915.65
7.0.10.0070.02915.77
7.0.00.0070.01915.67
5.6.400.0030.01014.55
5.6.390.0090.00614.71
5.6.380.0020.01414.52
5.6.370.0020.01314.37
5.6.360.0030.01214.51
5.6.350.0090.00514.47
5.6.340.0060.00914.65
5.6.330.0090.00314.57
5.6.320.0050.00914.38
5.6.310.0050.00814.55
5.6.300.0030.01014.53
5.6.290.0100.00214.61
5.6.280.0050.02816.59
5.6.270.0060.00614.48
5.6.260.0090.00514.59
5.6.250.0110.01816.57
5.6.240.0070.03216.57
5.6.230.0030.02516.42
5.6.220.0040.01916.45
5.6.210.0080.01716.59
5.6.200.0080.02416.65
5.6.190.0070.02516.78
5.6.180.0110.01516.62
5.6.170.0070.01916.80
5.6.160.0080.01616.54
5.6.150.0070.02116.68
5.6.140.0040.01816.74
5.6.130.0040.01916.62
5.6.120.0070.01616.72
5.6.110.0090.01416.74
5.6.100.0050.02416.49
5.6.90.0050.02016.76
5.6.80.0010.02116.33
5.6.70.0030.01816.52
5.6.60.0060.01716.48
5.6.50.0030.01716.45
5.6.40.0070.01716.37
5.6.30.0040.03316.41
5.6.20.0050.03216.47
5.6.10.0030.02816.36
5.6.00.0090.02816.46
5.5.380.0020.03415.40
5.5.370.0050.01715.61
5.5.360.0020.02215.24
5.5.350.0070.01815.36
5.5.340.0090.02615.57
5.5.330.0050.02415.62
5.5.320.0080.01815.42
5.5.310.0040.02515.53
5.5.300.0050.01615.52
5.5.290.0050.03215.55
5.5.280.0010.02015.43
5.5.270.0040.01615.67
5.5.260.0060.02015.56
5.5.250.0060.01815.52
5.5.240.0040.02215.21
5.5.230.0020.02015.08
5.5.220.0060.01715.26
5.5.210.0030.01815.38
5.5.200.0030.02015.20
5.5.190.0060.02815.12
5.5.180.0080.03115.29
5.5.170.0020.01112.75
5.5.160.0040.01615.16
5.5.150.0060.01715.20
5.5.140.0070.03115.25
5.5.130.0010.02515.25
5.5.120.0050.02415.26
5.5.110.0040.02115.32
5.5.100.0060.02815.22
5.5.90.0070.03315.25
5.5.80.0020.03115.36
5.5.70.0040.01915.15
5.5.60.0100.02815.26
5.5.50.0090.02615.25
5.5.40.0030.03315.27
5.5.30.0050.02715.19
5.5.20.0030.03015.06
5.5.10.0010.03415.35
5.5.00.0080.02415.24
5.4.450.0050.01913.88
5.4.440.0020.01714.02
5.4.430.0040.01713.92
5.4.420.0030.02014.02
5.4.410.0030.01614.01
5.4.400.0030.01913.68
5.4.390.0100.01213.60
5.4.380.0070.02413.73
5.4.370.0060.02213.77
5.4.360.0090.01213.88
5.4.350.0080.01313.64
5.4.340.0050.03113.75
5.4.330.0000.00911.03
5.4.320.0050.02513.66
5.4.310.0050.02813.59
5.4.300.0080.01613.77
5.4.290.0100.02613.68
5.4.280.0050.03113.70
5.4.270.0040.03213.62
5.4.260.0030.01813.60
5.4.250.0050.02713.69
5.4.240.0050.03013.83
5.4.230.0080.02713.79
5.4.220.0040.02713.80
5.4.210.0110.02413.75
5.4.200.0080.01813.64
5.4.190.0010.03513.77
5.4.180.0070.02913.74
5.4.170.0050.02113.75
5.4.160.0090.02813.63
5.4.150.0070.01813.65
5.4.140.0040.03013.04
5.4.130.0060.01312.98
5.4.120.0030.02912.96
5.4.110.0020.01812.88
5.4.100.0060.01913.03
5.4.90.0010.03212.78
5.4.80.0080.01313.00
5.4.70.0020.02812.92
5.4.60.0020.02713.03
5.4.50.0080.02612.89
5.4.40.0030.02912.93
5.4.30.0030.02012.88
5.4.20.0070.02712.79
5.4.10.0030.01912.93
5.4.00.0060.01812.80
5.3.290.0060.02912.10
5.3.280.0080.02512.08
5.3.270.0040.03012.09
5.3.260.0020.02212.08
5.3.250.0040.03012.00
5.3.240.0060.02512.06
5.3.230.0060.01412.07
5.3.220.0100.02012.04
5.3.210.0060.02612.04
5.3.200.0030.03212.02
5.3.190.0090.02912.11
5.3.180.0080.02511.99
5.3.170.0040.02812.11
5.3.160.0030.03112.00
5.3.150.0060.02512.10
5.3.140.0040.03011.96
5.3.130.0020.03112.06
5.3.120.0060.03012.05
5.3.110.0100.01711.99
5.3.100.0060.02711.95
5.3.90.0070.02711.96
5.3.80.0060.02511.86
5.3.70.0050.02811.81
5.3.60.0050.02711.92
5.3.50.0080.02511.81
5.3.40.0080.02411.78
5.3.30.0040.02611.80
5.3.20.0020.02711.66
5.3.10.0050.02611.71
5.3.00.0050.02811.63

preferences:
52.12 ms | 401 KiB | 5 Q