3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { public $var = array(1,2,3); public function __construct($array) { $var = array(1,2,3); 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 $count = 0;*/ /* public function __construct($array) { $var = array(1,2,3); if (is_array($array)) { $this->var = $array; } } */ // Required definition of interface IteratorAggregate public function getIterator() { return new MyIterator('var'); } public function add($value) { $this->var[$this->count++] = $value; } } /*$values = array('value 1','value 2','value 3');*/ $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.60.0150.00316.75
8.3.50.0110.00921.95
8.3.40.0100.00618.92
8.3.30.0060.01219.02
8.3.20.0050.00320.16
8.3.10.0090.00923.68
8.3.00.0150.00019.50
8.2.180.0090.00618.29
8.2.170.0070.01422.96
8.2.160.0100.00320.42
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0140.00026.16
8.2.120.0030.00622.31
8.2.110.0070.00322.26
8.2.100.0120.00017.91
8.2.90.0030.00519.11
8.2.80.0050.00318.16
8.2.70.0090.00017.63
8.2.60.0000.00818.16
8.2.50.0070.00418.07
8.2.40.0040.00418.34
8.2.30.0060.00318.05
8.2.20.0000.00717.67
8.2.10.0030.00618.11
8.2.00.0030.00517.81
8.1.280.0110.01125.92
8.1.270.0080.00023.83
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.76
8.1.230.0000.01119.22
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0030.00717.35
8.1.190.0050.00317.53
8.1.180.0040.00418.10
8.1.170.0080.00018.65
8.1.160.0030.00522.10
8.1.150.0000.00718.57
8.1.140.0070.00017.43
8.1.130.0000.00717.76
8.1.120.0000.00717.48
8.1.110.0040.00417.31
8.1.100.0000.00717.54
8.1.90.0040.00417.52
8.1.80.0060.00317.50
8.1.70.0030.00317.46
8.1.60.0000.00917.57
8.1.50.0000.00817.54
8.1.40.0050.00317.51
8.1.30.0030.00717.64
8.1.20.0040.00417.66
8.1.10.0020.00517.46
8.1.00.0000.00817.44
8.0.300.0030.00618.77
8.0.290.0000.00717.16
8.0.280.0020.00518.42
8.0.270.0000.00717.34
8.0.260.0030.00316.90
8.0.250.0030.00316.96
8.0.240.0040.00417.05
8.0.230.0080.00017.06
8.0.220.0030.00317.05
8.0.210.0030.00316.94
8.0.200.0030.00616.95
8.0.190.0080.00016.91
8.0.180.0040.00417.01
8.0.170.0030.00617.04
8.0.160.0040.00416.86
8.0.150.0000.00716.83
8.0.140.0080.00316.90
8.0.130.0070.00013.35
8.0.120.0050.00316.94
8.0.110.0000.00816.88
8.0.100.0030.00516.81
8.0.90.0000.00717.05
8.0.80.0100.01016.97
8.0.70.0040.00416.81
8.0.60.0040.00416.92
8.0.50.0000.00816.97
8.0.30.0080.01317.24
8.0.20.0120.00617.40
8.0.10.0020.00517.00
8.0.00.0080.01316.91
7.4.330.0050.00015.00
7.4.320.0040.00416.52
7.4.300.0030.00316.51
7.4.290.0040.00316.66
7.4.280.0050.00716.51
7.4.270.0030.00316.39
7.4.260.0040.00416.50
7.4.250.0030.00516.42
7.4.240.0000.00716.61
7.4.230.0000.00716.47
7.4.220.0070.01016.47
7.4.210.0080.00616.59
7.4.200.0030.00516.37
7.4.190.0040.00416.60
7.4.160.0180.00416.59
7.4.150.0090.00917.40
7.4.140.0090.00817.86
7.4.130.0090.00916.56
7.4.120.0150.00816.52
7.4.110.0100.00916.59
7.4.100.0120.01016.42
7.4.90.0130.01216.39
7.4.80.0060.01319.39
7.4.70.0040.01316.41
7.4.60.0070.01116.41
7.4.50.0000.00516.47
7.4.40.0030.01022.77
7.4.30.0030.01316.49
7.4.00.0000.01214.69
7.3.330.0050.00013.46
7.3.320.0000.00613.30
7.3.310.0000.00716.44
7.3.300.0070.00016.42
7.3.290.0030.01016.53
7.3.280.0080.00816.49
7.3.270.0160.00017.40
7.3.260.0170.00616.28
7.3.250.0100.01316.47
7.3.240.0090.00916.52
7.3.230.0140.00916.39
7.3.210.0120.00916.44
7.3.200.0110.00719.39
7.3.190.0140.00916.50
7.3.180.0060.00916.41
7.3.170.0130.00316.47
7.3.160.0080.00816.64
7.3.120.0040.01114.74
7.2.330.0070.01016.75
7.2.320.0040.01216.85
7.2.310.0090.00916.86
7.2.300.0130.00316.54
7.2.290.0110.00716.43
7.1.100.0060.00617.88
7.1.70.0060.01617.25
7.1.60.0110.01419.33
7.1.50.0070.01716.77
7.1.00.0030.07722.40
7.0.200.0000.00816.82
7.0.140.0000.07722.21
7.0.110.0770.04719.89
7.0.100.0600.06719.95
7.0.90.0500.04319.87
7.0.80.0370.05320.05
7.0.70.0570.06720.00
7.0.60.0570.07019.95
7.0.50.0530.07020.00
7.0.40.0070.08319.66
7.0.30.0070.08719.84
7.0.20.0100.07719.70
7.0.10.0130.07019.87
7.0.00.0030.08319.70
5.6.280.0070.07020.91
5.6.260.0130.06320.52
5.6.250.0130.07720.52
5.6.240.0130.04020.73
5.6.230.0070.07320.73
5.6.220.0000.05020.71
5.6.210.0130.07720.72
5.6.200.0000.04320.57
5.6.190.0130.07720.68
5.6.180.0070.05720.48
5.6.170.0070.07320.71
5.6.160.0130.07320.48
5.6.150.0070.08720.48
5.6.140.0130.06320.63
5.6.130.0100.08020.60
5.6.120.0100.07720.71
5.6.110.0070.08020.59
5.6.100.0100.08020.55
5.6.90.0100.07320.61
5.6.80.0100.07020.02
5.6.70.0100.07720.08
5.6.60.0170.06720.06
5.6.50.0100.07019.95
5.6.40.0030.07719.84
5.6.30.0130.06720.01
5.6.20.0130.07319.98
5.6.10.0070.06719.92
5.6.00.0130.07320.07
5.5.380.0070.04017.69
5.5.370.0130.07317.64
5.5.360.0100.07717.68
5.5.350.0130.07717.68
5.5.340.0000.08018.09
5.5.330.0100.07318.23
5.5.320.0000.07318.14
5.5.310.0100.07318.25
5.5.300.0030.07718.05
5.5.290.0030.08718.10
5.5.280.0030.08718.09
5.5.270.0030.08317.92
5.5.260.0030.08318.25
5.5.250.0030.08017.77
5.5.240.0070.08017.31
5.5.230.0100.07317.47
5.5.220.0070.07017.47
5.5.210.0170.06017.50
5.5.200.0030.07017.40
5.5.190.0030.08017.44
5.5.180.0100.07017.45
5.5.160.0070.07717.28
5.5.150.0130.02717.39
5.5.140.0100.07317.17
5.5.130.0070.04317.27
5.5.120.0030.07017.48
5.5.110.0000.07317.46
5.5.100.0070.07317.37
5.5.90.0070.07317.10
5.5.80.0030.07717.07
5.5.70.0070.07017.17
5.5.60.0030.06717.07
5.5.50.0030.07717.51
5.5.40.0030.08317.36
5.5.30.0030.07317.49
5.5.20.0030.07717.11
5.5.10.0070.03717.48
5.5.00.0070.04717.06
5.4.450.0100.07719.52
5.4.440.0100.07719.49
5.4.430.0000.04319.33
5.4.420.0100.07319.33
5.4.410.0130.07319.34
5.4.400.0100.07018.95
5.4.390.0070.07319.02
5.4.380.0000.06718.95
5.4.370.0130.07019.18
5.4.360.0030.07719.17
5.4.350.0070.03019.24
5.4.340.0100.07019.01
5.4.320.0000.08318.99
5.4.310.0000.08318.99
5.4.300.0070.04318.95
5.4.290.0070.07318.99
5.4.280.0100.06719.24
5.4.270.0070.04319.22
5.4.260.0230.05718.95
5.4.250.0130.06719.18
5.4.240.0170.04019.08
5.4.230.0030.07719.08
5.4.220.0070.04319.23
5.4.210.0030.05719.17
5.4.200.0000.08018.98
5.4.190.0070.04018.93
5.4.180.0030.04318.94
5.4.170.0070.07019.32
5.4.160.0030.07718.99
5.4.150.0100.07019.16
5.4.140.0100.06716.29
5.4.130.0100.07016.36
5.4.120.0030.04716.50
5.4.110.0030.03716.57
5.4.100.0000.04716.59
5.4.90.0070.07316.47
5.4.80.0030.04016.55
5.4.70.0030.03716.41
5.4.60.0030.07316.55
5.4.50.0000.07716.49
5.4.40.0130.05016.53
5.4.30.0030.07316.63
5.4.20.0030.06716.52
5.4.10.0100.06316.54
5.4.00.0030.07016.07
5.3.290.0100.06314.54
5.3.280.0070.04314.62
5.3.270.0030.07014.64
5.3.260.0070.03714.85
5.3.250.0000.08314.70
5.3.240.0070.07014.48
5.3.230.0170.05014.72
5.3.220.0100.07314.60
5.3.210.0070.07314.59
5.3.200.0100.07314.67
5.3.190.0070.07714.59
5.3.180.0070.07314.66
5.3.170.0030.06314.66
5.3.160.0030.06314.59
5.3.150.0070.05314.67
5.3.140.0100.06314.66
5.3.130.0070.05714.42
5.3.120.0070.07714.65
5.3.110.0100.07714.80
5.3.100.0070.05714.03
5.3.90.0000.05014.26
5.3.80.0070.07314.05
5.3.70.0070.07014.05
5.3.60.0070.07314.10
5.3.50.0000.05713.97
5.3.40.0070.08013.97
5.3.30.0030.04714.01
5.3.20.0130.06713.84
5.3.10.0070.03713.65
5.3.00.0030.06713.69
5.2.170.0000.05311.92
5.2.160.0030.06011.92
5.2.150.0070.06011.92
5.2.140.0030.07311.92
5.2.130.0070.03711.92
5.2.120.0000.04711.92
5.2.110.0000.03011.92
5.2.100.0030.03711.92
5.2.90.0100.05011.92
5.2.80.0030.04711.92
5.2.70.0070.05711.92
5.2.60.0000.04011.92
5.2.50.0070.06711.92
5.2.40.0070.05711.92
5.2.30.0030.05011.92
5.2.20.0000.03011.92
5.2.10.0000.03311.92
5.2.00.0100.05711.92
5.1.60.0000.04711.92
5.1.50.0070.02311.92
5.1.40.0030.04011.92
5.1.30.0000.06011.92
5.1.20.0000.02711.92
5.1.10.0030.05711.92
5.1.00.0000.06011.92
5.0.50.0030.03711.92
5.0.40.0000.04711.92
5.0.30.0030.06311.92
5.0.20.0000.04711.92
5.0.10.0030.04311.92
5.0.00.0030.06011.92
4.4.90.0000.02711.92
4.4.80.0030.03311.92
4.4.70.0070.03311.92
4.4.60.0100.02711.92
4.4.50.0000.02711.92
4.4.40.0000.04011.92
4.4.30.0000.04011.92
4.4.20.0070.03011.92
4.4.10.0130.02311.92
4.4.00.0030.04711.92
4.3.110.0000.03011.92
4.3.100.0000.03711.92
4.3.90.0030.03311.92
4.3.80.0000.05311.92
4.3.70.0030.03011.92
4.3.60.0030.03311.92
4.3.50.0030.03711.92
4.3.40.0000.05311.92
4.3.30.0030.03311.92
4.3.20.0000.02011.92
4.3.10.0030.03311.92
4.3.00.0000.03711.92

preferences:
53.6 ms | 400 KiB | 5 Q