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->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.0110.00718.69
8.3.30.0110.00419.10
8.3.20.0070.00020.04
8.3.10.0080.00021.91
8.3.00.0060.00322.43
8.2.170.0040.01222.96
8.2.160.0100.00720.77
8.2.150.0050.00324.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0060.00317.50
8.2.110.0060.00321.93
8.2.100.0090.00319.43
8.2.90.0000.00819.18
8.2.80.0000.00819.63
8.2.70.0050.00317.63
8.2.60.0080.00417.80
8.2.50.0040.00418.07
8.2.40.0000.00818.16
8.2.30.0070.00017.98
8.2.20.0050.00317.82
8.2.10.0030.00517.72
8.2.00.0000.00717.72
8.1.270.0040.00422.14
8.1.260.0080.00026.35
8.1.250.0030.00528.09
8.1.240.0050.00523.92
8.1.230.0000.01018.89
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0070.00317.35
8.1.190.0060.00317.53
8.1.180.0040.00418.10
8.1.170.0000.00818.55
8.1.160.0060.00321.96
8.1.150.0040.00418.64
8.1.140.0030.00617.47
8.1.130.0070.00017.95
8.1.120.0030.00517.41
8.1.110.0050.00317.45
8.1.100.0000.00717.47
8.1.90.0030.00517.44
8.1.80.0020.00517.50
8.1.70.0060.00317.37
8.1.60.0040.00417.63
8.1.50.0000.00817.44
8.1.40.0000.00817.60
8.1.30.0000.00817.70
8.1.20.0030.00517.54
8.1.10.0000.00817.53
8.1.00.0000.00717.55
8.0.300.0070.00018.77
8.0.290.0000.00717.04
8.0.280.0030.00318.59
8.0.270.0000.00717.25
8.0.260.0000.00716.93
8.0.250.0030.00317.12
8.0.240.0000.01016.99
8.0.230.0070.00017.10
8.0.220.0070.00016.90
8.0.210.0030.00516.97
8.0.200.0030.00517.02
8.0.190.0040.00416.98
8.0.180.0000.00816.90
8.0.170.0050.00316.92
8.0.160.0000.00817.03
8.0.150.0000.00716.98
8.0.140.0070.00016.94
8.0.130.0030.00313.48
8.0.120.0080.00016.92
8.0.110.0040.00416.91
8.0.100.0040.00416.97
8.0.90.0070.00016.95
8.0.80.0090.00617.02
8.0.70.0040.00417.02
8.0.60.0040.00416.96
8.0.50.0030.00516.79
8.0.30.0110.01017.01
8.0.20.0090.01117.46
8.0.10.0030.00517.07
8.0.00.0070.01116.95
7.4.330.0050.00015.06
7.4.320.0030.00316.61
7.4.300.0000.00616.63
7.4.290.0030.00316.56
7.4.280.0080.00016.63
7.4.270.0030.00316.53
7.4.260.0070.00016.45
7.4.250.0000.00816.61
7.4.240.0010.00616.55
7.4.230.0070.00016.62
7.4.220.0070.01016.58
7.4.210.0110.00816.60
7.4.200.0030.00316.63
7.4.190.0080.00016.73
7.4.160.0140.00716.49
7.4.150.0070.01717.40
7.4.140.0120.00917.86
7.4.130.0090.01216.56
7.4.120.0110.00716.58
7.4.110.0030.01316.71
7.4.100.0090.00916.60
7.4.90.0100.00616.56
7.4.80.0150.00919.39
7.4.70.0080.01116.41
7.4.60.0110.00916.55
7.4.50.0000.00716.27
7.4.40.0000.01622.77
7.4.30.0080.00816.64
7.4.00.0060.00814.88
7.3.330.0070.00013.41
7.3.320.0030.00313.32
7.3.310.0060.00316.49
7.3.300.0000.00716.32
7.3.290.0130.00016.45
7.3.280.0130.00416.43
7.3.270.0070.01017.40
7.3.260.0100.01316.39
7.3.250.0090.00916.35
7.3.240.0090.01516.31
7.3.230.0080.01216.48
7.3.210.0150.00416.50
7.3.200.0110.00619.39
7.3.190.0120.00616.54
7.3.180.0150.00616.57
7.3.170.0070.01016.45
7.3.160.0120.00416.48
7.3.120.0070.01014.93
7.3.00.0000.01216.70
7.2.330.0040.01416.42
7.2.320.0100.01116.88
7.2.310.0120.00616.70
7.2.300.0030.01416.82
7.2.290.0030.01316.90
7.2.130.0080.00616.70
7.2.120.0080.00816.62
7.2.110.0070.00717.05
7.2.100.0000.01717.10
7.2.90.0120.00016.66
7.2.80.0060.00617.00
7.2.70.0070.00716.95
7.2.60.0070.01016.89
7.2.50.0040.00816.96
7.2.40.0030.01016.97
7.2.30.0030.01017.05
7.2.20.0100.00617.11
7.2.10.0160.00316.98
7.2.00.0080.00918.14
7.1.250.0030.01215.92
7.1.240.0160.00015.84
7.1.230.0050.00315.98
7.1.220.0090.00615.42
7.1.210.0080.00315.96
7.1.200.0070.00715.86
7.1.190.0080.00415.68
7.1.180.0090.00615.60
7.1.170.0030.00615.94
7.1.160.0100.00316.01
7.1.150.0040.01115.91
7.1.140.0020.00915.79
7.1.130.0070.01015.82
7.1.120.0030.00615.74
7.1.110.0070.00715.77
7.1.100.0050.00916.90
7.1.90.0030.00715.99
7.1.80.0000.01015.90
7.1.70.0040.00516.50
7.1.60.0080.00317.89
7.1.50.0040.00616.45
7.1.40.0030.00615.79
7.1.30.0040.00715.95
7.1.20.0090.00315.71
7.1.10.0030.01015.74
7.1.00.0040.04219.12
7.0.330.0090.00615.37
7.0.320.0040.00415.25
7.0.310.0040.00815.27
7.0.300.0000.00715.60
7.0.290.0060.00315.43
7.0.280.0060.00615.54
7.0.270.0100.00315.63
7.0.260.0040.00415.27
7.0.250.0050.00315.64
7.0.240.0090.00915.50
7.0.230.0030.00615.47
7.0.220.0050.00515.47
7.0.210.0000.01115.47
7.0.200.0060.00515.98
7.0.190.0040.00715.64
7.0.180.0050.00515.51
7.0.170.0070.00715.52
7.0.160.0110.00015.50
7.0.150.0120.00315.55
7.0.140.0020.04218.67
7.0.130.0070.00415.19
7.0.120.0030.01015.45
7.0.110.0000.01015.55
7.0.100.0050.04417.69
7.0.90.0070.04017.79
7.0.80.0080.04417.58
7.0.70.0030.03917.83
7.0.60.0080.03917.66
7.0.50.0250.04718.03
7.0.40.0100.04216.72
7.0.30.0030.03916.72
7.0.20.0050.04516.81
7.0.10.0080.04016.81
7.0.00.0050.04416.78
5.6.380.0050.00514.24
5.6.370.0070.00714.19
5.6.360.0070.00714.61
5.6.350.0070.00714.61
5.6.340.0060.00614.38
5.6.330.0060.00614.46
5.6.320.0070.00714.20
5.6.310.0030.00814.59
5.6.300.0100.00314.63
5.6.290.0030.00914.13
5.6.280.0050.00314.61
5.6.270.0000.00814.25
5.6.260.0120.00014.28
5.6.250.0030.04617.61
5.6.240.0080.02517.56
5.6.230.0150.02717.55
5.6.220.0080.04117.54
5.6.210.0030.04917.51
5.6.200.0070.04617.67
5.6.190.0070.03617.74
5.6.180.0030.04517.64
5.6.170.0090.04117.62
5.6.160.0030.04817.61
5.6.150.0080.04217.76
5.6.140.0070.04917.80
5.6.130.0080.03017.73
5.6.120.0050.03717.70
5.6.110.0110.03717.72
5.6.100.0110.04117.62
5.6.90.0070.02817.64
5.6.80.0100.03517.40
5.6.70.0050.04517.24
5.6.60.0070.04017.40
5.6.50.0080.04017.44
5.6.40.0030.04717.40
5.6.30.0070.04217.37
5.6.20.0070.03517.27
5.6.10.0140.03317.41
5.6.00.0050.03917.48
5.5.380.0050.04215.90
5.5.370.0080.04015.79
5.5.360.0070.03915.77
5.5.350.0070.03815.82
5.5.340.0090.02515.95
5.5.330.0060.04115.92
5.5.320.0020.04915.93
5.5.310.0050.04215.98
5.5.300.0060.04015.97
5.5.290.0120.03316.03
5.5.280.0020.04716.13
5.5.270.0090.04116.12
5.5.260.0050.04016.07
5.5.250.0060.04315.83
5.5.240.0070.04015.69
5.5.230.0030.02615.65
5.5.220.0050.02515.74
5.5.210.0030.04415.72
5.5.200.0040.02915.57
5.5.190.0120.03715.77
5.5.180.0070.02615.79
5.5.170.0000.01011.03
5.5.160.0070.02315.44
5.5.150.0120.03415.66
5.5.140.0070.04215.67
5.5.130.0050.02815.56
5.5.120.0070.03315.67
5.5.110.0100.03215.76
5.5.100.0050.03915.71
5.5.90.0090.03515.55
5.5.80.0050.03615.63
5.5.70.0050.04015.71
5.5.60.0050.04015.50
5.5.50.0030.02915.71
5.5.40.0050.03715.54
5.5.30.0090.03815.55
5.5.20.0100.03515.52
5.5.10.0030.05515.65
5.5.00.0070.04215.60
5.4.450.0030.03615.39
5.4.440.0050.03715.24
5.4.430.0070.02015.08
5.4.420.0050.04215.13
5.4.410.0040.03915.11
5.4.400.0050.04214.94
5.4.390.0100.03515.01
5.4.380.0040.02514.89
5.4.370.0050.02614.87
5.4.360.0020.04415.09
5.4.350.0110.03315.17
5.4.340.0070.04015.03
5.4.330.0000.00611.07
5.4.320.0050.02315.14
5.4.310.0130.02315.00
5.4.300.0030.04114.89
5.4.290.0100.03515.17
5.4.280.0080.03814.96
5.4.270.0050.03415.08
5.4.260.0030.04314.92
5.4.250.0050.04014.90
5.4.240.0030.02814.97
5.4.230.0110.03514.95
5.4.220.0050.04014.89
5.4.210.0050.03714.97
5.4.200.0070.03515.12
5.4.190.0080.03615.16
5.4.180.0070.03815.02
5.4.170.0030.04115.07
5.4.160.0090.03014.92
5.4.150.0040.04014.87
5.4.140.0030.03713.76
5.4.130.0110.03213.73
5.4.120.0050.03813.52
5.4.110.0100.03913.81
5.4.100.0030.03813.80
5.4.90.0070.04013.76
5.4.80.0070.04013.74
5.4.70.0050.03813.79
5.4.60.0060.04113.71
5.4.50.0050.04013.71
5.4.40.0020.04013.76
5.4.30.0100.02513.66
5.4.20.0030.03713.82
5.4.10.0090.03513.70
5.4.00.0040.04613.42
5.3.290.0030.03712.68
5.3.280.0050.03912.63
5.3.270.0050.02212.70
5.3.260.0030.04112.49
5.3.250.0030.04212.68
5.3.240.0020.03612.57
5.3.230.0040.03512.57
5.3.220.0060.04012.55
5.3.210.0030.04012.58
5.3.200.0080.04012.51
5.3.190.0020.04112.43
5.3.180.0150.03312.49
5.3.170.0040.03812.54
5.3.160.0070.04012.68
5.3.150.0050.04012.50
5.3.140.0030.03912.46
5.3.130.0060.04112.59
5.3.120.0080.03712.62
5.3.110.0040.03312.57
5.3.100.0050.04112.33
5.3.90.0080.03812.24
5.3.80.0020.03012.26
5.3.70.0090.03512.27
5.3.60.0100.04012.42
5.3.50.0070.03912.26
5.3.40.0060.04012.30
5.3.30.0080.03512.28
5.3.20.0070.03712.21
5.3.10.0070.03012.14
5.3.00.0040.03112.03
5.2.170.0070.03310.46
5.2.160.0080.03010.62
5.2.150.0050.03510.49
5.2.140.0070.03010.64
5.2.130.0030.03310.57
5.2.120.0020.03510.59
5.2.110.0040.03510.59
5.2.100.0030.02810.57
5.2.90.0020.02810.58
5.2.80.0020.03110.57
5.2.70.0070.03010.57
5.2.60.0060.03110.49
5.2.50.0090.03010.46
5.2.40.0030.03510.56
5.2.30.0070.03010.46
5.2.20.0030.03510.47
5.2.10.0020.03510.46
5.2.00.0030.02510.46
5.1.60.0070.02510.46
5.1.50.0030.02810.46
5.1.40.0060.02410.46
5.1.30.0070.03010.46
5.1.20.0040.03010.46
5.1.10.0040.03010.46
5.1.00.0020.03010.46
5.0.50.0010.02110.46
5.0.40.0030.02410.46
5.0.30.0000.03710.46
5.0.20.0030.02510.46
5.0.10.0020.02310.46
5.0.00.0050.03410.46
4.4.90.0020.01010.46
4.4.80.0020.02010.46
4.4.70.0020.01810.46
4.4.60.0040.01610.46
4.4.50.0020.01810.46
4.4.40.0020.02810.46
4.4.30.0030.01910.46
4.4.20.0040.01710.46
4.4.10.0030.02010.46
4.4.00.0050.02810.46
4.3.110.0050.01810.46
4.3.100.0030.01810.46
4.3.90.0030.01710.46
4.3.80.0020.02810.46
4.3.70.0070.01310.46
4.3.60.0000.02010.46
4.3.50.0030.01710.46
4.3.40.0020.02710.46
4.3.30.0010.01810.46
4.3.20.0000.02010.46
4.3.10.0000.01910.46
4.3.00.0030.01810.46

preferences:
42.87 ms | 400 KiB | 5 Q