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.0100.01018.50
8.3.50.0100.01021.33
8.3.40.0110.00318.67
8.3.30.0110.00418.79
8.3.20.0080.00018.82
8.3.10.0030.00620.56
8.3.00.0000.00823.48
8.2.180.0120.00916.75
8.2.170.0100.01022.96
8.2.160.0110.00420.54
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00019.48
8.2.110.0060.00320.31
8.2.100.0060.00617.91
8.2.90.0080.00019.36
8.2.80.0050.01017.97
8.2.70.0000.00817.63
8.2.60.0030.00717.93
8.2.50.0060.00318.07
8.2.40.0040.00418.34
8.2.30.0000.00819.92
8.2.20.0040.00417.72
8.2.10.0080.00017.83
8.2.00.0040.00417.64
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0050.00526.35
8.1.250.0080.00028.09
8.1.240.0000.00922.64
8.1.230.0090.00320.98
8.1.220.0050.00318.77
8.1.210.0000.00818.87
8.1.200.0060.00717.35
8.1.190.0000.00817.52
8.1.180.0000.00718.10
8.1.170.0040.00418.65
8.1.160.0030.00618.91
8.1.150.0000.00718.70
8.1.140.0040.00417.38
8.1.130.0000.00717.85
8.1.120.0000.00717.40
8.1.110.0070.00017.37
8.1.100.0000.00817.37
8.1.90.0080.00017.47
8.1.80.0000.00817.42
8.1.70.0000.00717.41
8.1.60.0060.00317.62
8.1.50.0000.00817.51
8.1.40.0000.00717.45
8.1.30.0080.00017.59
8.1.20.0000.00817.64
8.1.10.0080.00017.64
8.1.00.0000.00817.54
8.0.300.0050.00319.94
8.0.290.0000.00717.18
8.0.280.0030.00318.38
8.0.270.0000.00717.16
8.0.260.0080.00016.86
8.0.250.0080.00016.88
8.0.240.0040.00416.96
8.0.230.0000.00716.93
8.0.220.0000.00716.95
8.0.210.0000.00716.93
8.0.200.0040.00416.84
8.0.190.0030.00616.89
8.0.180.0040.00416.89
8.0.170.0000.00816.85
8.0.160.0040.00416.96
8.0.150.0030.00716.91
8.0.140.0080.00416.89
8.0.130.0000.00513.38
8.0.120.0070.00016.86
8.0.110.0040.00416.91
8.0.100.0070.00016.75
8.0.90.0000.00816.96
8.0.80.0080.00716.91
8.0.70.0050.00316.79
8.0.60.0050.00216.79
8.0.50.0040.00416.95
8.0.30.0120.00717.09
8.0.20.0080.01017.40
8.0.10.0000.00716.99
8.0.00.0100.00816.91
7.4.330.0050.00014.76
7.4.320.0060.00316.65
7.4.300.0000.00616.67
7.4.290.0070.00016.61
7.4.280.0040.00416.44
7.4.270.0030.00316.39
7.4.260.0000.00513.18
7.4.250.0040.00416.54
7.4.240.0070.00016.52
7.4.230.0000.00716.73
7.4.220.0030.01316.63
7.4.210.0070.01016.64
7.4.200.0030.00516.43
7.4.190.0030.00316.64
7.4.160.0160.00716.59
7.4.150.0060.01217.40
7.4.140.0110.01017.86
7.4.130.0050.01316.63
7.4.120.0100.00816.57
7.4.110.0140.00716.52
7.4.100.0120.00616.34
7.4.90.0090.00916.48
7.4.80.0080.01019.04
7.4.70.0120.00616.34
7.4.60.0060.00916.37
7.4.50.0000.00916.54
7.4.40.0030.01322.27
7.4.30.0030.01616.51
7.4.10.0030.01614.90
7.4.00.0060.01014.89
7.3.330.0030.00313.38
7.3.320.0000.00513.20
7.3.310.0000.00716.37
7.3.300.0040.00416.35
7.3.290.0080.01216.39
7.3.280.0060.01116.36
7.3.270.0110.00717.40
7.3.260.0110.00918.24
7.3.250.0100.01216.37
7.3.240.0090.00916.54
7.3.230.0130.00416.55
7.3.210.0110.00716.32
7.3.200.0040.01419.39
7.3.190.0060.01816.39
7.3.180.0120.00616.48
7.3.170.0080.00816.55
7.3.160.0090.00716.36
7.3.130.0090.00414.86
7.3.120.0060.01114.86
7.3.110.0060.01314.93
7.3.100.0100.00614.75
7.3.90.0080.00714.75
7.3.80.0090.00614.95
7.3.70.0040.00814.88
7.3.60.0050.00814.81
7.3.50.0050.01114.63
7.3.40.0070.00614.73
7.3.30.0050.01014.93
7.3.20.0070.00616.74
7.3.10.0090.00516.67
7.3.00.0070.00816.71
7.2.330.0070.01116.84
7.2.320.0080.00816.72
7.2.310.0030.01616.88
7.2.300.0080.00816.71
7.2.290.0120.00416.46
7.2.260.0060.00615.29
7.2.250.0080.01115.21
7.2.240.0050.01215.15
7.2.230.0070.00715.20
7.2.220.0020.01314.96
7.2.210.0030.00915.15
7.2.200.0050.01015.14
7.2.190.0060.00515.08
7.2.180.0080.00815.02
7.2.170.0030.01115.15
7.2.160.0030.01315.11
7.2.150.0080.00617.07
7.2.140.0070.00917.00
7.2.130.0060.00817.02
7.2.120.0070.00516.90
7.2.110.0010.01216.94
7.2.100.0020.01117.02
7.2.90.0060.01317.00
7.2.80.0050.01016.77
7.2.70.0060.01016.99
7.2.60.0060.00817.01
7.2.50.0060.00916.76
7.2.40.0060.00916.98
7.2.30.0050.00616.90
7.2.20.0050.01016.99
7.2.10.0040.00816.89
7.2.00.0070.00417.77
7.1.330.0020.01215.82
7.1.320.0060.00915.69
7.1.310.0070.00515.85
7.1.300.0030.01115.86
7.1.290.0060.00715.78
7.1.280.0070.00715.73
7.1.270.0090.00615.82
7.1.260.0070.00715.78
7.1.250.0050.00715.79
7.1.240.0090.00215.56
7.1.230.0040.00915.72
7.1.220.0080.00615.67
7.1.210.0040.00915.70
7.1.200.0020.01015.79
7.1.190.0080.00315.82
7.1.180.0090.00415.73
7.1.170.0030.01215.74
7.1.160.0020.01115.55
7.1.150.0060.00615.70
7.1.140.0050.00715.60
7.1.130.0020.01015.90
7.1.120.0030.00815.50
7.1.110.0090.00515.90
7.1.100.0070.00616.58
7.1.90.0060.00815.82
7.1.80.0100.00515.78
7.1.70.0060.01016.29
7.1.60.0120.00517.03
7.1.50.0050.01116.18
7.1.40.0050.00715.62
7.1.30.0060.00515.73
7.1.20.0050.00715.72
7.1.10.0080.00915.80
7.1.00.0050.02318.00
7.0.330.0060.00815.46
7.0.320.0070.00715.54
7.0.310.0050.00815.46
7.0.300.0080.00515.35
7.0.290.0030.00615.43
7.0.280.0060.00415.58
7.0.270.0030.01215.40
7.0.260.0060.00515.15
7.0.250.0130.00015.50
7.0.240.0070.00815.41
7.0.230.0050.01015.65
7.0.220.0070.00715.43
7.0.210.0060.00815.36
7.0.200.0040.00715.87
7.0.190.0000.01415.41
7.0.180.0060.00715.50
7.0.170.0060.00615.42
7.0.160.0060.00615.56
7.0.150.0070.00715.47
7.0.140.0100.02617.70
7.0.130.0060.00515.47
7.0.120.0030.01015.42
7.0.110.0040.01015.36
7.0.100.0030.01115.31
7.0.90.0020.01015.28
7.0.80.0010.01115.40
7.0.70.0090.00415.31
7.0.60.0130.03116.97
7.0.50.0150.03017.04
7.0.40.0110.02815.62
7.0.30.0120.03515.55
7.0.20.0160.02815.72
7.0.10.0130.02815.71
7.0.00.0100.03115.77
5.6.400.0050.00914.60
5.6.390.0080.00514.54
5.6.380.0060.00714.41
5.6.370.0050.01014.27
5.6.360.0020.01514.38
5.6.350.0020.00814.32
5.6.340.0050.00614.55
5.6.330.0060.00614.57
5.6.320.0080.00814.33
5.6.310.0060.00614.65
5.6.300.0080.01014.56
5.6.290.0050.00814.35
5.6.280.0040.01214.44
5.6.270.0090.00414.37
5.6.260.0080.00714.57
5.6.250.0070.00714.35
5.6.240.0050.00914.67
5.6.230.0070.00514.65
5.6.220.0050.00914.47
5.6.210.0100.03116.48
5.6.200.0130.03316.73
5.6.190.0160.02416.74
5.6.180.0100.01716.60
5.6.170.0140.03016.64
5.6.160.0180.02216.71
5.6.150.0140.03316.58
5.6.140.0140.01616.70
5.6.130.0160.02416.71
5.6.120.0140.02716.61
5.6.110.0110.02616.63
5.6.100.0130.03016.64
5.6.90.0130.02716.56
5.6.80.0190.02516.28
5.6.70.0090.03016.42
5.6.60.0140.02916.40
5.6.50.0110.02516.44
5.6.40.0120.03016.39
5.6.30.0100.02816.27
5.6.20.0130.02616.47
5.6.10.0130.02616.40
5.6.00.0110.02616.46
5.5.380.0050.01014.37
5.5.370.0030.01014.27
5.5.360.0070.01014.34
5.5.350.0190.02616.36
5.5.340.0190.01816.57
5.5.330.0090.03016.46
5.5.320.0140.01516.43
5.5.310.0150.01816.58
5.5.300.0130.03116.65
5.5.290.0110.02116.54
5.5.280.0130.03116.67
5.5.270.0120.01816.53
5.5.260.0110.03516.51
5.5.250.0150.02616.55
5.5.240.0130.03016.21
5.5.230.0100.02816.34
5.5.220.0130.03016.14
5.5.210.0080.03316.35
5.5.200.0100.02216.41
5.5.190.0100.02016.25
5.5.180.0110.02916.28
5.5.170.0030.00814.37
5.5.160.0100.02116.38
5.5.150.0150.02216.36
5.5.140.0170.02516.15
5.5.130.0140.02916.32
5.5.120.0120.03216.31
5.5.110.0130.02816.18
5.5.100.0160.02816.18
5.5.90.0110.03316.23
5.5.80.0130.02616.21
5.5.70.0140.02716.16
5.5.60.0110.02816.26
5.5.50.0110.03116.23
5.5.40.0120.02216.22
5.5.30.0070.02816.31
5.5.20.0150.03116.20
5.5.10.0110.01816.35
5.5.00.0100.03316.38
5.4.450.0100.01814.04
5.4.440.0100.02913.84
5.4.430.0090.03213.99
5.4.420.0110.02613.86
5.4.410.0110.02813.77
5.4.400.0090.02513.79
5.4.390.0110.02613.72
5.4.380.0100.02813.81
5.4.370.0110.02613.74
5.4.360.0080.02313.84
5.4.350.0120.02713.72
5.4.340.0130.02213.73
5.4.330.0040.00611.26
5.4.320.0090.03013.80
5.4.310.0190.02213.74
5.4.300.0100.02913.86
5.4.290.0130.03013.82
5.4.280.0150.02513.70
5.4.270.0130.02513.92
5.4.260.0120.02013.81
5.4.250.0120.02413.69
5.4.240.0120.02913.89
5.4.230.0090.02813.90
5.4.220.0140.01913.81
5.4.210.0140.02713.67
5.4.200.0100.03113.90
5.4.190.0100.03013.88
5.4.180.0100.02613.74
5.4.170.0120.02513.79
5.4.160.0100.02813.90
5.4.150.0130.02213.69
5.4.140.0100.02612.92
5.4.130.0080.02912.88
5.4.120.0080.01813.01
5.4.110.0120.02212.98
5.4.100.0120.02013.01
5.4.90.0090.02012.85
5.4.80.0150.01312.96
5.4.70.0080.01512.87
5.4.60.0110.01312.79
5.4.50.0080.01712.89
5.4.40.0060.02412.80
5.4.30.0080.01712.89
5.4.20.0090.01912.97
5.4.10.0090.02812.94
5.4.00.0090.02712.74
5.3.290.0180.02312.19
5.3.280.0130.02412.21
5.3.270.0080.01912.21
5.3.260.0140.02512.17
5.3.250.0120.02512.19
5.3.240.0120.02012.22
5.3.230.0080.01912.21
5.3.220.0060.02312.13
5.3.210.0120.02812.20
5.3.200.0090.03012.19
5.3.190.0060.02312.16
5.3.180.0060.02212.16
5.3.170.0120.01012.19
5.3.160.0110.01712.18
5.3.150.0090.02412.12
5.3.140.0090.01912.19
5.3.130.0110.02812.19
5.3.120.0120.01912.20
5.3.110.0120.01312.18
5.3.100.0080.03011.98
5.3.90.0110.02411.98
5.3.80.0100.02712.02
5.3.70.0110.02312.00
5.3.60.0150.02411.93
5.3.50.0100.02711.98
5.3.40.0100.03111.96
5.3.30.0140.02711.90
5.3.20.0130.02811.91
5.3.10.0090.02111.90
5.3.00.0110.02411.81
5.2.170.0270.05711.21
5.2.160.0230.05711.16
5.2.150.0200.06011.07
5.2.140.0330.05311.14
5.2.130.0200.05310.99
5.2.120.0230.04711.02
5.2.110.0270.05011.13
5.2.100.0200.05311.23
5.2.90.0170.05010.98
5.2.80.0130.06711.09
5.2.70.0170.04311.22
5.2.60.0200.06011.06
5.2.50.0200.05311.14
5.2.40.0170.05711.10
5.2.30.0170.05710.84
5.2.20.0200.04011.03
5.2.10.0170.04710.94
5.2.00.0170.05010.79
5.1.60.0130.0539.99
5.1.50.0170.0479.89
5.1.40.0170.0379.99
5.1.30.0170.02710.34
5.1.20.0100.05710.43
5.1.10.0230.04710.13
5.1.00.0130.05710.17
5.0.50.0070.0478.81
5.0.40.0130.0378.81
5.0.30.0100.0608.81
5.0.20.0100.0378.81
5.0.10.0070.0438.81
5.0.00.0030.0638.81
4.4.90.0130.0178.81
4.4.80.0070.0378.81
4.4.70.0130.0278.81
4.4.60.0070.0338.81
4.4.50.0030.0408.81
4.4.40.0070.0408.81
4.4.30.0100.0338.81
4.4.20.0170.0178.81
4.4.10.0100.0338.81
4.4.00.0170.0438.81
4.3.110.0100.0208.81
4.3.100.0070.0278.81
4.3.90.0100.0278.81
4.3.80.0030.0438.81
4.3.70.0070.0378.81
4.3.60.0070.0338.81
4.3.50.0130.0308.81
4.3.40.0030.0508.81
4.3.30.0000.0378.81
4.3.20.0030.0338.81
4.3.10.0030.0378.81
4.3.00.0000.0238.81

preferences:
41.34 ms | 401 KiB | 5 Q