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($this->var); } /* public function add($value) { $this->var[$this->count++] = $value; }*/ } /*$values = array('value 1','value 2','value 3');*/ $coll = new Mycollection(); foreach ($coll as $key => $val) {$coll->getIterator($values); 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.0170.00718.50
8.3.50.0090.00921.99
8.3.40.0100.00518.71
8.3.30.0110.00418.71
8.3.20.0060.00318.45
8.3.10.0040.00420.95
8.3.00.0040.00423.61
8.2.180.0080.01216.88
8.2.170.0070.00722.96
8.2.160.0140.00020.35
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00419.77
8.2.110.0060.00320.56
8.2.100.0070.00417.91
8.2.90.0000.00919.21
8.2.80.0000.00719.32
8.2.70.0030.00617.50
8.2.60.0040.00417.80
8.2.50.0060.00318.07
8.2.40.0040.00418.34
8.2.30.0070.00019.41
8.2.20.0040.00417.80
8.2.10.0030.00617.77
8.2.00.0030.00517.89
8.1.280.0090.00625.92
8.1.270.0000.00723.99
8.1.260.0160.00326.35
8.1.250.0040.00428.09
8.1.240.0000.00922.52
8.1.230.0090.00320.97
8.1.220.0040.00418.77
8.1.210.0000.00818.77
8.1.200.0040.00417.23
8.1.190.0090.00017.53
8.1.180.0050.00318.10
8.1.170.0080.00018.59
8.1.160.0050.00218.86
8.1.150.0040.00418.78
8.1.140.0040.00417.57
8.1.130.0070.00017.84
8.1.120.0000.00717.41
8.1.110.0000.00717.48
8.1.100.0070.00017.39
8.1.90.0020.00517.53
8.1.80.0000.00817.49
8.1.70.0040.00417.43
8.1.60.0060.00317.63
8.1.50.0050.00217.45
8.1.40.0050.00317.43
8.1.30.0060.00317.70
8.1.20.0060.00317.67
8.1.10.0000.00717.51
8.1.00.0080.00017.56
8.0.300.0000.00719.98
8.0.290.0050.00217.30
8.0.280.0030.00318.42
8.0.270.0040.00417.20
8.0.260.0000.00616.97
8.0.250.0000.00716.96
8.0.240.0050.00317.02
8.0.230.0040.00417.08
8.0.220.0000.00716.90
8.0.210.0000.00716.92
8.0.200.0030.00316.92
8.0.190.0070.00017.04
8.0.180.0070.00016.99
8.0.170.0040.00417.05
8.0.160.0070.00017.03
8.0.150.0070.00016.86
8.0.140.0070.00416.91
8.0.130.0050.00013.43
8.0.120.0000.00916.84
8.0.110.0030.00616.93
8.0.100.0070.00017.05
8.0.90.0000.00716.78
8.0.80.0130.01016.98
8.0.70.0040.00416.90
8.0.60.0040.00417.04
8.0.50.0000.00816.91
8.0.30.0130.00617.21
8.0.20.0100.01317.40
8.0.10.0080.00016.96
8.0.00.0120.00816.80
7.4.330.0030.00314.97
7.4.320.0040.00416.63
7.4.300.0030.00316.53
7.4.290.0040.00416.48
7.4.280.0090.00016.54
7.4.270.0030.00316.64
7.4.260.0050.00013.28
7.4.250.0030.00516.53
7.4.240.0070.00016.68
7.4.230.0040.00416.70
7.4.220.0170.00316.40
7.4.210.0070.00816.65
7.4.200.0070.00016.61
7.4.190.0000.00816.68
7.4.160.0190.00316.68
7.4.150.0080.01717.40
7.4.140.0110.00717.86
7.4.130.0090.00916.53
7.4.120.0030.01716.53
7.4.110.0060.01216.40
7.4.100.0110.00716.53
7.4.90.0200.00316.43
7.4.80.0060.01119.39
7.4.70.0130.01016.47
7.4.60.0160.00016.48
7.4.50.0080.00016.62
7.4.40.0090.00922.77
7.4.30.0080.00816.35
7.4.00.0090.00614.96
7.3.330.0000.00513.40
7.3.320.0030.00313.39
7.3.310.0040.00416.46
7.3.300.0030.00316.38
7.3.290.0030.01016.42
7.3.280.0080.00916.45
7.3.270.0090.01117.40
7.3.260.0110.00818.24
7.3.250.0110.00816.60
7.3.240.0090.01016.60
7.3.230.0180.00016.39
7.3.210.0080.00816.44
7.3.200.0030.01319.39
7.3.190.0180.00616.57
7.3.180.0120.00816.66
7.3.170.0050.01016.50
7.3.160.0100.00716.48
7.3.120.0060.00915.10
7.2.330.0080.01116.71
7.2.320.0110.00716.50
7.2.310.0100.01016.77
7.2.300.0060.01116.53
7.2.290.0000.01716.94
7.1.100.0060.00618.09
7.1.70.0030.00317.29
7.1.60.0080.00417.18
7.1.50.0100.01317.10
7.1.00.0070.03022.51
7.0.200.0040.00416.86
7.0.140.0030.07322.01
7.0.80.0100.07721.73
7.0.70.0030.07021.64
7.0.60.0130.08021.87
7.0.50.0130.07022.10
7.0.40.0030.08720.10
7.0.30.0000.09020.04
7.0.20.0030.08320.05
7.0.10.0070.04719.94
7.0.00.0100.08020.09
5.6.280.0000.07321.07
5.6.230.0000.08320.60
5.6.220.0030.08020.54
5.6.210.0070.08020.63
5.6.200.0030.05021.10
5.6.190.0030.08321.00
5.6.180.0000.08321.04
5.6.170.0000.09020.96
5.6.160.0100.08321.09
5.6.150.0070.06021.02
5.6.140.0100.08321.05
5.6.130.0200.07321.03
5.6.120.0070.04021.08
5.6.110.0070.04021.08
5.6.100.0070.03721.08
5.6.90.0070.05721.07
5.6.80.0030.04020.46
5.6.70.0030.04320.32
5.6.60.0000.06320.44
5.6.50.0000.04320.41
5.6.40.0030.04020.49
5.6.30.0070.04720.48
5.6.20.0000.07020.39
5.6.10.0030.04020.31
5.6.00.0130.07020.48
5.5.370.0070.07320.36
5.5.360.0000.06320.30
5.5.350.0100.07720.42
5.5.340.0070.08020.81
5.5.330.0000.06320.90
5.5.320.0030.08720.66
5.5.310.0070.08020.74
5.5.300.0030.08320.90
5.5.290.0070.07320.77
5.5.280.0070.04020.89
5.5.270.0100.08020.93
5.5.260.0070.04020.80
5.5.250.0100.03320.58
5.5.240.0000.04020.20
5.5.230.0070.03320.29
5.5.220.0070.03320.16
5.5.210.0070.03720.27
5.5.200.0000.04020.25
5.5.190.0000.05720.14
5.5.180.0000.03720.24
5.5.160.0000.04020.18
5.5.150.0000.03720.16
5.5.140.0000.04020.00
5.5.130.0030.04020.27
5.5.120.0030.03320.15
5.5.110.0070.03720.23
5.5.100.0030.07719.96
5.5.90.0000.03720.02
5.5.80.0030.03320.09
5.5.70.0030.05020.11
5.5.60.0070.03720.05
5.5.50.0030.03720.07
5.5.40.0000.04020.06
5.5.30.0000.03720.14
5.5.20.0030.04020.15
5.5.10.0000.03719.99
5.5.00.0030.05019.97
5.4.450.0070.06719.29
5.4.440.0030.04319.20
5.4.430.0100.03319.50
5.4.420.0000.05319.17
5.4.410.0070.04019.10
5.4.400.0070.04319.04
5.4.390.0000.06719.13
5.4.380.0030.04019.23
5.4.370.0030.07719.04
5.4.360.0070.03318.82
5.4.350.0030.03718.85
5.4.340.0030.03019.09
5.4.320.0000.04019.00
5.4.310.0030.03719.15
5.4.300.0030.03718.84
5.4.290.0000.07719.12
5.4.280.0030.03718.90
5.4.270.0000.04019.13
5.4.260.0070.03318.87
5.4.250.0130.03318.84
5.4.240.0030.04718.94
5.4.230.0070.06719.04
5.4.220.0030.03718.94
5.4.210.0030.03019.15
5.4.200.0000.04318.84
5.4.190.0000.04019.02
5.4.180.0030.03318.89
5.4.170.0000.04019.04
5.4.160.0030.05018.85
5.4.150.0000.04319.16
5.4.140.0030.06016.43
5.4.130.0000.04016.42
5.4.120.0030.04016.44
5.4.110.0030.08016.28
5.4.100.0030.07016.33
5.4.90.0030.07016.42
5.4.80.0070.06016.37
5.4.70.0030.06716.45
5.4.60.0030.03716.25
5.4.50.0070.05716.50
5.4.40.0100.05316.46
5.4.30.0000.06016.33
5.4.20.0030.07316.47
5.4.10.0070.07716.39
5.4.00.0100.07015.82
5.3.290.0000.03714.73
5.3.280.0070.04014.53
5.3.270.0000.04714.65
5.3.260.0000.06314.76
5.3.250.0030.03714.55
5.3.240.0030.05714.68
5.3.230.0000.03714.59
5.3.220.0000.05714.65
5.3.210.0000.08014.63
5.3.200.0030.07714.61
5.3.190.0070.07014.69
5.3.180.0030.07314.57
5.3.170.0030.04714.69
5.3.160.0070.07014.64
5.3.150.0030.05714.67
5.3.140.0030.04014.71
5.3.130.0070.04714.62
5.3.120.0070.04014.63
5.3.110.0070.05014.59
5.3.100.0000.08013.98
5.3.90.0000.06014.04
5.3.80.0100.05714.06
5.3.70.0030.06713.96
5.3.60.0070.05014.12
5.3.50.0070.06013.98
5.3.40.0030.05714.06
5.3.30.0030.07313.91
5.3.20.0070.07013.85
5.3.10.0030.07013.68
5.3.00.0070.06313.77
5.2.170.0030.06311.72
5.2.160.0030.05711.72
5.2.150.0000.06311.72
5.2.140.0030.06011.72
5.2.130.0030.03711.72
5.2.120.0030.05011.72
5.2.110.0000.04311.72
5.2.100.0000.06311.72
5.2.90.0030.05311.72
5.2.80.0030.05711.72
5.2.70.0070.05711.72
5.2.60.0030.04711.72
5.2.50.0030.04711.72
5.2.40.0000.06011.72
5.2.30.0000.06311.72
5.2.20.0070.05711.72
5.2.10.0030.06311.72
5.2.00.0000.06011.72
5.1.60.0100.04311.72
5.1.50.0000.05011.72
5.1.40.0170.04711.72
5.1.30.0030.04011.72
5.1.20.0030.05711.72
5.1.10.0070.04311.72
5.1.00.0000.05011.72
5.0.50.0100.03711.72
5.0.40.0000.04311.72
5.0.30.0000.06711.72
5.0.20.0030.04011.72
5.0.10.0000.04311.72
5.0.00.0000.06711.72
4.4.90.0030.03011.72
4.4.80.0030.02011.72
4.4.70.0000.03711.72
4.4.60.0030.03311.72
4.4.50.0000.02711.72
4.4.40.0000.05711.72
4.4.30.0000.03311.72
4.4.20.0030.03311.72
4.4.10.0030.03311.72
4.4.00.0030.05311.72
4.3.110.0000.03711.72
4.3.100.0000.03311.72
4.3.90.0000.03711.72
4.3.80.0000.05011.72
4.3.70.0000.03711.72
4.3.60.0000.03311.72
4.3.50.0070.02711.72
4.3.40.0000.05311.72
4.3.30.0030.03311.72
4.3.20.0000.03311.72
4.3.10.0030.03311.72
4.3.00.0000.03711.72

preferences:
43.21 ms | 401 KiB | 5 Q