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) { 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.40.0080.00818.70
8.3.30.0130.00718.54
8.3.20.0050.00318.59
8.3.10.0100.00018.55
8.3.00.0000.00819.26
8.2.170.0110.00322.96
8.2.160.0160.00018.96
8.2.150.0050.00324.18
8.2.140.0130.00324.66
8.2.130.0000.00726.16
8.2.120.0070.00019.66
8.2.110.0110.00021.00
8.2.100.0080.00417.91
8.2.90.0090.00018.03
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0090.00018.04
8.2.50.0040.00417.79
8.2.40.0040.00419.30
8.2.30.0060.00317.60
8.2.20.0050.00517.60
8.2.10.0000.00717.66
8.2.00.0050.00317.79
8.1.270.0060.00323.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00420.59
8.1.230.0000.01022.18
8.1.220.0040.00417.74
8.1.210.0030.00618.82
8.1.200.0100.00017.35
8.1.190.0030.00517.22
8.1.180.0050.00318.10
8.1.170.0080.00017.62
8.1.160.0030.00619.09
8.1.150.0070.00018.55
8.1.140.0050.00217.54
8.1.130.0000.00719.22
8.1.120.0070.00017.50
8.1.110.0050.00317.43
8.1.100.0000.00817.54
8.1.90.0000.00817.39
8.1.80.0040.00417.56
8.1.70.0040.00417.45
8.1.60.0030.00517.62
8.1.50.0000.00817.59
8.1.40.0050.00217.47
8.1.30.0030.00717.66
8.1.20.0040.00817.56
8.1.10.0000.00717.58
8.1.00.0000.00717.42
8.0.300.0000.00720.03
8.0.290.0110.00016.63
8.0.280.0030.00318.61
8.0.270.0000.00717.20
8.0.260.0050.00316.93
8.0.250.0030.00617.04
8.0.240.0000.00716.96
8.0.230.0040.00417.05
8.0.220.0050.00217.01
8.0.210.0070.00017.03
8.0.200.0060.00316.92
8.0.190.0050.00317.02
8.0.180.0030.00616.98
8.0.170.0040.00417.05
8.0.160.0000.01116.95
8.0.150.0040.00416.84
8.0.140.0060.00316.96
8.0.130.0000.00613.43
8.0.120.0030.00516.86
8.0.110.0040.00416.86
8.0.100.0070.00017.04
8.0.90.0000.00716.92
8.0.80.0070.01016.93
8.0.70.0040.00416.81
8.0.60.0050.00317.06
8.0.50.0000.00816.90
8.0.30.0040.01417.18
8.0.20.0060.01317.36
8.0.10.0040.00417.00
8.0.00.0100.00817.02
7.4.330.0000.00713.05
7.4.320.0040.00416.48
7.4.300.0040.00416.57
7.4.290.0070.00016.64
7.4.280.0080.00016.59
7.4.270.0000.00616.61
7.4.260.0050.00013.30
7.4.250.0080.00016.63
7.4.240.0030.00316.69
7.4.230.0000.00716.52
7.4.220.0100.01016.63
7.4.210.0070.01316.50
7.4.200.0050.00316.73
7.4.190.0000.00916.64
7.4.160.0130.00316.45
7.4.150.0090.00916.52
7.4.140.0070.01817.86
7.4.130.0130.00716.68
7.4.120.0090.01216.44
7.4.110.0120.00616.46
7.4.100.0040.01316.63
7.4.90.0050.01116.55
7.4.80.0080.00819.39
7.4.70.0090.00916.53
7.4.60.0090.00916.48
7.4.50.0030.00316.38
7.4.40.0000.01216.44
7.4.30.0110.00616.64
7.4.10.0060.01214.91
7.4.00.0090.00515.00
7.3.330.0000.00613.43
7.3.320.0000.00513.40
7.3.310.0020.00516.33
7.3.300.0030.00316.48
7.3.290.0080.01016.43
7.3.280.0060.00916.38
7.3.270.0100.00616.42
7.3.260.0100.00716.65
7.3.240.0060.01516.50
7.3.230.0110.01116.44
7.3.210.0170.00016.35
7.3.200.0080.00816.42
7.3.190.0060.00916.52
7.3.180.0130.00316.70
7.3.170.0090.00616.48
7.3.160.0140.00316.61
7.3.130.0040.01514.95
7.3.120.0070.00914.93
7.3.110.0060.01214.66
7.3.100.0110.00314.90
7.3.90.0030.01414.81
7.3.80.0120.00314.83
7.3.70.0060.00614.72
7.3.60.0060.00914.95
7.3.50.0030.00915.08
7.3.40.0110.00414.76
7.3.30.0140.00314.84
7.3.20.0040.01116.76
7.3.10.0100.00316.69
7.3.00.0070.00716.69
7.2.330.0190.00616.80
7.2.320.0090.01216.61
7.2.310.0090.00916.86
7.2.300.0100.00716.76
7.2.290.0150.00316.57
7.2.260.0110.00415.36
7.2.250.0120.00314.81
7.2.240.0030.01314.75
7.2.230.0090.00614.99
7.2.220.0030.00614.97
7.2.210.0070.00715.22
7.2.200.0100.00715.14
7.2.190.0000.01215.30
7.2.180.0030.01315.09
7.2.170.0060.01015.19
7.2.160.0060.00615.09
7.2.150.0070.00716.96
7.2.140.0000.01416.94
7.2.130.0070.01016.89
7.2.120.0000.01717.03
7.2.110.0040.00817.06
7.2.100.0030.00916.77
7.2.90.0030.01417.06
7.2.80.0040.00717.10
7.2.70.0040.01417.07
7.2.60.0030.00616.78
7.2.50.0060.00617.12
7.2.40.0030.01317.09
7.2.30.0090.00617.16
7.2.20.0000.01216.91
7.2.10.0030.01317.10
7.2.00.0050.00718.13
7.1.330.0000.01415.72
7.1.320.0060.00615.98
7.1.310.0030.00715.70
7.1.300.0100.00315.86
7.1.290.0030.01315.84
7.1.280.0070.01015.95
7.1.270.0000.01315.54
7.1.260.0060.01015.77
7.1.250.0030.00615.79
7.1.240.0040.01115.85
7.1.230.0000.01516.01
7.1.220.0040.00415.78
7.1.210.0080.00815.90
7.1.200.0060.00615.74
7.1.190.0110.00415.94
7.1.180.0120.00015.82
7.1.170.0070.00715.82
7.1.160.0050.00515.54
7.1.150.0070.00715.89
7.1.140.0070.00715.76
7.1.130.0070.00715.82
7.1.120.0090.00615.78
7.1.110.0030.00915.82
7.1.100.0060.00316.99
7.1.90.0070.00415.87
7.1.80.0040.01115.49
7.1.70.0070.00816.56
7.1.60.0080.01217.54
7.1.50.0070.00916.31
7.1.40.0000.01315.78
7.1.30.0070.00715.70
7.1.20.0030.01215.77
7.1.10.0090.00015.45
7.1.00.0040.02019.00
7.0.330.0040.00815.11
7.0.320.0030.00715.48
7.0.310.0040.00715.20
7.0.300.0070.01015.50
7.0.290.0060.00615.43
7.0.280.0100.00315.12
7.0.270.0030.01015.55
7.0.260.0030.00915.38
7.0.250.0030.01215.49
7.0.240.0090.00615.33
7.0.230.0000.01215.55
7.0.220.0070.00715.49
7.0.210.0070.00715.47
7.0.200.0040.00615.97
7.0.190.0060.00615.48
7.0.180.0030.00915.55
7.0.170.0000.01115.52
7.0.160.0040.01115.38
7.0.150.0000.01515.40
7.0.140.0060.03818.72
7.0.130.0030.00715.18
7.0.120.0050.02518.73
7.0.110.0070.00715.34
7.0.100.0040.00715.54
7.0.90.0070.00715.23
7.0.80.0030.01015.43
7.0.70.0030.01315.48
7.0.60.0050.04317.73
7.0.50.0090.04516.67
7.0.40.0050.04916.75
7.0.30.0110.03916.80
7.0.20.0120.03416.90
7.0.10.0070.02516.78
7.0.00.0070.04916.80
5.6.400.0090.00614.72
5.6.390.0070.01014.56
5.6.380.0000.01314.00
5.6.370.0000.01314.36
5.6.360.0080.00414.35
5.6.350.0030.01314.04
5.6.340.0030.01214.04
5.6.330.0000.01114.34
5.6.320.0040.01114.22
5.6.310.0000.00914.24
5.6.300.0000.01214.47
5.6.290.0030.01014.48
5.6.280.0080.03217.68
5.6.270.0040.01114.13
5.6.260.0090.00614.65
5.6.250.0060.00614.52
5.6.240.0030.01314.32
5.6.230.0060.00614.03
5.6.220.0040.00814.27
5.6.210.0120.03317.57
5.6.200.0110.04516.28
5.6.190.0050.04517.38
5.6.180.0130.02817.40
5.6.170.0130.03117.49
5.6.160.0080.02417.54
5.6.150.0030.02716.13
5.6.140.0030.02516.34
5.6.130.0030.02916.32
5.6.120.0080.04117.79
5.6.110.0080.04517.71
5.6.100.0030.04317.62
5.6.90.0050.03517.61
5.6.80.0100.02917.53
5.6.70.2300.02217.51
5.6.60.0110.00414.59
5.6.50.0000.01414.35
5.6.40.0070.00714.04
5.6.30.0030.00914.29
5.6.20.0060.00614.14
5.6.10.0080.00814.49
5.6.00.0030.01314.27
5.5.380.0000.01414.11
5.5.370.0060.00614.17
5.5.360.0000.01514.14
5.5.350.0090.04317.32
5.5.340.0050.02616.01
5.5.330.0050.04417.36
5.5.320.0180.04217.31
5.5.310.0140.03617.41
5.5.300.0030.04616.18
5.5.290.0050.04816.18
5.5.280.0040.02917.56
5.5.270.0020.04017.62
5.5.260.0070.02317.47
5.5.250.0090.04517.41
5.5.240.0050.02717.33
5.5.230.0070.00714.49
5.5.220.0000.01414.35
5.5.210.0030.00614.03
5.5.200.0060.00914.39
5.5.190.0030.00914.12
5.5.180.0050.00313.86
5.5.170.0060.00614.18
5.5.160.0030.00614.07
5.5.150.0000.01214.35
5.5.140.0090.00614.21
5.5.130.0040.01114.19
5.5.120.0090.00914.45
5.5.110.0000.01414.08
5.5.100.0000.01114.07
5.5.90.0000.01314.24
5.5.80.0070.00714.53
5.5.70.0080.00813.91
5.5.60.0070.00713.96
5.5.50.0030.01014.15
5.5.40.0060.00614.27
5.5.30.0040.01114.02
5.5.20.0000.01714.21
5.5.10.0060.00914.06
5.5.00.0070.01013.82
5.4.450.0080.01915.19
5.4.440.0070.01915.31
5.4.430.0030.02615.23
5.4.420.0000.02715.27
5.4.410.0050.01815.02
5.4.400.0040.02215.19
5.4.390.0050.02115.07
5.4.380.0010.02315.06
5.4.370.0050.01914.99
5.4.360.0020.02514.96
5.4.350.0050.02015.16
5.4.340.0000.02614.98
5.4.330.0080.00311.16
5.4.320.0030.02314.87
5.4.310.0020.02114.99
5.4.300.0060.03115.00
5.4.290.0050.02314.96
5.4.280.0020.02314.97
5.4.270.0050.04314.97
5.4.260.0100.01714.99
5.4.250.0060.02614.83
5.4.240.0110.03515.19
5.4.230.0060.03214.92
5.4.220.0070.02015.02
5.4.210.0070.03314.89
5.4.200.0100.03715.14
5.4.190.0070.02414.85
5.4.180.0020.04515.22
5.4.170.0050.02714.98
5.4.160.0000.04815.00
5.4.150.0070.04014.96
5.4.140.0110.03313.77
5.4.130.0020.03113.81
5.4.120.0100.03313.62
5.4.110.0070.03713.71
5.4.100.0030.03013.63
5.4.90.0060.01813.71
5.4.80.0020.02313.81
5.4.70.0090.03213.78
5.4.60.0090.03513.68
5.4.50.0060.03513.69
5.4.40.0030.03913.93
5.4.30.0020.02913.79
5.4.20.0080.03513.61
5.4.10.0050.02813.62
5.4.00.0080.02613.44
5.3.290.0020.03312.72
5.3.280.0020.02512.60
5.3.270.0060.03712.46
5.3.260.0030.04012.66
5.3.250.0070.04112.66
5.3.240.0060.02312.54
5.3.230.0030.03612.62
5.3.220.0070.02212.54
5.3.210.0030.04312.63
5.3.200.0000.02612.58
5.3.190.0070.02712.59
5.3.180.0030.03012.52
5.3.170.0050.04112.78
5.3.160.0050.03912.54
5.3.150.0040.04012.66
5.3.140.0060.03112.58
5.3.130.0050.04412.61
5.3.120.0030.03312.52
5.3.110.0050.04012.61
5.3.100.0080.03312.43
5.3.90.0070.03912.39
5.3.80.0090.03212.31
5.3.70.0030.02312.26
5.3.60.0070.03712.33
5.3.50.0060.03112.25
5.3.40.0080.03912.25
5.3.30.0050.04112.30
5.3.20.0030.02312.22
5.3.10.0020.03012.09
5.3.00.0000.02911.88
5.2.170.0070.04711.08
5.2.160.0130.04011.19
5.2.150.0070.05711.24
5.2.140.0030.05711.21
5.2.130.0070.05711.13
5.2.120.0030.05711.27
5.2.110.0070.06011.11
5.2.100.0070.06311.13
5.2.90.0070.05711.08
5.2.80.0070.06011.00
5.2.70.0070.04311.18
5.2.60.0070.02711.07
5.2.50.0070.06311.07
5.2.40.0100.05310.93
5.2.30.0070.06010.93
5.2.20.0100.06011.05
5.2.10.0070.04010.91
5.2.00.0100.05710.66
5.1.60.0070.05010.06
5.1.50.0100.04310.07
5.1.40.0030.04310.15
5.1.30.0070.05310.35
5.1.20.0030.05710.32
5.1.10.0100.04010.09
5.1.00.0030.03010.13
5.0.50.0030.0238.71
5.0.40.0000.0278.48
5.0.30.0070.0608.24
5.0.20.0030.0238.28
5.0.10.0030.0408.13
5.0.00.0070.0438.11
4.4.90.0000.0277.80
4.4.80.0030.0137.80
4.4.70.0070.0277.80
4.4.60.0000.0237.80
4.4.50.0000.0277.80
4.4.40.0000.0437.80
4.4.30.0030.0337.80
4.4.20.0030.0337.80
4.4.10.0030.0177.80
4.4.00.0030.0437.80
4.3.110.0030.0377.80
4.3.100.0000.0207.80
4.3.90.0070.0307.80
4.3.80.0000.0577.80
4.3.70.0000.0307.80
4.3.60.0170.0207.80
4.3.50.0000.0377.80
4.3.40.0000.0477.80
4.3.30.0070.0307.80
4.3.20.0030.0207.80
4.3.10.0000.0337.80
4.3.00.0030.0277.80

preferences:
42.94 ms | 400 KiB | 5 Q