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(); foreach ($coll as $key => $val) {$coll->add('value 1'); $coll->add('value 2'); $coll->add('value 3'); 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.00418.55
8.3.50.0080.00821.21
8.3.40.0070.00718.98
8.3.30.0130.00618.81
8.3.20.0040.00418.91
8.3.10.0070.00021.22
8.3.00.0070.00023.61
8.2.180.0150.00316.75
8.2.170.0140.00422.96
8.2.160.0070.01020.52
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0040.00421.00
8.2.110.0030.00720.12
8.2.100.0060.00617.97
8.2.90.0080.00019.17
8.2.80.0050.00318.05
8.2.70.0090.00017.63
8.2.60.0000.00817.93
8.2.50.0030.00518.07
8.2.40.0040.00418.34
8.2.30.0040.00421.13
8.2.20.0040.00417.68
8.2.10.0040.00417.75
8.2.00.0070.00017.68
8.1.280.0100.01025.92
8.1.270.0030.00523.99
8.1.260.0000.00826.35
8.1.250.0050.00228.09
8.1.240.0070.00322.59
8.1.230.0030.00820.86
8.1.220.0030.00518.77
8.1.210.0040.00418.95
8.1.200.0060.00317.36
8.1.190.0000.00717.54
8.1.180.0050.00318.10
8.1.170.0050.00318.53
8.1.160.0000.00718.82
8.1.150.0050.00218.65
8.1.140.0000.00817.38
8.1.130.0030.00317.77
8.1.120.0070.00217.50
8.1.110.0050.00317.34
8.1.100.0000.00717.50
8.1.90.0020.00517.46
8.1.80.0050.00317.49
8.1.70.0030.00317.49
8.1.60.0030.00617.50
8.1.50.0040.00417.54
8.1.40.0000.00817.43
8.1.30.0040.00417.68
8.1.20.0040.00417.61
8.1.10.0040.00417.56
8.1.00.0070.00017.47
8.0.300.0050.00319.88
8.0.290.0030.00617.00
8.0.280.0000.00718.34
8.0.270.0040.00417.29
8.0.260.0050.00316.84
8.0.250.0070.00016.97
8.0.240.0040.00416.88
8.0.230.0030.00316.98
8.0.220.0030.00316.96
8.0.210.0000.00716.90
8.0.200.0030.00316.97
8.0.190.0050.00316.95
8.0.180.0070.00016.98
8.0.170.0000.00816.92
8.0.160.0030.00316.82
8.0.150.0030.00516.74
8.0.140.0040.00416.84
8.0.130.0000.00613.34
8.0.120.0040.00416.84
8.0.110.0040.00416.93
8.0.100.0000.00816.82
8.0.90.0070.00016.91
8.0.80.0110.00716.80
8.0.70.0030.00616.88
8.0.60.0040.00416.92
8.0.50.0000.00716.80
8.0.30.0120.00716.95
8.0.20.0110.00717.40
8.0.10.0050.00217.00
8.0.00.0080.01016.71
7.4.330.0030.00314.89
7.4.320.0000.00616.54
7.4.300.0040.00416.63
7.4.290.0000.00816.52
7.4.280.0070.00016.56
7.4.270.0080.00016.61
7.4.260.0000.00613.35
7.4.250.0030.00516.46
7.4.240.0050.00316.67
7.4.230.0030.00516.73
7.4.220.0070.01116.56
7.4.210.0080.00816.61
7.4.200.0020.00516.71
7.4.190.0030.00316.58
7.4.160.0160.00016.40
7.4.150.0060.01217.40
7.4.140.0120.00517.86
7.4.130.0070.01116.54
7.4.120.0140.00316.47
7.4.110.0000.01716.62
7.4.100.0190.00416.41
7.4.90.0170.00316.67
7.4.80.0060.01219.39
7.4.70.0030.01316.39
7.4.60.0080.00816.49
7.4.50.0030.00516.57
7.4.40.0060.00922.52
7.4.30.0030.01616.61
7.4.00.0100.00014.98
7.3.330.0000.00513.38
7.3.320.0050.00013.35
7.3.310.0070.00016.41
7.3.300.0040.00416.33
7.3.290.0090.00616.38
7.3.280.0080.00916.39
7.3.270.0030.01317.40
7.3.260.0100.00918.24
7.3.250.0090.00916.50
7.3.240.0070.01116.55
7.3.230.0090.00916.79
7.3.210.0100.01016.48
7.3.200.0090.00819.39
7.3.190.0130.00316.32
7.3.180.0120.00316.48
7.3.170.0110.01116.52
7.3.160.0080.00816.46
7.3.120.0100.00615.07
7.2.330.0130.00516.53
7.2.320.0150.00616.59
7.2.310.0080.01516.54
7.2.300.0070.01016.75
7.2.290.0080.01216.71
7.2.60.0090.00617.04
7.2.00.0070.00719.50
7.1.200.0040.01115.85
7.1.100.0040.00818.22
7.1.70.0090.00617.33
7.1.60.0080.00819.40
7.1.50.0100.01317.01
7.1.00.0000.03722.50
7.0.200.0000.00816.93
7.0.140.0030.07022.09
7.0.110.0130.04719.91
7.0.100.0170.07319.98
7.0.90.0130.07719.97
7.0.80.0100.06019.88
7.0.70.0200.06720.00
7.0.60.0200.06320.13
7.0.50.0130.07020.02
7.0.40.0100.03719.73
7.0.30.0030.04019.75
7.0.20.0030.03319.73
7.0.10.0030.04019.73
7.0.00.0000.04319.63
5.6.280.0030.07320.79
5.6.260.0070.07320.90
5.6.250.0070.08020.52
5.6.240.0030.04020.65
5.6.230.0070.08020.57
5.6.220.0170.06320.57
5.6.210.0070.03720.63
5.6.200.0130.08020.63
5.6.190.0100.03320.67
5.6.180.0000.04020.57
5.6.170.0030.04020.71
5.6.160.0030.04020.71
5.6.150.0070.03020.59
5.6.140.0030.04020.66
5.6.130.0030.04320.61
5.6.120.0030.04320.57
5.6.110.0000.04320.69
5.6.100.0030.05320.57
5.6.90.0030.08320.64
5.6.80.0100.03320.10
5.6.70.0000.06320.03
5.6.60.0030.04020.19
5.6.50.0030.04319.91
5.6.40.0000.04019.96
5.6.30.0070.04320.01
5.6.20.0070.03719.99
5.6.10.0130.03020.01
5.6.00.0000.04320.01
5.5.380.0070.08017.64
5.5.370.0000.08717.70
5.5.360.0030.04017.52
5.5.350.0100.07317.62
5.5.340.0000.04317.83
5.5.330.0030.06018.10
5.5.320.0000.04318.11
5.5.310.0070.03717.93
5.5.300.0030.04017.91
5.5.290.0000.04318.23
5.5.280.0000.04317.91
5.5.270.0070.07017.92
5.5.260.0000.04017.94
5.5.250.0070.04717.72
5.5.240.0030.05717.44
5.5.230.0000.04717.45
5.5.220.0030.04017.20
5.5.210.0030.03717.51
5.5.200.0070.05017.48
5.5.190.0000.06717.58
5.5.180.0030.04717.58
5.5.160.0070.03317.28
5.5.150.0070.04317.44
5.5.140.0030.03317.43
5.5.130.0000.04017.18
5.5.120.0030.03717.27
5.5.110.0000.03717.58
5.5.100.0030.04317.39
5.5.90.0070.03017.08
5.5.80.0070.04317.20
5.5.70.0070.03717.17
5.5.60.0070.03317.17
5.5.50.0100.03317.07
5.5.40.0070.03317.17
5.5.30.0030.04017.07
5.5.20.0070.03717.36
5.5.10.0030.03717.28
5.5.00.0070.07317.32
5.4.450.0030.04019.50
5.4.440.0100.05319.31
5.4.430.0100.07719.36
5.4.420.0070.04019.41
5.4.410.0030.07019.13
5.4.400.0100.05319.06
5.4.390.0030.04019.18
5.4.380.0000.03719.18
5.4.370.0030.03718.99
5.4.360.0030.05719.23
5.4.350.0030.04718.95
5.4.340.0000.04319.32
5.4.320.0030.04018.99
5.4.310.0130.05719.24
5.4.300.0030.03718.97
5.4.290.0000.03719.25
5.4.280.0030.04319.16
5.4.270.0030.03318.94
5.4.260.0030.03719.33
5.4.250.0100.03018.98
5.4.240.0130.02719.00
5.4.230.0170.02319.17
5.4.220.0100.03019.02
5.4.210.0100.03319.23
5.4.200.0070.03319.26
5.4.190.0070.03318.97
5.4.180.0000.04719.32
5.4.170.0100.04019.30
5.4.160.0030.08318.98
5.4.150.0030.06319.26
5.4.140.0100.06716.39
5.4.130.0030.03716.55
5.4.120.0000.05016.28
5.4.110.0100.03316.50
5.4.100.0000.07316.65
5.4.90.0130.03316.45
5.4.80.0100.07016.55
5.4.70.0100.07316.56
5.4.60.0130.06716.52
5.4.50.0100.07016.64
5.4.40.0070.05016.62
5.4.30.0070.07716.51
5.4.20.0030.04716.47
5.4.10.0100.03016.54
5.4.00.0070.04715.98
5.3.290.0070.03714.68
5.3.280.0000.03714.69
5.3.270.0070.04314.49
5.3.260.0030.06714.61
5.3.250.0100.07314.77
5.3.240.0070.07714.62
5.3.230.0030.07714.85
5.3.220.0030.08014.62
5.3.210.0070.07714.59
5.3.200.0100.07014.73
5.3.190.0100.06714.59
5.3.180.0070.04014.71
5.3.170.0070.04314.59
5.3.160.0130.07014.56
5.3.150.0100.06014.72
5.3.140.0030.06314.72
5.3.130.0070.04714.58
5.3.120.0030.04714.58
5.3.110.0030.05314.53
5.3.100.0070.08014.15
5.3.90.0070.03314.05
5.3.80.0130.06714.05
5.3.70.0030.04014.00
5.3.60.0000.04014.04
5.3.50.0130.06313.99
5.3.40.0070.07013.94
5.3.30.0000.07714.02
5.3.20.0070.07313.69
5.3.10.0070.04013.80
5.3.00.0000.08013.63
5.2.170.0100.02711.91
5.2.160.0100.02011.91
5.2.150.0070.02311.91
5.2.140.0070.04711.91
5.2.130.0000.06311.91
5.2.120.0000.06011.91
5.2.110.0170.04711.91
5.2.100.0070.06011.91
5.2.90.0030.05711.91
5.2.80.0070.06311.91
5.2.70.0030.03011.91
5.2.60.0170.04711.91
5.2.50.0070.04311.91
5.2.40.0100.05311.91
5.2.30.0070.05711.91
5.2.20.0070.03011.91
5.2.10.0100.03311.91
5.2.00.0070.06011.91
5.1.60.0070.05011.91
5.1.50.0030.05311.91
5.1.40.0070.05011.91
5.1.30.0100.02711.91
5.1.20.0030.05311.91
5.1.10.0070.04311.91
5.1.00.0030.05311.91
5.0.50.0000.04711.91
5.0.40.0030.04311.91
5.0.30.0030.06311.91
5.0.20.0000.04311.91
5.0.10.0070.04011.91
5.0.00.0030.05311.91
4.4.90.0030.02311.91
4.4.80.0000.03311.91
4.4.70.0030.03711.91
4.4.60.0100.03011.91
4.4.50.0070.03011.91
4.4.40.0030.05011.91
4.4.30.0000.01711.91
4.4.20.0030.03011.91
4.4.10.0030.03711.91
4.4.00.0070.04011.91
4.3.110.0000.03711.91
4.3.100.0000.02011.91
4.3.90.0000.03711.91
4.3.80.0000.04711.91
4.3.70.0000.03711.91
4.3.60.0100.02311.91
4.3.50.0030.03311.91
4.3.40.0000.05311.91
4.3.30.0000.02711.91
4.3.20.0030.01711.91
4.3.10.0030.01311.91
4.3.00.0030.01311.91

preferences:
40.32 ms | 401 KiB | 5 Q