3v4l.org

run code in 300+ PHP versions simultaneously
<?php class myData implements IteratorAggregate { public $property1 = "Public property one"; public $property2 = "Public property two"; public $property3 = "Public property three"; public function getIterator() : ArrayIterator { return new ArrayIterator($this); } } class myIterator implements Iterator { private $position = 0; private $array = ['property1'=>'Public property one', 'property2'=>'Public property two', 'property3'=>'Public property three']; function rewind(): void { $this->position = 0; } function current(): mixed { $position = $this->position + 1; $key = 'property' . $position; return $this->array[$key]; } function key(): mixed { $position = $this->position + 1; $key = 'property' . $position; return $key; } function next(): void { ++$this->position; } function valid(): bool { $position = $this->position + 1; $key = 'property' . $position; return isset($this->array[$key]); } } $renderFunction = function($iterator) { foreach($iterator as $key => $value) { echo "$key: $value\n"; foreach($iterator as $key => $value) { echo " $key: $value\n"; } } }; echo "----- Aggregate Iterator -----\n"; $renderFunction(new myData); echo "\n----- Simple Iterator-----\n"; $renderFunction(new myIterator);

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.0110.00819.47
8.5.00.0130.00920.31
8.4.150.0030.00014.05
8.4.140.0150.00617.46
8.4.130.0130.00817.77
8.4.120.0120.00724.21
8.4.110.0050.00622.44
8.4.100.0120.00818.89
8.4.90.0160.00418.83
8.4.80.0030.00518.79
8.4.70.0040.00617.92
8.4.60.0100.01118.96
8.4.50.0060.00519.41
8.4.40.0100.01020.62
8.4.30.0030.01623.93
8.4.20.0030.01619.57
8.4.10.0060.00322.30
8.3.280.0120.00918.35
8.3.270.0150.01116.66
8.3.260.0090.01016.95
8.3.250.0090.01018.80
8.3.240.0070.01017.13
8.3.230.0160.00316.32
8.3.220.0120.00719.03
8.3.210.0100.00718.66
8.3.200.0070.00416.48
8.3.190.0050.00317.18
8.3.180.0100.00716.60
8.3.170.0090.00918.75
8.3.160.0180.00318.29
8.3.150.0100.01017.17
8.3.140.0040.00716.75
8.3.130.0090.00018.29
8.3.120.0050.00318.98
8.3.110.0070.00720.94
8.3.100.0030.00624.06
8.3.90.0080.00026.77
8.3.80.0060.00318.30
8.3.70.0040.01516.75
8.3.60.0180.00416.88
8.3.50.0140.00718.65
8.3.40.0100.00321.88
8.3.30.0120.00318.59
8.3.20.0080.00024.18
8.3.10.0060.00324.66
8.3.00.0060.00326.16
8.2.290.0040.00520.22
8.2.280.0090.00620.13
8.2.270.0040.01417.32
8.2.260.0110.00019.04
8.2.250.0150.00016.70
8.2.240.0060.00318.96
8.2.230.0060.00322.58
8.2.220.0040.00437.54
8.2.210.0060.01326.77
8.2.200.0060.00318.29
8.2.190.0070.00716.58
8.2.180.0180.00016.88
8.2.170.0090.00619.08
8.2.160.0080.00822.96
8.2.150.0000.00825.66
8.2.140.0040.00424.66
8.2.130.0050.00226.16
8.2.120.0000.00819.79
8.2.110.0030.00621.12
8.2.100.0040.00817.84
8.2.90.0000.00817.88
8.2.80.0060.00618.70
8.2.70.0000.00817.63
8.2.60.0120.00617.38
8.2.50.0190.00217.38
8.2.40.0110.00617.25
8.2.30.0150.00417.63
8.2.20.0080.00317.63
8.2.10.0080.00817.38
8.2.00.0100.00717.63
8.1.330.0080.01222.03
8.1.320.0100.00916.33
8.1.310.0100.00016.79
8.1.300.0040.00418.57
8.1.290.0090.00030.84
8.1.280.0170.00325.92
8.1.270.0030.00624.66
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0080.00323.86
8.1.230.0040.00820.86
8.1.220.0040.00418.70
8.1.210.0080.00018.77
8.1.200.0090.00017.48
8.1.190.0090.00717.25
8.1.180.0080.00817.11
8.1.170.0090.00917.13
8.1.160.0150.00716.88
8.1.150.0160.00217.25
8.1.140.0150.00417.25
8.1.130.0130.00617.12
8.1.120.0130.00417.50
8.1.110.0130.00317.13
8.1.100.0120.00417.23
8.1.90.0110.00517.13
8.1.80.0110.00517.24
8.1.70.0070.01017.23
8.1.60.0110.00717.38
8.1.50.0130.00517.36
8.1.40.0140.00417.46
8.1.30.0110.00717.50
8.1.20.0110.00717.38
8.1.10.0120.00517.34
8.1.00.0200.00017.00
8.0.300.0060.00319.89
8.0.290.0060.00316.58
8.0.280.0170.00316.52
8.0.270.0070.01116.52
8.0.260.0130.00316.75
8.0.250.0080.00816.75
8.0.240.0160.00016.75
8.0.230.0130.00616.52
8.0.220.0070.01016.63
8.0.210.0170.00016.63
8.0.200.0130.00316.63
8.0.190.0140.00316.52
8.0.180.0060.01116.52
8.0.170.0110.00516.75
8.0.160.0120.00416.63
8.0.150.0150.00416.52
8.0.140.0040.01216.63
8.0.130.0130.00316.61
8.0.120.0090.00916.73
8.0.110.0100.00516.52
8.0.100.0110.00616.52
8.0.90.0070.01016.52
8.0.80.0130.00316.63
8.0.70.0160.00016.52
8.0.60.0170.00016.63
8.0.50.0120.00816.75
8.0.30.0170.00016.59
8.0.20.0100.00616.75
8.0.10.0130.00316.87

preferences:
78.15 ms | 403 KiB | 5 Q