3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private $var = array(); public function __construct($array) { if (is_array($array)) { $this->var = $array; } } public function rewind() { echo "rewinding\n"; reset($this->var); } public function current() { $var = current($this->var); echo "current: $var\n"; return $var; } public function key() { $var = key($this->var); echo "key: $var\n"; return $var; } public function next() { $var = next($this->var); echo "next: $var\n"; return $var; } public function valid() { $key = key($this->var); $var = ($key !== NULL && $key !== FALSE); echo "valid: $var\n"; return $var; } } class MyCollection implements IteratorAggregate { private $items = array(); private $count = 0; // Required definition of interface IteratorAggregate public function getIterator() { return new MyIterator($this->items); } public function add($value) { $this->items[$this->count++] = $value; } } $coll = new MyCollection(); $coll->add('value 1'); $coll->add('value 2'); $coll->add('value 3'); foreach ($coll as $key => $val) { echo "key/value: [$key -> $val]\n\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.3.70.0070.00716.88
8.3.60.0140.00716.63
8.3.50.0120.00716.66
8.3.40.0110.00618.85
8.3.30.0090.00618.81
8.3.20.0050.00318.59
8.3.10.0060.00318.69
8.3.00.0080.00019.51
8.2.180.0090.00616.63
8.2.170.0040.01122.96
8.2.160.0060.01318.84
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0030.00626.16
8.2.120.0000.00821.02
8.2.110.0060.00320.52
8.2.100.0120.00018.03
8.2.90.0050.00319.20
8.2.80.0040.00419.39
8.2.70.0080.00017.63
8.2.60.0000.00818.05
8.2.50.0040.00418.07
8.2.40.0000.00818.22
8.2.30.0050.00218.04
8.2.20.0030.00517.72
8.2.10.0080.00017.64
8.2.00.0040.00417.82
8.1.280.0180.00325.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0140.00022.04
8.1.230.0150.00020.82
8.1.220.0050.00318.77
8.1.210.0000.00719.07
8.1.200.0040.00417.35
8.1.190.0040.00417.63
8.1.180.0030.00618.10
8.1.170.0030.00618.84
8.1.160.0050.00218.81
8.1.150.0050.00318.64
8.1.140.0040.00417.36
8.1.130.0030.00317.79
8.1.120.0050.00217.42
8.1.110.0000.00717.37
8.1.100.0000.00817.46
8.1.90.0030.00417.46
8.1.80.0040.00417.38
8.1.70.0000.00917.36
8.1.60.0000.00717.61
8.1.50.0040.00417.37
8.1.40.0050.00317.55
8.1.30.0070.00417.57
8.1.20.0000.00717.61
8.1.10.0000.00817.57
8.1.00.0040.00417.38
8.0.300.0000.00819.94
8.0.290.0040.00416.63
8.0.280.0030.00318.32
8.0.270.0000.00716.82
8.0.260.0070.00016.83
8.0.250.0030.00316.93
8.0.240.0000.00716.98
8.0.230.0000.00716.84
8.0.220.0040.00416.73
8.0.210.0070.00016.86
8.0.200.0030.00316.79
8.0.190.0000.00817.00
8.0.180.0040.00416.94
8.0.170.0080.00016.89
8.0.160.0000.00716.88
8.0.150.0060.00316.90
8.0.140.0100.00016.74
8.0.130.0030.00513.34
8.0.120.0070.00016.88
8.0.110.0040.00416.68
8.0.100.0030.00316.88
8.0.90.0040.00416.79
8.0.80.0090.00616.82
8.0.70.0050.00216.77
8.0.60.0000.00716.86
8.0.50.0040.00416.77
8.0.30.0100.01017.22
8.0.20.0060.01217.12
8.0.10.0040.00417.11
8.0.00.0110.00816.69
7.4.330.0030.00313.01
7.4.320.0030.00316.64
7.4.300.0070.00016.37
7.4.290.0030.00316.54
7.4.280.0060.00316.60
7.4.270.0030.00316.53
7.4.260.0070.00013.32
7.4.250.0040.00416.58
7.4.240.0000.00716.51
7.4.230.0070.00016.32
7.4.220.0100.00716.55
7.4.210.0060.01316.54
7.4.200.0050.00216.50
7.4.190.0070.00016.58
7.4.160.0170.00316.51
7.4.150.0090.00916.48
7.4.140.0030.01316.50
7.4.130.0110.01116.56
7.4.120.0000.01616.23
7.4.110.0150.00916.49
7.4.100.0150.00416.60
7.4.90.0040.01416.36
7.4.80.0100.01016.51
7.4.70.0130.00316.42
7.4.60.0070.01016.64
7.4.50.0060.00316.41
7.4.40.0030.00916.42
7.4.30.0140.00316.59
7.4.00.0090.00314.94
7.3.330.0000.00613.14
7.3.320.0040.00413.41
7.3.310.0040.00416.26
7.3.300.0000.00716.30
7.3.290.0110.00516.37
7.3.280.0060.00916.41
7.3.270.0200.00316.50
7.3.260.0080.00816.44
7.3.250.0140.00816.52
7.3.240.0060.01216.39
7.3.230.0120.00316.64
7.3.210.0110.00716.46
7.3.200.0140.00319.39
7.3.190.0100.01016.55
7.3.180.0060.01016.68
7.3.170.0030.01216.57
7.3.160.0110.00616.43
7.3.120.0040.01415.11
7.3.10.0030.01016.61
7.3.00.0090.00016.52
7.2.330.0190.00416.50
7.2.320.0090.00916.50
7.2.310.0130.00616.80
7.2.300.0030.01416.60
7.2.290.0130.01316.54
7.2.130.0070.00717.05
7.2.120.0080.00416.74
7.2.110.0120.00317.06
7.2.100.0090.00016.75
7.2.90.0030.01016.93
7.2.80.0070.01016.99
7.2.70.0030.00817.07
7.2.60.0000.01517.11
7.2.50.0060.00317.10
7.2.40.0110.00616.95
7.2.30.0060.00616.73
7.2.20.0030.01016.98
7.2.10.0030.00916.75
7.2.00.0080.00517.99
7.1.250.0050.00315.49
7.1.100.0000.01218.19
7.1.70.0000.01517.07
7.1.60.0070.01619.30
7.1.50.0070.01717.04
7.1.00.0070.07022.35
7.0.200.0060.00916.60
7.0.140.0070.07021.96
7.0.120.0070.06722.04
7.0.60.0230.04019.99
7.0.50.0030.06017.87
7.0.40.0370.03320.10
7.0.30.0270.05320.11
7.0.20.0200.09320.30
7.0.10.0370.08020.02
7.0.00.0330.04320.16
5.6.280.0000.07320.82
5.6.210.0100.08720.49
5.6.200.0030.04018.27
5.6.190.0200.05720.48
5.6.180.0300.04320.50
5.6.170.0270.05020.50
5.6.160.0430.06720.76
5.6.150.0330.06720.50
5.6.140.0470.06720.34
5.6.130.0270.05320.47
5.6.120.0330.07320.43
5.6.110.0370.07720.16
5.6.100.0300.04720.17
5.6.90.0370.07020.42
5.6.80.0230.04319.55
5.6.70.0270.06719.90
5.6.60.0330.06719.55
5.6.50.0230.05019.58
5.6.40.0370.04719.57
5.6.30.0300.06019.55
5.6.20.0330.04019.74
5.6.10.0300.04019.79
5.6.00.0270.07719.52
5.5.350.0000.08320.45
5.5.340.0070.06717.95
5.5.330.0300.05320.21
5.5.320.0330.04020.20
5.5.310.0330.06020.43
5.5.300.0270.07019.97
5.5.290.0270.05020.30
5.5.280.0400.04320.12
5.5.270.0330.03720.32
5.5.260.0270.04719.96
5.5.250.0300.04020.02
5.5.240.0270.04019.59
5.5.230.0300.06719.35
5.5.220.0370.07319.34
5.5.210.0370.06719.58
5.5.200.0570.05319.68
5.5.190.0200.08319.55
5.5.180.0330.04019.48
5.5.160.0330.08019.56
5.5.150.0400.05019.32
5.5.140.0230.04319.28
5.5.130.0200.04719.34
5.5.120.0270.05019.55
5.5.110.0300.08019.58
5.5.100.0300.06019.43
5.5.90.0400.05019.55
5.5.80.0270.06019.46
5.5.70.0300.04019.56
5.5.60.0270.04719.20
5.5.50.0470.03719.21
5.5.40.0330.07019.40
5.5.30.0300.04319.32
5.5.20.0430.06319.61
5.5.10.0600.07719.31
5.5.00.0270.07719.25
5.4.450.0300.08019.54
5.4.440.0200.05019.20
5.4.430.0300.03719.20
5.4.420.0300.06719.18
5.4.410.0330.08319.18
5.4.400.0330.08019.15
5.4.390.0270.07319.17
5.4.380.0270.07719.15
5.4.370.0370.06719.15
5.4.360.0200.04319.25
5.4.350.0330.03719.15
5.4.340.0130.04718.85
5.4.320.0530.05718.86
5.4.310.0300.05019.08
5.4.300.0200.04719.12
5.4.290.0300.04719.00
5.4.280.0270.04019.00
5.4.270.0500.04318.85
5.4.260.0370.06019.25
5.4.250.0300.05019.28
5.4.240.0430.05319.14
5.4.230.0400.05018.98
5.4.220.0400.06718.97
5.4.210.0300.03719.20
5.4.200.0430.05718.86
5.4.190.0300.07719.19
5.4.180.0500.05019.14
5.4.170.0270.07318.84
5.4.160.0300.06719.13
5.4.150.0270.05319.13
5.4.140.0230.07316.31
5.4.130.0370.06316.38
5.4.120.0300.06316.50
5.4.110.0400.06016.41
5.4.100.0230.04016.32
5.4.90.0230.03316.39
5.4.80.0230.04016.39
5.4.70.0200.04316.28
5.4.60.0300.03016.28
5.4.50.0370.04016.43
5.4.40.0270.04316.31
5.4.30.0270.06716.64
5.4.20.0330.06716.36
5.4.10.0400.06016.27
5.4.00.0270.07015.95
5.3.290.0300.07014.73
5.3.280.0300.06314.65
5.3.270.0300.07314.70
5.3.260.0300.06314.67
5.3.250.0300.07014.77
5.3.240.0330.06314.62
5.3.230.0270.05314.63
5.3.220.0370.03714.66
5.3.210.0270.03714.50
5.3.200.0270.04714.64
5.3.190.0330.06714.66
5.3.180.0300.07314.63
5.3.170.0300.03314.59
5.3.160.0330.06014.61
5.3.150.0330.03714.58
5.3.140.0300.06714.58
5.3.130.0400.06314.61
5.3.120.0300.07314.59
5.3.110.0300.06314.62
5.3.100.0200.04314.08
5.3.90.0200.04314.12
5.3.80.0200.04014.09
5.3.70.0330.06714.09
5.3.60.0230.04014.10
5.3.50.0300.07014.01
5.3.40.0230.04013.98
5.3.30.0330.05013.93
5.3.20.0270.04713.70
5.3.10.0270.07013.82
5.3.00.0330.04013.58
5.2.170.0230.06012.58
5.2.160.0230.05012.58
5.2.150.0230.05712.58
5.2.140.0270.06012.58
5.2.130.0230.03712.58
5.2.120.0230.06012.58
5.2.110.0200.05712.58
5.2.100.0230.02712.58
5.2.90.0200.05012.58
5.2.80.0330.05312.58
5.2.70.0230.06012.58
5.2.60.0170.05312.58
5.2.50.0200.04012.58
5.2.40.0170.06012.58
5.2.30.0230.04712.58
5.2.20.0230.04712.58
5.2.10.0270.05012.58
5.2.00.0200.05312.58
5.1.60.0130.04312.58
5.1.50.0170.03012.58
5.1.40.0200.05012.58
5.1.30.0170.02712.58
5.1.20.0230.02712.58
5.1.10.0130.03012.58
5.1.00.0200.05012.58
5.0.50.0170.03712.58
5.0.40.0130.04012.58
5.0.30.0100.03012.58
5.0.20.0100.03012.58
5.0.10.0070.03312.58
5.0.00.0070.05712.58
4.4.90.0100.03712.58
4.4.80.0070.02312.58
4.4.70.0100.02712.58
4.4.60.0130.01712.58
4.4.50.0030.02012.58
4.4.40.0070.05312.58
4.4.30.0070.02012.58
4.4.20.0100.01312.58
4.4.10.0100.02712.58
4.4.00.0070.04312.58
4.3.110.0130.03312.58
4.3.100.0100.03312.58
4.3.90.0130.02312.58
4.3.80.0130.05012.58
4.3.70.0070.01712.58
4.3.60.0100.03012.58
4.3.50.0100.02312.58
4.3.40.0030.04312.58
4.3.30.0030.02012.58
4.3.20.0030.03712.58
4.3.10.0000.02712.58
4.3.00.0030.02312.58

preferences:
41.24 ms | 401 KiB | 5 Q