3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private $var = array(); public function __construct($array) { 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; } } $values = array(1,2,3); $it = new MyIterator($values); class MyCollection implements IteratorAggregate { private $items = array(); private $count = 0; // Required definition of interface IteratorAggregate public function getIterator() { return new MyIterator($this->items); } public function add($value) { $this->items[$this->count++] = $value; } } $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.0120.00318.68
8.3.50.0130.00722.16
8.3.40.0090.00918.96
8.3.30.0140.00419.17
8.3.20.0030.00520.25
8.3.10.0060.00321.92
8.3.00.0120.00622.43
8.2.180.0190.00316.73
8.2.170.0110.00722.96
8.2.160.0040.01120.95
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00419.38
8.2.110.0060.00322.18
8.2.100.0070.01017.91
8.2.90.0000.00819.30
8.2.80.0000.00817.97
8.2.70.0100.00017.75
8.2.60.0040.00417.93
8.2.50.0050.00318.07
8.2.40.0030.00618.22
8.2.30.0000.00718.14
8.2.20.0000.00817.80
8.2.10.0000.00817.77
8.2.00.0050.00317.66
8.1.280.0150.00425.92
8.1.270.0040.00423.96
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0050.00523.96
8.1.230.0040.00719.15
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0060.00317.25
8.1.190.0050.00317.55
8.1.180.0000.00818.10
8.1.170.0000.00918.39
8.1.160.0040.00421.93
8.1.150.0090.00018.66
8.1.140.0040.00417.43
8.1.130.0070.00017.82
8.1.120.0040.00417.48
8.1.110.0030.00617.39
8.1.100.0000.00717.48
8.1.90.0000.00817.36
8.1.80.0030.00417.38
8.1.70.0040.00417.36
8.1.60.0040.00417.59
8.1.50.0060.00317.46
8.1.40.0040.00417.46
8.1.30.0080.00017.59
8.1.20.0080.00017.56
8.1.10.0030.00617.60
8.1.00.0040.00417.48
8.0.300.0040.00418.77
8.0.290.0000.00717.18
8.0.280.0040.00418.37
8.0.270.0030.00317.26
8.0.260.0000.00616.83
8.0.250.0070.00016.98
8.0.240.0050.00316.98
8.0.230.0070.00016.93
8.0.220.0000.00716.95
8.0.210.0000.00716.83
8.0.200.0070.00017.01
8.0.190.0040.00416.98
8.0.180.0080.00016.97
8.0.170.0000.00816.89
8.0.160.0060.00316.98
8.0.150.0000.00716.89
8.0.140.0040.00416.77
8.0.130.0000.00513.37
8.0.120.0040.00416.89
8.0.110.0000.00716.79
8.0.100.0000.00716.77
8.0.90.0070.00016.82
8.0.80.0060.00916.96
8.0.70.0000.00816.78
8.0.60.0000.00816.78
8.0.50.0070.00016.88
8.0.30.0130.01017.15
8.0.20.0100.01017.40
8.0.10.0000.00817.04
8.0.00.0140.00316.85
7.4.330.0060.00015.16
7.4.320.0000.00616.64
7.4.300.0000.00616.45
7.4.290.0030.00316.46
7.4.280.0030.00316.61
7.4.270.0000.00716.59
7.4.260.0070.00016.47
7.4.250.0020.00516.59
7.4.240.0020.00616.55
7.4.230.0000.00716.61
7.4.220.0110.00716.68
7.4.210.0070.00816.55
7.4.200.0050.00316.26
7.4.190.0050.00316.42
7.4.160.0130.01016.52
7.4.150.0140.00317.40
7.4.140.0080.01317.86
7.4.130.0060.01516.48
7.4.120.0070.01016.57
7.4.110.0080.00916.61
7.4.100.0170.00616.38
7.4.90.0060.01116.29
7.4.80.0030.01516.42
7.4.70.0060.01016.66
7.4.60.0060.01216.47
7.4.50.0020.00516.33
7.4.40.0040.01122.77
7.4.30.0120.00616.68
7.4.00.0070.00715.01
7.3.330.0030.00313.20
7.3.320.0060.00013.23
7.3.310.0050.00316.47
7.3.300.0000.00716.39
7.3.290.0110.00316.34
7.3.280.0110.00716.39
7.3.270.0100.00717.40
7.3.260.0070.01116.63
7.3.250.0090.00816.62
7.3.240.0070.01116.44
7.3.230.0110.00616.42
7.3.210.0120.00816.57
7.3.200.0060.01519.39
7.3.190.0130.01016.66
7.3.180.0140.00516.69
7.3.170.0070.01416.47
7.3.160.0060.01116.32
7.3.120.0060.01214.73
7.3.10.0000.01416.72
7.3.00.0000.01216.73
7.2.330.0090.01316.71
7.2.320.0030.01716.53
7.2.310.0070.01316.55
7.2.300.0080.00816.82
7.2.290.0120.01216.77
7.2.130.0030.00716.89
7.2.120.0030.01017.03
7.2.110.0040.01216.84
7.2.100.0080.00417.02
7.2.90.0040.01117.05
7.2.80.0000.01216.84
7.2.70.0030.00916.98
7.2.60.0070.00717.07
7.2.50.0080.00916.88
7.2.40.0030.01316.74
7.2.30.0060.00616.81
7.2.20.0100.00316.67
7.2.10.0060.00916.98
7.2.00.0030.00716.77
7.1.250.0030.00715.84
7.1.200.0080.00416.03
7.1.70.0070.00316.98
7.1.60.0180.00719.82
7.1.50.0070.00316.96
7.1.00.0000.08022.48
7.0.200.0000.01116.88
7.0.140.0100.06322.16
7.0.60.0070.07720.05
7.0.50.0030.04317.80
7.0.40.0100.08720.02
7.0.30.0530.03720.12
7.0.20.0230.05320.24
7.0.10.0200.07320.05
7.0.00.0070.05720.34
5.6.280.0070.07021.12
5.6.210.0070.03720.74
5.6.200.0070.03718.19
5.6.190.0030.04320.50
5.6.180.3600.03720.43
5.6.170.0200.05320.57
5.6.160.0030.04720.55
5.6.150.0070.06718.14
5.6.140.0000.05718.16
5.6.130.0200.03318.21
5.6.120.0030.08721.00
5.6.110.0100.04020.97
5.6.100.0200.06320.97
5.6.90.0070.08320.89
5.6.80.0070.05720.41
5.6.70.3630.04320.50
5.5.350.0070.08020.51
5.5.340.0130.07317.98
5.5.330.0070.05320.43
5.5.320.0300.07320.47
5.5.310.0130.05020.34
5.5.300.0070.08317.95
5.5.290.0030.05017.94
5.5.280.0070.04320.96
5.5.270.0000.06020.98
5.5.260.0070.04720.99
5.5.250.0070.06320.81
5.5.240.0070.08320.30
5.4.450.0670.07019.51
5.4.440.0700.06719.55
5.4.430.0100.05719.53
5.4.420.0170.05019.58
5.4.410.0070.06019.02
5.4.400.0870.05318.77
5.4.390.0870.05318.79
5.4.380.0130.05318.85
5.4.370.0070.04718.68
5.4.360.0070.03718.62
5.4.350.0080.03812.03
5.4.340.0070.03712.02
5.4.320.0010.04012.52
5.4.310.0070.04212.51
5.4.300.0030.04012.52
5.4.290.0080.04112.51
5.4.280.0040.04012.41
5.4.270.0050.04212.41
5.4.260.0040.03912.41
5.4.250.0100.04112.41
5.4.240.0060.03812.41
5.4.230.0070.04512.40
5.4.220.0070.03412.40
5.4.210.0090.03712.40
5.4.200.0040.04112.40
5.4.190.0190.04712.40
5.4.180.0130.05012.39
5.4.170.0170.04612.41
5.4.160.0170.04512.40
5.4.150.0200.04712.39
5.4.140.0230.05212.08
5.4.130.0170.05312.07
5.4.120.0230.05412.03
5.4.110.0190.04512.02
5.4.100.0170.05412.02
5.4.90.0300.06612.02
5.4.80.0230.05412.02
5.4.70.0170.04512.02
5.4.60.0280.04012.02
5.4.50.0220.04312.02
5.4.40.0180.04312.01
5.4.30.0170.04412.00
5.4.20.0150.04812.00
5.4.10.0170.04312.00
5.4.00.0200.03911.49
5.3.290.0040.04212.80
5.3.280.0070.03612.70
5.3.270.0190.04812.72
5.3.260.0230.04712.72
5.3.250.0200.04412.72
5.3.240.0220.04212.72
5.3.230.0240.05112.71
5.3.220.0210.04312.68
5.3.210.0190.04512.68
5.3.200.0160.04912.68
5.3.190.0180.04612.68
5.3.180.0170.04412.67
5.3.170.0180.04412.67
5.3.160.0260.03912.67
5.3.150.0170.04712.67
5.3.140.0230.05212.66
5.3.130.0210.04212.66
5.3.120.0190.05012.66
5.3.110.0210.04412.66
5.3.100.0420.08012.14
5.3.90.0130.04912.12
5.3.80.0180.04312.11
5.3.70.0210.04312.11
5.3.60.0120.04912.09
5.3.50.0160.04912.05
5.3.40.0150.04612.05
5.3.30.0150.04412.01
5.3.20.0200.03911.79
5.3.10.0190.03911.75
5.3.00.0150.04211.73
5.2.170.0140.0349.24
5.2.160.0090.0389.23
5.2.150.0150.0349.24
5.2.140.0180.0319.24
5.2.130.0130.0349.20
5.2.120.0160.0319.20
5.2.110.0110.0379.20
5.2.100.0170.0309.20
5.2.90.0120.0359.20
5.2.80.0120.0369.19
5.2.70.0140.0339.19
5.2.60.0130.0349.14
5.2.50.0100.0379.11
5.2.40.0170.0319.09
5.2.30.0150.0329.07
5.2.20.0160.0329.07
5.2.10.0100.0388.97
5.2.00.0110.0358.82
5.1.60.0100.0308.11
5.1.50.0130.0298.11
5.1.40.0120.0298.09
5.1.30.0190.0248.44
5.1.20.0160.0278.46
5.1.10.0120.0318.18
5.1.00.0140.0288.18
5.0.50.0120.0236.67
5.0.40.0060.0276.53
5.0.30.0060.0396.35
5.0.20.0090.0236.32
5.0.10.0110.0216.29
5.0.00.0110.0636.28
4.4.90.0050.0214.78
4.4.80.0090.0164.75
4.4.70.0090.0174.75
4.4.60.0070.0194.75
4.4.50.0070.0184.77
4.4.40.0070.0294.71
4.4.30.0080.0184.76
4.4.20.0090.0164.85
4.4.10.0060.0194.85
4.4.00.0040.0314.76
4.3.110.0070.0184.66
4.3.100.0070.0174.67
4.3.90.0080.0164.64
4.3.80.0080.0274.59
4.3.70.0060.0194.63
4.3.60.0040.0214.63
4.3.50.0050.0214.63
4.3.40.0100.0254.54
4.3.30.0060.0173.29
4.3.20.0070.0173.29
4.3.10.0060.0193.25
4.3.00.0000.0237.09

preferences:
47.65 ms | 401 KiB | 5 Q