3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private $var = array(1,2,3); 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; } public $values = array(1,2,3); } 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->var[$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.0090.00918.43
8.3.50.0160.00422.04
8.3.40.0110.00418.70
8.3.30.0040.01119.23
8.3.20.0000.00720.30
8.3.10.0050.00323.73
8.3.00.0050.00319.50
8.2.180.0120.00318.38
8.2.170.0120.00322.96
8.2.160.0070.01020.25
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00022.25
8.2.110.0000.00922.11
8.2.100.0040.00717.91
8.2.90.0060.00317.63
8.2.80.0090.00017.97
8.2.70.0000.00817.93
8.2.60.0000.00818.04
8.2.50.0030.00618.10
8.2.40.0030.00622.18
8.2.30.0060.00318.02
8.2.20.0040.00417.78
8.2.10.0000.00718.23
8.2.00.0030.00617.77
8.1.280.0150.00625.92
8.1.270.0120.00323.71
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0030.00622.52
8.1.230.0030.00919.15
8.1.220.0030.00617.74
8.1.210.0060.00318.77
8.1.200.0070.00317.35
8.1.190.0050.00317.25
8.1.180.0060.00318.10
8.1.170.0060.00318.59
8.1.160.0000.00722.04
8.1.150.0090.00018.68
8.1.140.0000.00717.39
8.1.130.0000.00717.79
8.1.120.0050.00317.51
8.1.110.0000.00717.39
8.1.100.0000.00717.50
8.1.90.0000.00817.41
8.1.80.0040.00417.46
8.1.70.0000.00717.43
8.1.60.0080.00617.48
8.1.50.0000.00817.59
8.1.40.0050.00217.60
8.1.30.0030.00517.54
8.1.20.0040.00417.59
8.1.10.0040.00417.60
8.1.00.0040.00417.55
8.0.300.0000.00719.63
8.0.290.0030.00616.75
8.0.280.0030.00318.50
8.0.270.0030.00317.21
8.0.260.0030.00317.30
8.0.250.0070.00016.96
8.0.240.0030.00316.98
8.0.230.0000.00716.99
8.0.220.0040.00416.78
8.0.210.0070.00016.93
8.0.200.0070.00016.96
8.0.190.0080.00017.00
8.0.180.0040.00416.91
8.0.170.0030.00516.84
8.0.160.0040.00416.82
8.0.150.0040.00416.77
8.0.140.0050.00216.88
8.0.130.0070.00013.37
8.0.120.0030.00616.80
8.0.110.0050.00216.90
8.0.100.0040.00416.73
8.0.90.0040.00416.73
8.0.80.0000.01616.80
8.0.70.0040.00416.77
8.0.60.0070.00016.77
8.0.50.0000.00716.84
8.0.30.0120.01117.38
8.0.20.0050.01317.40
8.0.10.0070.00017.08
8.0.00.0080.01216.92
7.4.330.0020.00215.14
7.4.320.0000.00616.40
7.4.300.0060.00016.53
7.4.290.0070.00016.56
7.4.280.0000.00716.61
7.4.270.0050.00316.54
7.4.260.0030.00316.48
7.4.250.0070.00016.65
7.4.240.0010.00716.49
7.4.230.0000.00716.71
7.4.220.0090.00916.71
7.4.210.0040.01116.57
7.4.200.0040.00416.63
7.4.190.0000.00716.69
7.4.160.0100.00616.54
7.4.150.0130.00717.40
7.4.140.0120.00617.86
7.4.130.0060.01316.46
7.4.120.0070.01116.59
7.4.110.0070.01016.57
7.4.100.0120.00616.36
7.4.90.0040.01316.73
7.4.80.0070.01119.39
7.4.70.0070.01016.60
7.4.60.0100.00716.57
7.4.50.0040.00416.62
7.4.40.0070.01016.61
7.4.30.0070.01416.62
7.4.10.0070.01016.67
7.4.00.0060.00815.66
7.3.330.0000.00613.24
7.3.320.0050.00013.36
7.3.310.0000.00816.40
7.3.300.0030.00316.42
7.3.290.0130.00616.28
7.3.280.0080.01016.34
7.3.270.0150.00017.40
7.3.260.0060.01316.41
7.3.250.0150.00716.59
7.3.240.0110.00516.41
7.3.230.0030.01416.39
7.3.210.0080.00816.66
7.3.200.0120.00919.39
7.3.190.0170.00616.52
7.3.180.0100.01316.27
7.3.170.0110.00416.60
7.3.160.0100.00716.57
7.3.130.0030.01716.36
7.3.120.0080.01015.59
7.3.110.0070.00716.68
7.3.100.0110.00716.29
7.3.90.0080.00416.46
7.3.80.0030.01116.34
7.3.70.0030.00716.40
7.3.60.0070.00716.33
7.3.50.0040.01116.27
7.3.40.0060.00616.21
7.3.30.0090.00916.49
7.3.20.0030.01018.18
7.3.10.0070.00717.30
7.3.00.0100.00717.35
7.2.330.0130.01316.54
7.2.320.0120.00816.73
7.2.310.0130.00316.69
7.2.300.0080.00816.67
7.2.290.0160.00416.79
7.2.260.0100.01016.70
7.2.250.0070.01416.67
7.2.240.0040.01116.75
7.2.230.0070.01116.52
7.2.220.0000.01416.86
7.2.210.0000.01416.78
7.2.200.0000.01516.61
7.2.190.0030.01016.63
7.2.180.0100.00316.80
7.2.170.0130.00016.57
7.2.160.0060.00616.79
7.2.150.0000.01518.40
7.2.140.0000.01218.52
7.2.130.0090.00617.71
7.2.120.0070.01017.75
7.2.110.0050.00817.64
7.2.100.0050.00917.78
7.2.90.0110.00517.57
7.2.80.0050.00717.77
7.2.70.0090.00517.76
7.2.60.0070.00917.65
7.2.50.0050.00917.56
7.2.40.0060.00717.76
7.2.30.0030.01117.80
7.2.20.0100.00417.76
7.2.10.0030.01117.72
7.2.00.0050.00818.29
7.1.330.0000.01817.28
7.1.320.0070.00717.36
7.1.310.0060.01317.53
7.1.300.0030.01017.35
7.1.290.0100.00317.38
7.1.280.0000.00917.37
7.1.270.0040.01117.28
7.1.260.0060.00617.25
7.1.250.0050.01116.51
7.1.240.0060.00317.47
7.1.230.0060.00917.34
7.1.220.0110.00317.37
7.1.210.0070.01017.46
7.1.200.0070.00717.33
7.1.190.0080.00817.51
7.1.180.0030.00617.29
7.1.170.0030.01317.45
7.1.160.0130.00317.33
7.1.150.0060.01017.40
7.1.140.0030.01017.27
7.1.130.0000.01617.40
7.1.120.0000.01417.29
7.1.110.0000.01017.36
7.1.100.0030.01117.82
7.1.90.0090.00817.24
7.1.80.0090.00617.30
7.1.70.0020.00917.36
7.1.60.0080.01018.42
7.1.50.0100.00617.19
7.1.40.0000.01317.19
7.1.30.0040.00717.50
7.1.20.0030.00717.47
7.1.10.0030.01117.40
7.1.00.0070.03919.79
7.0.330.0150.00417.11
7.0.320.0070.01017.09
7.0.310.0040.00717.00
7.0.300.0040.00916.93
7.0.290.0070.01116.69
7.0.280.0070.01116.80
7.0.270.0070.00716.88
7.0.260.0040.00717.14
7.0.250.0030.01017.01
7.0.240.0090.00317.14
7.0.230.0030.01317.05
7.0.220.0040.01216.94
7.0.210.0070.01017.18
7.0.200.0070.00416.72
7.0.190.0060.00317.16
7.0.180.0110.00417.20
7.0.170.0040.01116.97
7.0.160.0030.01017.05
7.0.150.0040.00517.20
7.0.140.0020.04219.54
7.0.130.0070.01017.15
7.0.120.0150.00417.09
7.0.110.0030.01417.20
7.0.100.0080.02518.43
7.0.90.0050.02418.56
7.0.80.0020.02918.48
7.0.70.0140.02718.49
7.0.60.0080.02218.42
7.0.50.0050.02818.68
7.0.40.0070.03217.60
7.0.30.0080.04217.47
7.0.20.0130.04017.54
7.0.10.0050.04517.50
7.0.00.0080.03617.54
5.6.400.0060.00616.02
5.6.390.0130.00616.10
5.6.380.0070.01016.11
5.6.370.0000.01316.04
5.6.360.0030.01016.11
5.6.350.0060.01016.25
5.6.340.0000.01216.14
5.6.330.0040.00816.04
5.6.320.0060.00916.14
5.6.310.0060.00915.81
5.6.300.0040.01216.13
5.6.290.0070.00716.09
5.6.280.0070.01115.80
5.6.270.0030.01616.14
5.6.260.0030.00716.02
5.6.250.0090.02618.30
5.6.240.0070.02018.32
5.6.230.0070.02718.31
5.6.220.0030.02118.28
5.6.210.0080.01718.27
5.6.200.0050.02118.42
5.6.190.0050.02118.47
5.6.180.0100.04218.46
5.6.170.0110.04218.52
5.6.160.0060.03218.44
5.6.150.0030.04918.61
5.6.140.0030.04718.54
5.6.130.0060.03018.52
5.6.120.0080.04918.38
5.6.110.0020.02718.46
5.6.100.0120.04218.48
5.6.90.0080.04218.40
5.6.80.0070.04318.30
5.6.70.0060.02718.19
5.6.60.0070.04318.23
5.6.50.0080.03518.09
5.6.40.0130.04118.22
5.6.30.0050.04718.16
5.6.20.0070.04218.04
5.6.10.0050.03517.99
5.6.00.0020.02918.04
5.5.380.0050.02518.12
5.5.370.0050.03418.13
5.5.360.0030.02018.14
5.5.350.0020.03118.18
5.5.340.0080.02918.51
5.5.330.0060.02918.34
5.5.320.0050.03518.43
5.5.310.0080.04318.46
5.5.300.0080.04318.33
5.5.290.0030.02718.34
5.5.280.0050.04518.40
5.5.270.0070.03218.39
5.5.260.0100.04418.45
5.5.250.0140.02718.33
5.5.240.0060.03518.07
5.5.230.0070.03318.10
5.5.220.0050.04217.93
5.5.210.0070.04218.10
5.5.200.0060.03118.15
5.5.190.0100.04518.04
5.5.180.0050.02918.02
5.5.170.0110.00415.78
5.5.160.0070.04318.06
5.5.150.0090.03617.96
5.5.140.0050.04117.83
5.5.130.0100.02317.98
5.5.120.0070.02317.85
5.5.110.0080.04218.07
5.5.100.0100.02617.89
5.5.90.0110.02518.03
5.5.80.0090.03517.97
5.5.70.0080.04817.98
5.5.60.0030.02717.92
5.5.50.0110.03918.00
5.5.40.0080.03718.01
5.5.30.0090.03617.88
5.5.20.0070.02617.95
5.5.10.0070.04417.98
5.5.00.0100.02818.02
5.4.450.0110.03516.48
5.4.440.0030.04116.61
5.4.430.0040.04616.60
5.4.420.0070.04516.63
5.4.410.0010.04416.45
5.4.400.0050.02316.33
5.4.390.0070.03716.38
5.4.380.0070.03816.50
5.4.370.0030.04416.45
5.4.360.0100.04016.41
5.4.350.0000.03216.42
5.4.340.0030.04416.46
5.4.330.0030.01013.77
5.4.320.0090.02516.43
5.4.310.0030.03716.39
5.4.300.0050.02016.33
5.4.290.0050.02816.44
5.4.280.0050.02816.40
5.4.270.0050.02516.32
5.4.260.0080.02816.35
5.4.250.0060.02516.39
5.4.240.0030.02716.44
5.4.230.0060.03816.39
5.4.220.0080.02516.47
5.4.210.0070.03716.45
5.4.200.0080.02316.44
5.4.190.0080.02016.45
5.4.180.0080.02016.31
5.4.170.0030.04316.47
5.4.160.0050.04416.39
5.4.150.0050.04416.31
5.4.140.0050.02515.11
5.4.130.0100.02715.09
5.4.120.0050.02815.12
5.4.110.0050.03215.12
5.4.100.0050.03015.08
5.4.90.0110.01815.13
5.4.80.0130.03615.05
5.4.70.0030.02215.13
5.4.60.0020.02415.13
5.4.50.0100.01915.08
5.4.40.0090.02115.08
5.4.30.0050.03715.09
5.4.20.0100.03815.12
5.4.10.0060.04415.08
5.4.00.0050.02914.77
5.3.290.0040.03614.20
5.3.280.0070.02014.17
5.3.270.0030.03714.27
5.3.260.0070.02214.19
5.3.250.0050.04214.22
5.3.240.0090.01714.23
5.3.230.0030.03014.23
5.3.220.0050.04214.17
5.3.210.0080.03514.14
5.3.200.0080.04214.17
5.3.190.0070.03014.21
5.3.180.0070.02414.23
5.3.170.0060.01914.14
5.3.160.0100.01714.14
5.3.150.0050.03714.19
5.3.140.0020.04114.15
5.3.130.0120.03014.21
5.3.120.0080.02114.14
5.3.110.0080.04014.18
5.3.100.0030.03713.95
5.3.90.0050.03313.94
5.3.80.0050.04413.90
5.3.70.0160.02013.96
5.3.60.0050.02513.84
5.3.50.0060.01813.82
5.3.40.0020.03213.90
5.3.30.0050.02113.79
5.3.20.0070.02013.69
5.3.10.0120.04213.77
5.3.00.0050.04013.76
5.2.170.0030.04311.28
5.2.160.0100.06311.28
5.2.150.0130.04011.28
5.2.140.0030.05311.28
5.2.130.0030.03011.28
5.2.120.0030.04011.28
5.2.110.0000.05311.28
5.2.100.0030.06011.28
5.2.90.0030.03311.28
5.2.80.0000.03311.28
5.2.70.0070.04011.28
5.2.60.0070.06011.28
5.2.50.0100.06011.28
5.2.40.0070.02711.28
5.2.30.0000.03011.28
5.2.20.0030.04711.28
5.2.10.0100.05311.28
5.2.00.0070.04711.28
5.1.60.0070.03711.28
5.1.50.0070.04711.28
5.1.40.0070.02711.28
5.1.30.0030.02711.28
5.1.20.0000.04711.28
5.1.10.0030.04711.28
5.1.00.0070.04711.28
5.0.50.0000.02711.28
5.0.40.0030.04311.28
5.0.30.0000.05711.28
5.0.20.0030.04311.28
5.0.10.0030.04011.28
5.0.00.0070.06011.28
4.4.90.0000.03011.28
4.4.80.0000.02011.28
4.4.70.0030.01711.28
4.4.60.0100.03011.28
4.4.50.0000.02011.28
4.4.40.0000.05311.28
4.4.30.0030.03311.28
4.4.20.0000.03711.28
4.4.10.0030.02311.28
4.4.00.0030.03311.28
4.3.110.0030.03311.28
4.3.100.0000.02311.28
4.3.90.0030.01711.28
4.3.80.0070.04711.28
4.3.70.0000.01711.28
4.3.60.0000.03711.28
4.3.50.0000.03711.28
4.3.40.0000.03711.28
4.3.30.0070.02011.28
4.3.20.0000.03311.28
4.3.10.0030.03011.28
4.3.00.0030.02711.28

preferences:
36.95 ms | 401 KiB | 5 Q