3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestClass { public function __destruct() { App::$flg = true; } } class App { public static $flg = false; public static function main() { $methods = array_filter( (new \ReflectionClass(__CLASS__))->getMethods(), function (\ReflectionMethod $r) { return preg_match('/^test/', $r->getName()); } ); array_walk($methods, function (\ReflectionMethod $r) { $r->invoke(null, null); }); } public static function testArray() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = array($aa); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testObject() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \stdClass(); $bb->aa = $aa; $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplFixedArray() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplFixedArray(1); $bb[0] = $aa; $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplObjectStorage() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplObjectStorage(); $bb->attach($aa); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testArrayObject() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \ArrayObject([$aa]); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplDoublyLinkedList() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplDoublyLinkedList(); $bb->push($aa); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplMaxHeap() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplMaxHeap(); $bb->insert($aa); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplPriorityQueue() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplPriorityQueue(); $bb->insert($aa, 1); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } } App::main();

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.0030.01418.50
8.3.50.0110.01118.43
8.3.40.0120.00618.97
8.3.30.0040.01119.04
8.3.20.0110.00420.33
8.3.10.0030.00620.73
8.3.00.0040.00421.94
8.2.180.0090.00918.33
8.2.170.0150.00422.96
8.2.160.0140.00322.38
8.2.150.0050.00324.18
8.2.140.0040.01224.66
8.2.130.0050.00526.16
8.2.120.0000.00821.00
8.2.110.0060.00320.35
8.2.100.0080.00418.16
8.2.90.0040.00418.09
8.2.80.0030.00617.97
8.2.70.0060.00617.93
8.2.60.0060.00318.22
8.2.50.0030.00518.10
8.2.40.0080.00021.26
8.2.30.0000.00819.30
8.2.20.0040.00417.88
8.2.10.0000.00818.07
8.2.00.0030.00618.24
8.1.280.0120.00325.92
8.1.270.0030.01222.12
8.1.260.0100.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00717.60
8.1.230.0070.00721.22
8.1.220.0040.00417.91
8.1.210.0080.00019.05
8.1.200.0070.00317.73
8.1.190.0040.00417.60
8.1.180.0050.00318.10
8.1.170.0050.00318.93
8.1.160.0040.00418.95
8.1.150.0040.00418.86
8.1.140.0000.00819.54
8.1.130.0040.00417.68
8.1.120.0030.00517.53
8.1.110.0040.00417.67
8.1.100.0000.00817.60
8.1.90.0050.00317.57
8.1.80.0000.00717.66
8.1.70.0040.00417.71
8.1.60.0050.00317.72
8.1.50.0050.00517.64
8.1.40.0060.00317.60
8.1.30.0030.00617.83
8.1.20.0040.00417.60
8.1.10.0050.00317.78
8.1.00.0030.00617.72
8.0.300.0000.00819.91
8.0.290.0070.00317.00
8.0.280.0040.00418.50
8.0.270.0050.00217.23
8.0.260.0040.00417.22
8.0.250.0030.00317.18
8.0.240.0020.00517.20
8.0.230.0080.00017.23
8.0.220.0000.00717.03
8.0.210.0050.00317.15
8.0.200.0060.00017.11
8.0.190.0080.00017.18
8.0.180.0040.00417.21
8.0.170.0000.00817.17
8.0.160.0050.00317.12
8.0.150.0030.00517.02
8.0.140.0070.00717.00
8.0.130.0060.00013.67
8.0.120.0050.00317.13
8.0.110.0040.00417.11
8.0.100.0070.00017.03
8.0.90.0050.00317.17
8.0.80.0160.00017.09
8.0.70.0040.00417.11
8.0.60.0080.00016.95
8.0.50.0040.00417.16
8.0.30.0150.00717.37
8.0.20.0120.01017.40
8.0.10.0070.00017.32
8.0.00.0110.00817.04
7.4.330.0000.00516.76
7.4.320.0070.00016.68
7.4.300.0030.00316.67
7.4.290.0080.00016.79
7.4.280.0000.00716.86
7.4.270.0040.00416.75
7.4.260.0040.00416.71
7.4.250.0040.00416.63
7.4.240.0040.00416.75
7.4.230.0060.00316.68
7.4.220.0070.01316.82
7.4.210.0080.00616.80
7.4.200.0080.00016.68
7.4.160.0100.00716.82
7.4.150.0110.00817.40
7.4.140.0110.01417.86
7.4.130.0070.01316.75
7.4.120.0110.00616.78
7.4.110.0090.00916.76
7.4.100.0120.00616.79
7.4.90.0090.00916.93
7.4.80.0090.01519.39
7.4.70.0140.00916.85
7.4.60.0120.00616.82
7.4.50.0100.00616.54
7.4.40.0090.00916.80
7.4.30.0160.00016.62
7.4.10.0100.01015.06
7.4.00.0080.00715.15
7.3.330.0000.00513.41
7.3.320.0030.00313.44
7.3.310.0030.00416.35
7.3.300.0000.00716.54
7.3.290.0110.00516.49
7.3.280.0100.00916.54
7.3.270.0040.01317.40
7.3.260.0150.00616.55
7.3.250.0110.00716.67
7.3.240.0080.00816.73
7.3.230.0150.00416.88
7.3.210.0100.00716.44
7.3.200.0030.01516.93
7.3.190.0120.00616.88
7.3.180.0080.00816.91
7.3.170.0100.01416.40
7.3.160.0060.01016.72
7.3.130.0040.01815.02
7.3.120.0060.00914.99
7.3.110.0130.00515.14
7.3.100.0060.00915.04
7.3.90.0050.01215.12
7.3.80.0120.00515.02
7.3.70.0040.00714.87
7.3.60.0070.00914.94
7.3.50.0050.00915.11
7.3.40.0110.00415.07
7.3.30.0080.00615.11
7.3.20.0060.00916.92
7.3.10.0100.00516.64
7.3.00.0090.00716.78
7.2.330.0100.01016.94
7.2.320.0140.00416.77
7.2.310.0090.00916.85
7.2.300.0090.01616.94
7.2.290.0060.02016.68
7.2.260.0030.01415.25
7.2.250.0060.01315.23
7.2.240.0060.01315.22
7.2.230.0110.00415.09
7.2.220.0050.01015.16
7.2.210.0070.01015.12
7.2.200.0030.01215.05
7.2.190.0040.01415.21
7.2.180.0060.00815.15
7.2.170.0050.00815.06
7.2.160.0030.01314.96
7.2.150.0040.01416.96
7.2.140.0120.00017.15
7.2.130.0030.01316.94
7.2.120.0110.00317.00
7.2.110.0070.01016.70
7.2.100.0070.01017.06
7.2.90.0030.01217.14
7.2.80.0000.01117.07
7.2.70.0030.01017.17
7.2.60.0030.00716.85
7.2.50.0060.00617.12
7.2.40.0080.00317.07
7.2.30.0000.01117.11
7.2.20.0090.00617.20
7.2.10.0070.00317.02
7.2.00.0060.00718.13
7.1.330.0050.00715.95
7.1.320.0070.00815.89
7.1.310.0050.00515.88
7.1.300.0090.00515.91
7.1.290.0050.00915.79
7.1.280.0070.00815.96
7.1.270.0060.00815.83
7.1.260.0040.01116.06
7.1.250.0000.00915.98
7.1.240.0080.00816.07
7.1.230.0030.00916.12
7.1.220.0070.00715.93
7.1.210.0040.01115.86
7.1.200.0110.00416.02
7.1.190.0080.00015.92
7.1.180.0090.00015.87
7.1.170.0040.01115.96
7.1.160.0080.00316.05
7.1.150.0030.00916.07
7.1.140.0080.00315.77
7.1.130.0070.00316.12
7.1.120.0000.01416.05
7.1.110.0040.00815.91
7.1.100.0090.00517.05
7.1.90.0030.01015.97
7.1.80.0030.01015.91
7.1.70.0100.00216.62
7.1.60.0020.01517.68
7.1.50.0060.01216.59
7.1.40.0030.00715.79
7.1.30.0050.00516.02
7.1.20.0080.00416.04
7.1.10.0040.01115.73
7.1.00.0030.04319.23
7.0.330.0060.00615.66
7.0.320.0030.00515.52
7.0.310.0060.00615.65
7.0.300.0060.00915.64
7.0.290.0100.00015.52
7.0.280.0080.00815.41
7.0.270.0030.01015.47
7.0.260.0060.00615.54
7.0.250.0120.00015.85
7.0.240.0050.00515.82
7.0.230.0060.00615.57
7.0.220.0030.00915.50
7.0.210.0030.00615.43
7.0.200.0050.00815.40
7.0.190.0080.00515.57
7.0.180.0040.00715.61
7.0.170.0040.00415.66
7.0.160.0000.01415.65
7.0.150.0030.00615.45
7.0.140.0100.00315.38
7.0.130.0070.01115.56
7.0.120.0120.00415.86
7.0.110.0070.00715.46
7.0.100.0120.03117.81
7.0.90.0150.04517.78
7.0.80.0150.03017.83
7.0.70.0050.04317.83
7.0.60.0080.02517.86
7.0.50.0070.04717.87
7.0.40.0090.04616.97
7.0.30.0100.04217.01
7.0.20.0050.04616.91
7.0.10.0100.04016.91
7.0.00.0080.04716.79
5.6.400.0060.00914.59
5.6.390.0030.00714.73
5.6.380.0120.00314.45
5.6.370.0000.01414.77
5.6.360.0060.00914.90
5.6.350.0050.00514.76
5.6.340.0110.00414.98
5.6.330.0030.01014.39
5.6.320.0090.00614.71
5.6.310.0100.00314.70
5.6.300.0000.01014.77
5.6.290.0100.00314.57
5.6.280.0080.03017.83
5.6.270.0160.00314.86
5.6.260.0030.01214.71
5.6.250.0020.04417.76
5.6.240.0110.04317.64
5.6.230.0050.03717.76
5.6.220.0090.04517.66
5.6.210.0030.04817.58
5.6.200.0080.02317.96
5.6.190.0150.04017.87
5.6.180.0050.04717.92
5.6.170.0110.04217.77
5.6.160.0090.03117.90
5.6.150.0070.04417.88
5.6.140.0030.04417.97
5.6.130.0080.04117.89
5.6.120.0080.03817.89
5.6.110.0040.04417.88
5.6.100.0030.05217.82
5.6.90.0030.03117.75
5.6.80.0080.04117.46
5.6.70.0080.04117.42
5.6.60.0060.04317.56
5.6.50.0090.04217.47
5.6.40.0130.02317.52
5.6.30.0050.02717.52
5.6.20.0050.02817.62
5.6.10.0020.04717.50
5.6.00.0070.04117.52
5.5.380.0100.02817.64
5.5.370.0050.04117.49
5.5.360.0070.02517.48
5.5.350.0060.04217.57
5.5.340.0060.02817.76
5.5.330.0030.04717.70
5.5.320.0130.03717.51
5.5.310.0050.03317.76
5.5.300.0060.04517.65
5.5.290.0120.04217.81
5.5.280.0130.04317.70
5.5.270.0100.04317.73
5.5.260.0080.04417.66
5.5.250.0080.04317.65
5.5.240.0030.04417.39
5.5.230.0070.03417.40
5.5.220.0090.03317.38
5.5.210.0080.03217.44
5.5.200.0080.03817.44
5.5.190.0080.03717.26
5.5.180.0070.04717.33
5.5.170.0030.01214.74
5.5.160.0090.04117.30
5.5.150.0130.02717.20
5.5.140.0030.04717.30
5.5.130.0030.02917.25
5.5.120.0020.03217.34
5.5.110.0100.04017.46
5.5.100.0140.04017.43
5.5.90.0070.04317.26
5.5.80.0070.04517.33
5.5.70.0090.04417.42
5.5.60.0030.04617.36
5.5.50.0050.04617.36
5.5.40.0080.02217.21
5.5.30.0140.03517.36
5.5.20.0090.03817.44
5.5.10.0100.03517.30
5.5.00.0060.04617.33

preferences:
54.33 ms | 400 KiB | 5 Q