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; } } class MyCollection implements IteratorAggregate { private $var = array(); private $count = 0; // Required definition of interface IteratorAggregate public function getIterator() { return new MyIterator($this->var); } public function add($value) { $this->items[$this->count++] = $value; } } $values = array('value 1','value 2','value 3'); $coll = new MyCollection($values); 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.0130.00718.36
8.3.50.0240.00622.00
8.3.40.0060.00918.84
8.3.30.0040.01119.17
8.3.20.0000.00720.31
8.3.10.0040.00423.53
8.3.00.0040.00422.37
8.2.180.0150.00318.41
8.2.170.0130.01022.96
8.2.160.0110.00420.57
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0000.00819.89
8.2.110.0050.00522.21
8.2.100.0040.00717.59
8.2.90.0040.00418.95
8.2.80.0050.00317.97
8.2.70.0040.00417.63
8.2.60.0000.00817.80
8.2.50.0000.00818.07
8.2.40.0030.00618.28
8.2.30.0000.00817.96
8.2.20.0050.00317.57
8.2.10.0000.00717.77
8.2.00.0000.00817.87
8.1.280.0120.00325.92
8.1.270.0000.00822.11
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.72
8.1.230.0040.00719.14
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0040.00417.48
8.1.190.0040.00417.53
8.1.180.0080.00018.10
8.1.170.0080.00018.60
8.1.160.0000.01122.02
8.1.150.0000.00718.64
8.1.140.0000.00717.38
8.1.130.0000.00717.76
8.1.120.0070.00017.46
8.1.110.0040.00417.38
8.1.100.0000.00717.46
8.1.90.0080.00017.32
8.1.80.0000.00717.49
8.1.70.0090.00017.36
8.1.60.0000.00817.61
8.1.50.0090.00017.44
8.1.40.0000.00917.59
8.1.30.0030.00617.61
8.1.20.0040.00417.67
8.1.10.0000.00817.58
8.1.00.0040.00417.57
8.0.300.0040.00418.77
8.0.290.0000.00717.18
8.0.280.0070.00018.40
8.0.270.0030.00317.19
8.0.260.0000.00616.79
8.0.250.0000.00717.04
8.0.240.0050.00316.88
8.0.230.0050.00216.88
8.0.220.0040.00416.91
8.0.210.0030.00616.87
8.0.200.0000.00916.90
8.0.190.0000.00816.97
8.0.180.0050.00316.89
8.0.170.0040.00416.97
8.0.160.0070.00016.99
8.0.150.0070.00016.83
8.0.140.0000.00716.74
8.0.130.0050.00013.27
8.0.120.0000.00816.83
8.0.110.0030.00616.81
8.0.100.0000.00716.87
8.0.90.0070.00016.87
8.0.80.0060.01516.94
8.0.70.0030.00516.95
8.0.60.0000.00716.88
8.0.50.0040.00416.88
8.0.30.0090.00917.21
8.0.20.0060.01417.40
8.0.10.0000.00717.02
8.0.00.0090.01216.83
7.4.330.0000.00515.00
7.4.320.0000.00616.46
7.4.300.0030.00316.57
7.4.290.0040.00416.60
7.4.280.0050.00316.52
7.4.270.0030.00616.66
7.4.260.0040.00416.63
7.4.250.0050.00216.59
7.4.240.0020.00516.62
7.4.230.0030.00316.59
7.4.220.0100.01016.51
7.4.210.0050.01016.51
7.4.200.0000.00716.27
7.4.190.0070.00016.79
7.4.160.0100.00716.38
7.4.150.0090.00917.40
7.4.140.0100.01017.86
7.4.130.0100.00716.67
7.4.120.0090.01216.70
7.4.110.0130.00316.55
7.4.100.0140.00416.68
7.4.90.0100.01316.49
7.4.80.0240.00419.39
7.4.70.0060.01116.59
7.4.60.0070.01116.55
7.4.50.0000.00816.66
7.4.40.0030.01322.77
7.4.30.0120.00316.73
7.4.00.0060.00915.14
7.3.330.0040.00413.24
7.3.320.0000.00513.31
7.3.310.0070.00016.32
7.3.300.0000.00716.29
7.3.290.0090.00616.29
7.3.280.0090.00916.30
7.3.270.0070.01517.40
7.3.260.0130.00616.47
7.3.250.0110.00616.46
7.3.240.0120.00616.42
7.3.230.0070.01016.45
7.3.210.0060.01216.41
7.3.200.0100.01019.39
7.3.190.0130.00416.36
7.3.180.0090.00616.59
7.3.170.0140.00716.56
7.3.160.0060.00916.23
7.3.120.0040.01114.98
7.3.110.0030.01614.82
7.3.100.0070.01014.69
7.3.90.0090.00314.80
7.3.80.0000.01315.01
7.3.70.0110.00714.78
7.3.60.0000.01614.55
7.3.50.0090.00614.71
7.3.40.0030.00614.85
7.3.30.0040.00714.52
7.3.20.0040.00816.71
7.3.10.0060.00616.59
7.3.00.0090.00416.75
7.2.330.0100.00616.93
7.2.320.0120.00616.59
7.2.310.0130.00316.77
7.2.300.0060.01116.58
7.2.290.0100.00716.56
7.2.240.0110.00615.12
7.2.230.0040.01215.25
7.2.220.0030.01614.80
7.2.210.0030.01015.20
7.2.200.0080.00815.11
7.2.190.0090.00614.83
7.2.180.0030.01315.04
7.2.170.0030.00614.86
7.2.160.0040.00815.00
7.2.150.0090.00416.82
7.2.140.0030.01017.04
7.2.130.0050.00816.90
7.2.120.0020.01217.06
7.2.110.0080.00516.87
7.2.100.0080.00816.93
7.2.90.0040.00917.04
7.2.80.0080.00616.81
7.2.70.0060.00917.05
7.2.60.0080.00616.91
7.2.50.0120.00516.93
7.2.40.0100.00617.03
7.2.30.0130.01016.83
7.2.20.0070.00916.82
7.2.10.0150.00616.92
7.2.00.0090.00717.34
7.1.330.0070.01015.89
7.1.320.0030.01415.48
7.1.310.0090.00015.78
7.1.300.0060.00615.87
7.1.290.0070.01015.88
7.1.280.0030.00915.67
7.1.270.0030.01015.84
7.1.260.0040.01115.84
7.1.250.0050.00715.88
7.1.230.0250.00915.80
7.1.220.0100.00715.80
7.1.210.2640.00315.75
7.1.200.0140.00315.55
7.1.190.0120.00615.71
7.1.180.0080.00815.93
7.1.170.0180.00415.89
7.1.160.0140.00415.83
7.1.150.0070.00715.59
7.1.140.0330.00315.55
7.1.130.0130.00415.68
7.1.120.0160.00315.86
7.1.110.0080.00815.56
7.1.100.0120.00217.15
7.1.90.0090.00915.74
7.1.80.0180.00315.99
7.1.70.0070.00616.45
7.1.60.0060.01717.67
7.1.50.0130.00916.33
7.1.40.0040.01315.70
7.1.30.0310.00715.93
7.1.20.0200.01315.82
7.1.10.0090.01215.79
7.1.00.0090.03819.06
7.0.310.0070.00715.59
7.0.300.0550.00315.53
7.0.290.0500.00615.45
7.0.280.0080.00815.18
7.0.270.0250.00415.46
7.0.260.0140.00315.57
7.0.250.0310.00315.33
7.0.240.0090.00615.45
7.0.230.0080.00815.48
7.0.220.0040.01815.48
7.0.210.0140.00315.38
7.0.200.0120.00516.13
7.0.190.0100.01015.52
7.0.180.0300.00615.51
7.0.170.0070.00715.52
7.0.160.0150.00415.23
7.0.150.0160.00515.48
7.0.140.0080.04018.80
7.0.130.0200.00315.42
7.0.120.0140.00515.61
7.0.110.0250.00415.32
7.0.100.0190.00815.10
7.0.90.0120.00414.96
7.0.80.0200.00815.46
7.0.70.0090.00815.38
7.0.60.0140.03817.75
7.0.50.0160.04616.75
7.0.40.0130.03116.81
7.0.30.0140.02416.87
7.0.20.0190.04616.91
7.0.10.0210.02016.69
7.0.00.0080.02616.83
5.6.380.0110.00314.30
5.6.370.0170.00414.21
5.6.360.0070.01014.53
5.6.350.0140.00014.32
5.6.340.0050.00914.66
5.6.330.0060.00614.39
5.6.320.0110.00814.40
5.6.310.0050.00914.63
5.6.300.0160.00314.75
5.6.290.0100.00614.34
5.6.280.0080.04217.67
5.6.270.0130.00714.49
5.6.260.0130.00914.32
5.6.250.0090.01014.41
5.6.240.0060.00914.31
5.6.230.0180.00714.31
5.6.220.0120.00614.27
5.6.210.0160.03717.59
5.6.200.0120.04516.42
5.6.190.0050.02517.24
5.6.180.0080.02517.48
5.6.170.0240.02517.45
5.6.160.0130.04317.46
5.6.150.0130.03716.29
5.6.140.0130.03516.22
5.6.130.0130.03916.30
5.6.120.0070.02817.67
5.6.110.0180.04317.66
5.6.100.0190.03917.96
5.6.90.0140.04417.57
5.6.80.0120.04317.41
5.6.70.0160.02617.34
5.6.60.0110.01114.27
5.6.50.0050.01414.25
5.6.40.0160.01014.29
5.6.30.0180.00314.22
5.6.20.0130.01014.09
5.6.10.0100.00714.16
5.6.00.0080.00814.44
5.5.380.0160.00912.79
5.5.370.0080.00612.79
5.5.360.0120.00012.79
5.5.350.0070.03216.60
5.5.340.0020.02415.37
5.5.330.0040.02616.59
5.5.320.0080.04116.59
5.5.310.0160.04316.54
5.5.300.0060.04115.37
5.5.290.0080.04315.37
5.5.280.0150.04216.77
5.5.270.0150.03416.82
5.5.260.0090.02816.80
5.5.250.0030.03916.69
5.5.240.0050.02316.53
5.5.230.0170.00312.79
5.5.220.0090.00412.79
5.5.210.0080.00512.79
5.5.200.0130.00012.79
5.5.190.0120.00412.79
5.5.180.0090.00912.79
5.5.170.0170.00014.34
5.5.160.0120.00612.79
5.5.150.0050.01012.79
5.5.140.0110.00012.79
5.5.130.0130.00312.79
5.5.120.0180.00012.79
5.5.110.0100.00512.79
5.5.100.0050.00512.79
5.5.90.0100.00512.79
5.5.80.0060.00612.79
5.5.70.0100.00512.79
5.5.60.0160.00512.79
5.5.50.0150.00612.79
5.5.40.0130.00012.79
5.5.30.0080.00512.79
5.5.20.0040.00812.79
5.5.10.0100.00912.79
5.5.00.0160.00312.79
5.4.450.0920.02716.10
5.4.440.1060.02516.12
5.4.430.1070.02416.13
5.4.420.1050.02216.17
5.4.410.1010.02616.09
5.4.400.1070.02315.96
5.4.390.1070.02315.93
5.4.380.1090.02316.02
5.4.370.1050.02515.90
5.4.360.1050.02115.94
5.4.350.0970.02516.05
5.4.340.1030.02516.00
5.4.330.0140.00012.79
5.4.320.0950.02115.83
5.4.310.1000.02315.87
5.4.300.0980.02315.93
5.4.290.1020.02616.02
5.4.280.0970.02216.00
5.4.270.1040.02415.89
5.4.260.1150.02015.90
5.4.250.1100.02515.82
5.4.240.1070.02216.00
5.4.230.1050.02215.88
5.4.220.1080.02115.94
5.4.210.1050.02315.82
5.4.200.1090.02216.01
5.4.190.1050.02316.04
5.4.180.0910.02115.95
5.4.170.1090.02015.92
5.4.160.1060.02016.00
5.4.150.1100.02315.82
5.4.140.1050.02714.60
5.4.130.1050.02214.54
5.4.120.1100.02314.65
5.4.110.1070.02014.65
5.4.100.0900.02214.62
5.4.90.1000.01814.65
5.4.80.1060.02614.61
5.4.70.1120.02114.66
5.4.60.0970.01814.61
5.4.50.1110.02414.51
5.4.40.0500.02214.66
5.4.30.0030.03014.63
5.4.20.0100.02014.58
5.4.10.0400.03214.65
5.4.00.1040.02214.37
5.3.290.0950.02113.67
5.3.280.1050.01513.78
5.3.270.0970.02013.71
5.3.260.0980.02413.71
5.3.250.1030.02313.71
5.3.240.0950.02113.82
5.3.230.1020.02413.66
5.3.220.1010.01713.67
5.3.210.0900.02313.73
5.3.200.0080.04013.73
5.3.190.0080.03613.74
5.3.180.0690.01813.64
5.3.170.0980.02713.67
5.3.160.0950.02213.72
5.3.150.0970.02013.69
5.3.140.1010.01813.64
5.3.130.1220.02713.75
5.3.120.0020.02713.63
5.3.110.0030.02813.71
5.3.100.0080.02313.38
5.3.90.0450.02513.36
5.3.80.1050.02113.37
5.3.70.0920.02813.37
5.3.60.0920.02413.36
5.3.50.0070.02713.36
5.3.40.0080.02413.38
5.3.30.0050.02413.40
5.3.20.0830.01613.29
5.3.10.0990.02013.24
5.3.00.1020.02413.17
5.2.170.0830.01911.94
5.2.160.0920.01711.97
5.2.150.0850.02011.97
5.2.140.0820.01512.09
5.2.130.0910.01911.92
5.2.120.0870.02011.94
5.2.110.0850.01411.96
5.2.100.0900.01811.96
5.2.90.0790.01511.91
5.2.80.0890.01712.03
5.2.70.0900.01712.06
5.2.60.0870.01711.89
5.2.50.0890.01612.04
5.2.40.0780.01311.94
5.2.30.0740.01711.89
5.2.20.0730.02011.88
5.2.10.0670.02011.84
5.2.00.0730.02011.77
5.1.60.0720.01711.33
5.1.50.0740.01811.44
5.1.40.0740.01711.40
5.1.30.0620.01311.58
5.1.20.0610.01311.63
5.1.10.0090.02211.38
5.1.00.0140.02711.50
5.0.50.0070.02210.63
5.0.40.0090.01510.65
5.0.30.0050.02410.64
5.0.20.0030.01610.53
5.0.10.0050.02310.61
5.0.00.0090.02010.52
4.4.90.0050.02010.52
4.4.80.0020.01810.52
4.4.70.0030.01110.52
4.4.60.0010.01510.52
4.4.50.0050.01810.52
4.4.40.0090.01310.52
4.4.30.0070.01510.52
4.4.20.0050.01310.52
4.4.10.0070.02010.52
4.4.00.0070.02310.52
4.3.110.0050.01510.52
4.3.100.0070.00910.52
4.3.90.0060.01010.52
4.3.80.0060.02510.52
4.3.70.0060.01710.52
4.3.60.0040.01510.52
4.3.50.0060.01910.52
4.3.40.0070.01210.52
4.3.30.0050.01610.52
4.3.20.0050.01310.52
4.3.10.0020.01210.52
4.3.00.0030.01410.52

preferences:
47.32 ms | 401 KiB | 5 Q