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 $var = array(); private $count = 0; public function __construct($array) { 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->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.0040.01118.68
8.3.50.0140.00522.04
8.3.40.0150.00018.73
8.3.30.0100.00719.09
8.3.20.0030.00620.31
8.3.10.0000.00823.48
8.3.00.0080.00022.37
8.2.180.0150.00416.63
8.2.170.0070.00722.96
8.2.160.0060.00922.02
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0060.00319.38
8.2.110.0080.00022.21
8.2.100.0060.00617.72
8.2.90.0040.00419.11
8.2.80.0040.00418.05
8.2.70.0080.00017.62
8.2.60.0080.00017.91
8.2.50.0030.00618.07
8.2.40.0040.00718.09
8.2.30.0030.00618.09
8.2.20.0000.00817.68
8.2.10.0070.00017.85
8.2.00.0040.00717.84
8.1.280.0150.00425.92
8.1.270.0040.00423.97
8.1.260.0080.00026.35
8.1.250.0050.00228.09
8.1.240.0040.00423.80
8.1.230.0030.00819.15
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0030.00517.30
8.1.180.0060.00318.10
8.1.170.0000.00818.64
8.1.160.0000.00722.00
8.1.150.0070.00018.72
8.1.140.0030.00617.41
8.1.130.0030.00517.46
8.1.120.0030.00317.49
8.1.110.0000.00717.46
8.1.100.0000.00717.43
8.1.90.0000.00717.52
8.1.80.0000.00717.37
8.1.70.0040.00417.45
8.1.60.0050.00317.55
8.1.50.0040.00417.55
8.1.40.0020.00517.61
8.1.30.0040.00417.64
8.1.20.0040.00417.59
8.1.10.0000.00817.64
8.1.00.0040.00417.58
8.0.300.0000.00718.77
8.0.290.0070.00017.18
8.0.280.0030.00318.53
8.0.270.0040.00417.30
8.0.260.0070.00016.98
8.0.250.0030.00317.00
8.0.240.0000.00717.06
8.0.230.0050.00316.95
8.0.220.0070.00017.01
8.0.210.0070.00017.00
8.0.200.0030.00317.02
8.0.190.0000.00716.95
8.0.180.0040.00417.08
8.0.170.0030.00516.85
8.0.160.0040.00416.99
8.0.150.0040.00416.98
8.0.140.0050.00216.97
8.0.130.0040.00413.40
8.0.120.0040.00417.02
8.0.110.0000.00717.01
8.0.100.0000.00716.99
8.0.90.0000.00716.87
8.0.80.0120.00317.03
8.0.70.0000.00716.87
8.0.60.0020.00516.93
8.0.50.0020.00516.95
8.0.30.0090.01017.39
8.0.20.0100.00917.45
8.0.10.0000.00717.04
8.0.00.0130.00716.82
7.4.330.0000.00515.14
7.4.320.0000.00716.51
7.4.300.0030.00316.59
7.4.290.0020.00516.52
7.4.280.0070.00016.45
7.4.270.0030.00316.52
7.4.260.0040.00416.48
7.4.250.0030.00516.41
7.4.240.0060.00116.48
7.4.230.0000.00716.45
7.4.220.0100.00716.68
7.4.210.0060.01116.55
7.4.200.0030.00316.73
7.4.190.0050.00316.58
7.4.160.0070.01016.54
7.4.150.0160.00317.40
7.4.140.0070.01117.86
7.4.130.0100.00916.46
7.4.120.0080.01016.69
7.4.110.0080.00816.55
7.4.100.0060.01216.52
7.4.90.0030.01316.64
7.4.80.0090.00916.72
7.4.70.0080.00816.55
7.4.60.0100.00716.47
7.4.50.0000.00816.61
7.4.40.0040.01122.77
7.4.30.0120.01016.47
7.4.10.0040.00815.04
7.4.00.0070.00914.82
7.3.330.0000.00713.16
7.3.320.0050.00013.18
7.3.310.0000.00716.27
7.3.300.0040.00416.26
7.3.290.0120.00816.36
7.3.280.0050.01016.38
7.3.270.0080.01517.40
7.3.260.0120.01216.44
7.3.250.0110.00616.46
7.3.240.0070.01016.40
7.3.230.0070.01016.39
7.3.210.0150.00316.50
7.3.200.0170.00619.39
7.3.190.0100.00716.59
7.3.180.0070.01316.31
7.3.170.0130.00716.47
7.3.160.0090.00616.48
7.3.130.0160.00314.91
7.3.120.0040.01014.98
7.3.110.0130.00714.96
7.3.100.0000.01314.60
7.3.90.0030.01314.93
7.3.80.0110.00414.48
7.3.70.0110.00314.77
7.3.60.0070.00714.91
7.3.50.0070.01014.76
7.3.40.0030.01014.81
7.3.30.0060.00615.02
7.3.20.0070.00716.80
7.3.10.0040.00716.34
7.3.00.0140.00016.55
7.2.330.0030.01416.84
7.2.320.0090.00916.75
7.2.310.0150.00616.68
7.2.300.0060.01016.56
7.2.290.0110.00816.75
7.2.260.0110.00614.91
7.2.250.0090.00815.09
7.2.240.0030.01015.12
7.2.230.0040.01415.00
7.2.220.0090.00615.16
7.2.210.0060.00314.85
7.2.200.0130.00314.94
7.2.190.0000.01815.25
7.2.180.0060.01315.21
7.2.170.0040.01115.05
7.2.160.0040.00814.87
7.2.150.0070.00717.05
7.2.140.0030.01016.92
7.2.130.0120.00316.89
7.2.120.0060.00316.66
7.2.110.0070.00716.83
7.2.100.0080.00816.94
7.2.90.0040.00716.85
7.2.80.0110.00416.87
7.2.70.0060.00916.72
7.2.60.0060.00816.82
7.2.50.0070.00316.57
7.2.40.0080.00317.06
7.2.30.0090.00616.80
7.2.20.0080.00816.80
7.2.10.0070.01016.91
7.2.00.0070.01016.95
7.1.330.0060.00915.77
7.1.320.0040.01115.96
7.1.310.0060.00615.71
7.1.300.0060.00915.81
7.1.290.0090.00615.92
7.1.280.0040.00415.79
7.1.270.0030.01315.72
7.1.260.0000.01315.77
7.1.250.0070.00715.72
7.1.240.0060.00615.58
7.1.230.0040.01215.70
7.1.220.0000.01715.59
7.1.210.0070.00715.65
7.1.200.0050.00515.71
7.1.190.0030.00915.38
7.1.180.0030.01015.80
7.1.170.0000.01015.48
7.1.160.0040.00815.55
7.1.150.0040.00715.66
7.1.140.0080.00815.48
7.1.130.0070.01015.61
7.1.120.0060.00615.88
7.1.110.0030.00815.80
7.1.100.0090.00616.95
7.1.90.0090.00915.76
7.1.80.0040.00815.90
7.1.70.0020.00916.36
7.1.60.0070.01017.49
7.1.50.0050.01416.34
7.1.40.0040.01415.49
7.1.30.0060.00615.96
7.1.20.0030.01015.70
7.1.10.0060.00615.77
7.1.00.0050.04119.12
7.0.330.0000.01215.36
7.0.320.0040.00415.41
7.0.310.0070.00415.60
7.0.300.0070.00415.48
7.0.290.0000.01215.23
7.0.280.0100.00315.59
7.0.270.0030.00915.42
7.0.260.0080.00015.48
7.0.250.0050.00815.14
7.0.240.0100.00315.37
7.0.230.0070.01015.25
7.0.220.0030.00515.41
7.0.210.0000.01315.52
7.0.200.0060.00616.04
7.0.190.0030.01315.47
7.0.180.0040.01515.59
7.0.170.0070.01115.45
7.0.160.0080.00415.18
7.0.150.0030.00915.51
7.0.140.0020.04418.70
7.0.130.0060.01015.62
7.0.120.0030.01015.48
7.0.110.0130.04017.67
7.0.100.0100.04317.78
7.0.90.0030.04017.70
7.0.80.0080.04017.64
7.0.70.0160.03517.71
7.0.60.0020.04417.72
7.0.50.0020.05017.73
7.0.40.0050.04416.58
7.0.30.0070.04116.69
7.0.20.0120.03716.58
7.0.10.0030.03416.71
7.0.00.0090.03416.75
5.6.400.0040.00714.73
5.6.390.0040.01114.48
5.6.380.0000.01214.43
5.6.370.0040.00714.46
5.6.360.0070.00714.60
5.6.350.0000.01314.48
5.6.340.0060.01214.51
5.6.330.0030.00714.46
5.6.320.0090.00614.19
5.6.310.0060.01114.45
5.6.300.0000.01814.65
5.6.290.0030.01414.25
5.6.280.0080.03817.74
5.6.270.0130.00014.26
5.6.260.0110.03817.59
5.6.250.0100.04517.62
5.6.240.0020.02817.64
5.6.230.0050.04717.58
5.6.220.0060.04017.52
5.6.210.0090.04417.66
5.6.200.0030.05117.66
5.6.190.0090.04517.62
5.6.180.0100.02417.60
5.6.170.0110.04417.52
5.6.160.0100.03717.58
5.6.150.0030.03617.67
5.6.140.0110.02817.69
5.6.130.0100.04017.47
5.6.120.0090.04017.50
5.6.110.0080.04317.54
5.6.100.0070.03917.62
5.6.90.0120.03817.37
5.6.80.0080.03217.35
5.6.70.0080.04017.21
5.6.60.0020.04717.29
5.6.50.0120.03517.23
5.6.40.0050.04017.25
5.6.30.0070.04717.21
5.6.20.0080.03717.16
5.6.10.0050.02817.19
5.6.00.0020.02817.11
5.5.380.0030.04815.99
5.5.370.0040.03516.04
5.5.360.0050.04516.17
5.5.350.0020.04816.02
5.5.340.0170.02716.27
5.5.330.0080.04116.35
5.5.320.0050.04316.15
5.5.310.0050.04816.09
5.5.300.0050.03816.25
5.5.290.0000.03116.31
5.5.280.0100.04316.28
5.5.270.0070.04616.20
5.5.260.0060.02616.32
5.5.250.0020.04816.20
5.5.240.0080.02315.76
5.5.230.0100.04015.97
5.5.220.0050.04315.92
5.5.210.0030.03015.71
5.5.200.0080.02015.81
5.5.190.0100.03715.92
5.5.180.0040.02915.90
5.5.170.0000.00914.37
5.5.160.0080.04016.03
5.5.150.0090.04015.88
5.5.140.0030.03216.03
5.5.130.0060.04316.02
5.5.120.0090.03715.92
5.5.110.0050.04515.66
5.5.100.0080.03815.88
5.5.90.0080.03815.63
5.5.80.0050.03515.81
5.5.70.0070.03215.95
5.5.60.0090.02215.92
5.5.50.0050.03715.82
5.5.40.0070.03915.61
5.5.30.0050.04015.96
5.5.20.0020.03115.79
5.5.10.0050.04515.92
5.5.00.0040.05215.71
5.4.450.0050.03916.01
5.4.440.0070.04015.91
5.4.430.0070.04216.08
5.4.420.0070.04015.89
5.4.410.0030.04315.84
5.4.400.0020.04415.75
5.4.390.0050.02515.79
5.4.380.0050.02515.86
5.4.370.0080.03815.87
5.4.360.0110.03815.73
5.4.350.0030.04015.84
5.4.340.0030.04815.75
5.4.330.0000.01112.50
5.4.320.0030.04715.87
5.4.310.0100.03315.87
5.4.300.0030.02815.81
5.4.290.0100.03215.75
5.4.280.0080.04015.77
5.4.270.0050.04315.91
5.4.260.0030.04315.84
5.4.250.0000.02815.74
5.4.240.0100.03615.92
5.4.230.0120.02415.87
5.4.220.0050.04215.84
5.4.210.0080.03815.78
5.4.200.0050.04215.84
5.4.190.0050.04215.86
5.4.180.0020.02715.90
5.4.170.0050.02515.84
5.4.160.0100.03315.74
5.4.150.0050.02815.73
5.4.140.0100.03714.40
5.4.130.0030.03814.48
5.4.120.0070.03714.43
5.4.110.0020.02814.53
5.4.100.0100.03514.53
5.4.90.0130.03714.50
5.4.80.0100.03314.52
5.4.70.0080.03614.38
5.4.60.0040.02714.51
5.4.50.0030.03914.45
5.4.40.0080.03814.54
5.4.30.0050.04214.39
5.4.20.0050.04014.51
5.4.10.0050.03914.47
5.4.00.0070.03714.28
5.3.290.0050.02713.66
5.3.280.0040.04313.58
5.3.270.0050.04013.58
5.3.260.0130.03613.63
5.3.250.0060.03013.57
5.3.240.0030.03413.61
5.3.230.0020.04613.64
5.3.220.0080.03513.55
5.3.210.0070.04213.56
5.3.200.0050.04013.48
5.3.190.0070.03713.66
5.3.180.0050.03913.55
5.3.170.0060.02613.55
5.3.160.0050.04213.62
5.3.150.0030.04413.54
5.3.140.0070.03713.56
5.3.130.0060.04013.54
5.3.120.0020.02913.55
5.3.110.0050.03313.53
5.3.100.0050.04313.26
5.3.90.0070.03713.27
5.3.80.0100.02813.39
5.3.70.0070.03813.34
5.3.60.0040.03713.30
5.3.50.0020.03813.24
5.3.40.0100.02013.30
5.3.30.0070.03713.22
5.3.20.0050.03813.15
5.3.10.0050.03013.08
5.3.00.0060.03713.15
5.2.170.0030.06711.16
5.2.160.0070.05711.20
5.2.150.0100.05311.30
5.2.140.0100.05711.31
5.2.130.0030.05311.20
5.2.120.0000.06011.09
5.2.110.0100.06011.14
5.2.100.0030.05711.09
5.2.90.0000.05711.15
5.2.80.0070.06011.11
5.2.70.0030.05311.21
5.2.60.0030.06011.06
5.2.50.0100.05011.08
5.2.40.0070.05011.03
5.2.30.0000.05311.07
5.2.20.0030.05010.95
5.2.10.0000.06010.86
5.2.00.0100.05310.60
5.1.60.0030.0309.85
5.1.50.0030.0479.84
5.1.40.0100.0309.98
5.1.30.0030.05310.34
5.1.20.0030.04310.35
5.1.10.0000.04710.09
5.1.00.0030.05310.27
5.0.50.0000.0438.66
5.0.40.0070.0308.40
5.0.30.0100.0578.42
5.0.20.0070.0308.41
5.0.10.0030.0438.29
5.0.00.0000.0538.20
4.4.90.0000.0377.02
4.4.80.0030.0307.02
4.4.70.0000.0337.02
4.4.60.0100.0277.02
4.4.50.0000.0337.02
4.4.40.0000.0337.02
4.4.30.0000.0337.02
4.4.20.0000.0207.02
4.4.10.0070.0307.02
4.4.00.0000.0607.02
4.3.110.0030.0377.02
4.3.100.0030.0337.02
4.3.90.0030.0177.02
4.3.80.0000.0307.02
4.3.70.0000.0407.02
4.3.60.0000.0337.02
4.3.50.0000.0307.02
4.3.40.0030.0537.02
4.3.30.0000.0237.02
4.3.20.0030.0207.02
4.3.10.0070.0277.02
4.3.00.0000.0337.02

preferences:
45.51 ms | 401 KiB | 5 Q