3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Action { /** @var \Iterator */ public $generator; public function __construct(array $data) { $this->generator = new \ArrayIterator($data); $this->generator->x = $this; // circular ref (can be any custom iterator) echo '-- c ' . spl_object_id($this) . "\n"; } public function __destruct() { echo '-- d ' . spl_object_id($this) . "\n"; } /** * @return $this */ public function filter() { $filterFx = function ($row) { return $row !== $this; // always true, dummy use $this }; $this->generator = new \CallbackFilterIterator($this->generator, $filterFx); $this->generator->rewind(); return $this; } /** * @return $this */ public function limit(int $limit = null, int $offset = 0) { $this->generator = new \LimitIterator($this->generator, $offset, $limit ?? -1); $this->generator->rewind(); return $this; } } $action = new Action(['a', 'b']); print_r(iterator_to_array($action->generator)); $action = null; gc_collect_cycles(); $action = new Action(['a', 'b']); $action->filter(); print_r(iterator_to_array($action->generator)); $action = null; gc_collect_cycles(); $action = new Action(['a', 'b']); $action->filter()->limit(1); print_r(iterator_to_array($action->generator)); $action = null; gc_collect_cycles(); echo '----------------' . "\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.5.10.0080.01018.48
8.5.00.0130.00920.14
8.4.150.0020.00014.05
8.4.140.0140.00717.69
8.4.130.0150.00518.70
8.4.120.0130.00720.40
8.4.110.0100.01020.49
8.4.100.0160.00817.93
8.4.90.0090.01218.88
8.4.80.0060.00619.58
8.4.70.0050.00418.05
8.4.60.0090.00718.93
8.4.50.0110.01021.62
8.4.40.0030.00617.71
8.4.30.0090.00620.72
8.4.20.0040.00717.97
8.4.10.0070.01319.45
8.3.280.0090.00918.42
8.3.270.0120.01116.80
8.3.260.0130.00816.67
8.3.250.0100.01018.96
8.3.240.0070.01216.77
8.3.230.0090.00816.90
8.3.220.0040.00517.20
8.3.210.0130.00618.47
8.3.200.0050.00416.91
8.3.190.0140.00517.17
8.3.180.0110.00817.31
8.3.170.0070.00716.72
8.3.160.0150.00316.99
8.3.150.0120.00617.32
8.3.140.0070.01116.87
8.3.130.0040.00418.83
8.3.120.0030.00620.64
8.3.110.0030.00618.72
8.3.100.0030.00616.85
8.3.90.0080.00026.77
8.3.80.0030.00618.68
8.3.70.0040.01118.43
8.3.60.0030.01218.56
8.3.50.0040.01220.03
8.3.40.0070.00719.88
8.3.30.0090.00618.57
8.3.20.0080.00024.18
8.3.10.0060.00324.66
8.3.00.0040.00426.16
8.2.290.0110.00920.70
8.2.280.0080.00818.65
8.2.270.0070.00316.68
8.2.260.0050.00318.87
8.2.250.0030.00619.14
8.2.240.0030.01119.14
8.2.230.0000.01020.94
8.2.220.0030.00724.06
8.2.210.0090.00626.77
8.2.200.0040.00816.88
8.2.190.0110.01116.58
8.2.180.0030.01225.92
8.2.170.0120.00318.99
8.2.160.0150.00322.96
8.2.150.0030.00525.66
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00419.64
8.2.110.0100.00022.07
8.2.100.0060.00617.91
8.2.90.0050.00517.88
8.2.80.0080.00017.97
8.2.70.0080.00017.63
8.2.60.0030.00717.93
8.2.50.0060.00318.07
8.2.40.0000.00819.88
8.2.30.0030.00518.16
8.2.20.0000.00720.41
8.2.10.0040.00417.86
8.2.00.0040.00419.27
8.1.330.0130.00623.53
8.1.320.0100.00816.28
8.1.310.0080.00816.82
8.1.300.0080.01117.96
8.1.290.0030.00630.84
8.1.280.0090.00625.92
8.1.270.0070.01023.71
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0070.00323.74
8.1.230.0080.00320.95
8.1.220.0000.00917.74
8.1.210.0060.00318.77
8.1.200.0030.00717.35
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0040.00418.57
8.1.160.0040.00418.93
8.1.150.0000.00818.67
8.1.140.0050.00217.41
8.1.130.0000.00718.92
8.1.120.0070.00017.47
8.1.110.0030.00617.52
8.1.100.0070.00017.50
8.1.90.0040.00417.44
8.1.80.0060.00317.38
8.1.70.0000.00817.45
8.1.60.0050.00417.60
8.1.50.0040.00417.58
8.1.40.0110.00017.57
8.1.30.0040.00417.65
8.1.20.0000.00817.54
8.1.10.0050.00317.56
8.1.00.0050.00317.50
8.0.300.0030.00621.51
8.0.290.0050.00316.75
8.0.280.0030.00518.51
8.0.270.0030.00316.91
8.0.260.0030.00318.46
8.0.250.0040.00417.01
8.0.240.0000.00716.97
8.0.230.0070.00016.97
8.0.220.0030.00516.80
8.0.210.0040.00416.88
8.0.200.0060.00016.99
8.0.190.0030.00516.92
8.0.180.0070.00016.95
8.0.170.0030.00516.89
8.0.160.0000.00816.93
8.0.150.0040.00416.88
8.0.140.0000.00716.73
8.0.130.0030.00516.88
8.0.120.0040.00316.84
8.0.110.0050.00316.89
8.0.100.0040.00416.88
8.0.90.0010.00616.92
8.0.80.0040.00416.80
8.0.70.0080.00016.90
8.0.60.0080.00016.83
8.0.50.0050.00316.71
8.0.30.0040.00416.91
8.0.20.0020.00616.79
8.0.10.0000.00716.98
7.4.330.0000.00615.55
7.4.320.0000.00616.53
7.4.300.0020.00516.63
7.4.290.0020.00516.47
7.4.280.0080.00016.51
7.4.270.0000.00716.55
7.4.260.0020.00516.54
7.4.250.0040.00316.58
7.4.240.0030.00416.49
7.4.230.0020.00516.54
7.4.220.0000.00716.50
7.4.210.0030.00316.44
7.4.200.0070.00016.47
7.4.190.0040.00416.62
7.4.180.0050.00216.58
7.4.160.0030.00316.62
7.4.150.0030.00316.55
7.4.140.0020.00516.45
7.4.130.0020.00516.34
7.4.120.0060.00216.41
7.4.110.0020.00516.52
7.4.100.0030.00316.52
7.4.90.0050.00216.44
7.4.80.0050.00216.46
7.4.70.0060.00216.47
7.4.60.0020.00616.49
7.4.50.0030.00316.38
7.4.40.0050.00216.37
7.4.30.0070.00016.42
7.4.20.0050.00216.54
7.4.10.0050.00316.44
7.4.00.0040.00416.52

preferences:
35.64 ms | 403 KiB | 5 Q