3v4l.org

run code in 300+ PHP versions simultaneously
<?php class lazyNew implements Iterator { private $obj = null; private $func ; public function __construct($func) { $this->func = $func; } public function init() { if ($this->obj === null) { $func = $this->func; $this->obj = $func(); } return $this->obj; } public function current() { return $this->init()->current(); } public function valid() { echo "valid on ".get_class($this)."\n"; //also try var_dump($this) return $this->init()->valid(); } public function next() { return $this->init()->next(); } public function key() { return $this->init()->key(); } public function rewind() { echo "rewind on ".get_class($this)."\n"; return $this->init()->rewind(); } } $P = new lazyNew(function() use (&$P) { return $P = new ArrayIterator(array(1,2,3,4,5)); }); foreach ($P as $val) echo($val); ?>

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.40.0110.00418.79
8.3.30.0140.00718.71
8.3.20.0080.00018.86
8.3.10.0040.00420.61
8.3.00.0000.00919.38
8.2.170.0140.00722.96
8.2.160.0100.01021.19
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0000.00726.16
8.2.120.0080.00019.23
8.2.110.0000.00921.00
8.2.100.0040.00717.91
8.2.90.0040.00419.34
8.2.80.0060.00319.40
8.2.70.0030.00517.63
8.2.60.0080.00017.80
8.2.50.0030.00618.07
8.2.40.0040.00418.22
8.2.30.0040.00418.18
8.2.20.0000.00817.60
8.2.10.0040.00417.72
8.2.00.0040.00417.69
8.1.270.0050.00324.66
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0100.00022.42
8.1.230.0070.00420.97
8.1.220.0000.00817.74
8.1.210.0000.00819.10
8.1.200.0060.00317.48
8.1.190.0040.00417.53
8.1.180.0050.00318.10
8.1.170.0000.00818.61
8.1.160.0040.00418.91
8.1.150.0030.00518.71
8.1.140.0040.00417.34
8.1.130.0030.00317.84
8.1.120.0030.00517.38
8.1.110.0000.00717.43
8.1.100.0040.00417.35
8.1.90.0040.00417.46
8.1.80.0050.00217.48
8.1.70.0000.00817.44
8.1.60.0000.00817.56
8.1.50.0050.00517.44
8.1.40.0050.00317.42
8.1.30.0000.00817.59
8.1.20.0060.00317.56
8.1.10.0040.00417.59
8.1.00.0030.00517.38
8.0.300.0000.00919.91
8.0.290.0000.00716.63
8.0.280.0020.00518.45
8.0.270.0030.00317.27
8.0.260.0040.00416.82
8.0.250.0040.00416.98
8.0.240.0070.00016.95
8.0.230.0030.00316.92
8.0.220.0030.00616.91
8.0.210.0000.00816.91
8.0.200.0040.00416.93
8.0.190.0000.00716.86
8.0.180.0050.00316.98
8.0.170.0030.00716.91
8.0.160.0080.00016.84
8.0.150.0030.00516.86
8.0.140.0050.00416.77
8.0.130.0000.00513.32
8.0.120.0080.00016.84
8.0.110.0040.00416.77
8.0.100.0040.00416.79
8.0.90.0070.00016.89
8.0.80.0060.00916.96
8.0.70.0040.00416.84
8.0.60.0050.00316.93
8.0.50.0000.00716.77
8.0.30.0090.01116.97
8.0.20.0100.00817.00
8.0.10.0050.00316.90
8.0.00.0100.00816.84
7.4.330.0050.00013.02
7.4.320.0030.00316.65
7.4.300.0030.00316.43
7.4.290.0030.00316.61
7.4.280.0030.00616.41
7.4.270.0030.00316.50
7.4.260.0030.00313.26
7.4.250.0030.00616.59
7.4.240.0040.00416.58
7.4.230.0070.00016.63
7.4.220.0060.01216.61
7.4.210.0050.01116.61
7.4.200.0070.00016.54
7.4.190.0050.00216.71
7.4.160.0000.01716.52
7.4.150.0140.01016.46
7.4.140.0120.00816.63
7.4.130.0110.00716.56
7.4.120.0070.01016.45
7.4.110.0070.01116.32
7.4.100.0150.00316.64
7.4.90.0170.00016.54
7.4.80.0120.00919.39
7.4.70.0090.01316.48
7.4.60.0120.00616.38
7.4.50.0030.00616.38
7.4.40.0090.00316.42
7.4.30.0040.01816.60
7.4.00.0170.00015.14
7.3.330.0000.00613.16
7.3.320.0060.00013.32
7.3.310.0030.00516.30
7.3.300.0050.00316.30
7.3.290.0060.01116.32
7.3.280.0060.01016.27
7.3.270.0040.01216.61
7.3.260.0090.00916.56
7.3.250.0100.01116.60
7.3.240.0090.01316.46
7.3.230.0070.01016.27
7.3.210.0040.01216.38
7.3.200.0100.01316.29
7.3.190.0100.00916.41
7.3.180.0140.00316.36
7.3.170.0140.00316.30
7.3.160.0120.00616.48
7.3.120.0100.00714.81
7.2.330.0100.00716.68
7.2.320.0060.01116.85
7.2.310.0130.01016.87
7.2.300.0060.01716.52
7.2.290.0120.00416.70
7.2.60.0100.00716.95
7.2.00.0060.00619.52
7.1.200.0000.00915.90
7.1.70.0040.00417.26
7.1.60.0030.00717.31
7.1.50.0040.02016.73
7.1.00.0000.08022.45
7.0.200.0030.01216.69
7.0.140.0000.08022.11
7.0.120.0000.07022.13
7.0.60.0000.08721.66
7.0.50.0100.05717.79
7.0.40.0000.09020.13
7.0.30.0400.06720.33
7.0.20.0370.05320.23
7.0.10.0070.08020.23
7.0.00.0100.05720.05
5.6.280.0000.07721.00
5.6.210.0070.07320.47
5.6.200.0070.07318.23
5.6.190.0070.04020.52
5.6.180.0230.08320.45
5.6.170.0370.07320.71
5.6.160.0030.04320.71
5.6.150.0000.04318.15
5.6.140.0070.06018.23
5.6.130.0070.08318.16
5.6.120.0070.08021.16
5.6.110.0230.04321.00
5.6.100.0100.08021.01
5.6.90.0030.07321.14
5.6.80.0070.08020.50
5.5.350.0000.05720.37
5.5.340.0070.05717.98
5.5.330.0170.04720.31
5.5.320.0170.04320.28
5.5.310.0300.04720.42
5.5.300.0000.04317.98
5.5.290.0070.08317.98
5.5.280.0070.04020.81
5.5.270.0030.08020.77
5.5.260.0100.06320.88
5.5.250.0070.08720.59
5.5.240.0130.05720.05
5.4.450.0070.06019.32
5.4.440.0130.07719.56
5.4.430.0070.07019.52
5.4.420.0100.05319.56
5.4.410.0170.05319.35
5.4.400.0100.07318.86
5.4.390.0070.04319.16
5.4.380.0070.07719.24
5.4.370.0070.06719.25
5.4.360.0100.04318.97
5.4.350.0030.07719.14
5.4.340.0100.04719.15
5.4.320.0100.07019.20
5.4.310.0070.07319.00
5.4.300.0070.07318.85
5.4.290.0070.03719.20
5.4.280.0100.03318.91
5.4.270.0070.07319.16
5.4.260.0030.06019.23
5.4.250.0170.07018.84
5.4.240.0070.03719.14
5.4.230.0100.07719.00
5.4.220.0030.07319.23
5.4.210.0070.04319.20
5.4.200.0030.04018.84
5.4.190.0030.08018.84
5.4.180.0130.04018.86
5.4.170.0030.08018.85
5.4.160.0100.04318.86
5.4.150.0070.07319.12
5.4.140.0070.07716.36
5.4.130.0130.04316.38
5.4.120.0100.07016.37
5.4.110.0100.07716.30
5.4.100.0070.07316.31
5.4.90.0000.07716.33
5.4.80.0030.07716.48
5.4.70.0070.07016.52
5.4.60.0070.07716.38
5.4.50.0100.04716.46
5.4.40.0130.07016.38
5.4.30.0100.07016.42
5.4.20.0000.08016.38
5.4.10.0100.04716.39
5.4.00.0000.08315.80
5.3.290.0070.07714.71
5.3.280.0130.06014.69
5.3.270.0070.08014.54
5.3.260.0130.05314.67
5.3.250.0170.06714.66
5.3.240.0070.07314.66
5.3.230.0030.04014.64
5.3.220.0070.05014.66
5.3.210.0070.04314.61
5.3.200.0130.06714.59
5.3.190.0170.06714.63
5.3.180.0030.05314.59
5.3.170.0070.04714.50
5.3.160.0070.07314.72
5.3.150.0070.04714.74
5.3.140.0100.05714.63
5.3.130.0030.05314.59
5.3.120.0100.07714.56
5.3.110.0170.06314.57
5.3.100.0130.07014.07
5.3.90.0030.06714.07
5.3.80.0030.05013.92
5.3.70.0030.07714.00
5.3.60.0130.07014.18
5.3.50.0070.04313.98
5.3.40.0070.07013.89
5.3.30.0030.05714.08
5.3.20.0070.07313.71
5.3.10.0000.06013.67
5.3.00.0170.06313.57
5.2.170.0070.06011.16
5.2.160.0030.03011.21
5.2.150.0000.07011.08
5.2.140.0030.03711.10
5.2.130.0070.06011.16
5.2.120.0170.05011.17
5.2.110.0030.03711.28
5.2.100.0100.03011.15
5.2.90.0030.06011.11
5.2.80.0000.03711.07
5.2.70.0030.03711.11
5.2.60.0030.02711.06
5.2.50.0070.02710.95
5.2.40.0030.03011.00
5.2.30.0000.03011.06
5.2.20.0000.03011.02
5.2.10.0000.03011.02
5.2.00.0000.03010.70
5.1.60.0000.02710.02
5.1.50.0000.02710.05
5.1.40.0030.0239.90
5.1.30.0000.02710.40
5.1.20.0000.02710.44
5.1.10.0000.03010.13
5.1.00.0000.02710.12
5.0.50.0070.0178.64
5.0.40.0030.0238.36
5.0.30.0070.0538.36
5.0.20.0030.0208.36
5.0.10.0030.0178.36
5.0.00.0000.0338.36
4.4.90.0000.0178.36
4.4.80.0070.0108.36
4.4.70.0070.0108.36
4.4.60.0000.0178.36
4.4.50.0000.0178.36
4.4.40.0030.0208.36
4.4.30.0000.0178.36
4.4.20.0000.0178.36
4.4.10.0000.0208.36
4.4.00.0030.0238.36
4.3.110.0030.0178.36
4.3.100.0000.0208.36
4.3.90.0000.0238.36
4.3.80.0030.0238.36
4.3.70.0000.0178.36
4.3.60.0000.0178.36
4.3.50.0030.0138.36
4.3.40.0000.0238.36
4.3.30.0000.0138.36
4.3.20.0000.0178.36
4.3.10.0000.0138.36
4.3.00.0000.0138.36

preferences:
47.72 ms | 400 KiB | 5 Q