3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface IDBResult { function FetchAssoc(); function Rewind(); } class DBResult implements IDBResult { private $_records = array( array('abc' => 'def'), ); private $_i = 0; function FetchAssoc() { return $this->_records[$this->_i++]; } function Rewind() { $this->_i = 0; } } class ResultIterator implements Iterator { private $_rs; private $_rec; private $_index = 0; private $_onLoad; function __construct(IDBResult $rs, callable $callback = null) { $this->_rs = $rs; $this->_onLoad = $callback ?: function($rec, $i) { return $rec; }; } public function current() { var_dump(__FUNCTION__); return call_user_func_array($this->_onLoad, array($this->_rec, $this->_index)); } public function key() { var_dump(__FUNCTION__); return $this->_index; } public function next() { var_dump(__FUNCTION__); $this->_index++; $this->_rec = $this->_rs->FetchAssoc(); } public function rewind() { var_dump(__FUNCTION__); $this->_index = 0; $this->_rs->Rewind(); } public function valid() { var_dump(__FUNCTION__); return !is_null($this->_rec); } } $rs = new DBResult(); $it = new ResultIterator($rs); foreach($it as $rec) { print_r($rec); }

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.70.0150.00616.88
8.3.60.0140.00316.88
8.3.50.0060.01522.11
8.3.40.0090.00618.71
8.3.30.0120.00619.15
8.3.20.0040.00420.34
8.3.10.0040.00421.65
8.3.00.0060.00617.63
8.2.180.0160.00616.88
8.2.170.0060.00922.96
8.2.160.0030.01021.92
8.2.150.0090.00024.18
8.2.140.0050.00324.66
8.2.130.0050.00226.16
8.2.120.0000.00819.66
8.2.110.0060.00322.23
8.2.100.0090.00317.63
8.2.90.0050.00319.06
8.2.80.0080.00017.97
8.2.70.0050.00317.50
8.2.60.0000.00817.93
8.2.50.0030.01018.07
8.2.40.0050.00318.01
8.2.30.0020.00517.99
8.2.20.0000.00817.71
8.2.10.0090.00017.97
8.2.00.0080.00017.70
8.1.280.0150.00025.92
8.1.270.0150.00418.76
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00319.01
8.1.230.0000.01217.42
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0080.00017.35
8.1.180.0000.00818.10
8.1.170.0060.00320.25
8.1.160.0040.00421.93
8.1.150.0000.00818.93
8.1.140.0090.00017.50
8.1.130.0050.00217.90
8.1.120.0080.00017.40
8.1.110.0050.00317.42
8.1.100.0020.00517.45
8.1.90.0040.00417.39
8.1.80.0030.00517.45
8.1.70.0030.00317.48
8.1.60.0070.00317.66
8.1.50.0030.00617.47
8.1.40.0030.00617.59
8.1.30.0030.00517.59
8.1.20.0050.00317.70
8.1.10.0080.00017.61
8.1.00.0060.00817.44
8.0.300.0050.00318.77
8.0.290.0090.00016.75
8.0.280.0000.00818.46
8.0.270.0070.00017.27
8.0.260.0030.00317.15
8.0.250.0070.00017.05
8.0.240.0000.00717.05
8.0.230.0000.00716.94
8.0.220.0000.00717.05
8.0.210.0040.00416.94
8.0.200.0040.00417.02
8.0.190.0060.00316.94
8.0.180.0000.00716.84
8.0.170.0000.00816.99
8.0.160.0000.00716.95
8.0.150.0070.00016.95
8.0.140.0040.00416.83
8.0.130.0000.00713.41
8.0.120.0070.00016.99
8.0.110.0050.00216.98
8.0.100.0040.00416.80
8.0.90.0000.00816.93
8.0.80.0040.01116.96
8.0.70.0020.00517.09
8.0.60.0040.00416.76
8.0.50.0080.00016.76
8.0.30.0100.01217.02
8.0.20.0110.01417.40
8.0.10.0000.00717.01
8.0.00.0070.01016.83
7.4.330.0060.00015.08
7.4.320.0030.00316.57
7.4.300.0040.00416.65
7.4.290.0060.00016.45
7.4.280.0040.00416.52
7.4.270.0030.00516.64
7.4.260.0070.00016.61
7.4.250.0000.00816.48
7.4.240.0030.00416.47
7.4.230.0040.00416.61
7.4.220.0120.00616.49
7.4.210.0090.00516.60
7.4.200.0070.00016.53
7.4.160.0050.01016.54
7.4.150.0150.01017.40
7.4.140.0090.00917.86
7.4.130.0110.00616.69
7.4.120.0080.01116.48
7.4.110.0070.01416.38
7.4.100.0100.00716.64
7.4.90.0100.00716.73
7.4.80.0080.01419.39
7.4.70.0080.01116.66
7.4.60.0030.01316.57
7.4.50.0000.00416.73
7.4.40.0030.01416.66
7.4.30.0190.00316.67
7.4.00.0000.01314.68
7.3.330.0000.00613.35
7.3.320.0090.00613.24
7.3.310.0030.00316.40
7.3.300.0000.00716.23
7.3.290.0030.00316.23
7.3.280.0080.00716.38
7.3.270.0320.03017.40
7.3.260.0100.00716.62
7.3.250.0120.01016.55
7.3.240.0130.00416.65
7.3.230.0160.00616.39
7.3.210.0130.01016.28
7.3.200.0120.00919.39
7.3.190.0080.00816.37
7.3.180.0070.01416.43
7.3.170.0130.00316.50
7.3.160.0160.00016.50
7.2.330.0130.01016.56
7.2.320.0070.01016.91
7.2.310.0110.00616.55
7.2.300.0000.01716.81
7.2.290.0190.00616.52
7.2.60.0110.00316.39
7.2.00.0000.01319.39
7.1.200.0050.00515.63
7.1.100.0040.00817.99
7.1.70.0000.00816.95
7.1.60.0070.01119.46
7.1.50.0140.01734.81
7.1.00.0070.07322.32
7.0.200.0000.01016.94
7.0.140.0000.05322.11
7.0.70.4330.04319.91
7.0.60.0030.09019.90
7.0.50.0000.05717.89
7.0.40.0030.05020.08
7.0.30.0230.04320.10
7.0.20.0270.04720.30
7.0.10.0300.03720.12
7.0.00.0100.05020.31
5.6.280.0030.07721.13
5.6.210.0070.07020.78
5.6.200.0000.09718.16
5.6.190.0070.08320.60
5.6.180.0270.06320.59
5.6.170.0270.06720.50
5.6.160.0100.04020.71
5.6.150.0100.04318.25
5.6.140.0100.07718.24
5.6.130.0030.04018.28
5.6.120.0070.07721.14
5.6.110.0030.04720.98
5.6.100.0070.07021.15
5.6.90.0130.07721.12
5.6.80.0030.08320.43
5.6.70.0270.07320.52
5.5.350.0070.08320.39
5.5.340.0030.06018.01
5.5.330.0070.04020.30
5.5.320.0070.08020.27
5.5.310.0130.04320.23
5.5.300.0030.05017.94
5.5.290.0100.08017.99
5.5.280.0100.04320.89
5.5.270.0100.03720.78
5.5.260.0070.07020.99
5.5.250.0100.03720.81
5.5.240.0130.07720.30
5.4.450.0130.05719.16
5.4.440.1000.06719.30
5.4.430.0970.05319.63
5.4.420.1000.07319.47
5.4.410.0270.05719.50
5.4.400.0230.04718.67
5.4.390.0430.05018.71
5.4.380.0230.05018.61
5.4.370.0200.07018.58
5.4.360.0130.06318.78
5.4.350.0070.06018.57
5.4.340.0130.06318.58
5.4.320.0170.05318.51
5.4.310.0130.05318.57
5.4.300.0200.04718.54
5.4.290.0070.06018.79
5.4.280.0130.06018.75
5.4.270.0130.05718.61
5.4.260.0200.04718.70
5.4.250.0200.05018.83
5.4.240.0100.06018.57
5.4.230.0230.04718.73
5.4.220.0030.07018.75
5.4.210.0300.04018.79
5.4.200.0100.05316.60
5.4.190.0130.05318.56
5.4.180.0170.05018.61
5.4.170.0170.05318.54
5.4.160.0130.05318.55
5.4.150.0100.06018.76
5.4.140.0170.04716.21
5.4.130.0130.05016.27
5.4.120.0170.04716.20
5.4.110.0130.04716.33
5.4.100.0200.04316.18
5.4.90.0070.05716.43
5.4.80.0070.05716.31
5.4.70.0200.04316.22
5.4.60.0170.04716.32
5.4.50.0130.05016.28
5.4.40.0230.04316.42
5.4.30.0170.04716.27
5.4.20.0270.06016.19
5.4.10.0130.05016.19
5.4.00.0130.04715.75
5.3.290.0130.07314.67
5.3.280.0170.05314.72
5.3.270.0170.05714.67
5.3.260.0070.06014.64
5.3.250.0170.07314.62
5.3.240.0170.05014.61
5.3.230.0170.05314.82
5.3.220.0100.05714.63
5.3.210.0100.05714.75
5.3.200.0200.04714.63
5.3.190.0230.04314.64
5.3.180.0130.05314.80
5.3.170.0170.05314.58
5.3.160.0170.05014.72
5.3.150.0200.04714.69
5.3.140.0170.05014.58
5.3.130.0100.05714.70
5.3.120.0170.05314.67
5.3.110.0100.05714.77
5.3.100.0170.05014.29
5.3.90.0100.05714.09
5.3.80.0100.05714.27
5.3.70.0100.05714.24
5.3.60.0070.05714.06
5.3.50.0200.04714.14
5.3.40.0170.05013.96
5.3.30.0230.04013.93
5.3.20.0100.05013.76
5.3.10.0070.05713.71
5.3.00.0130.05013.64
5.2.170.0130.04011.28
5.2.160.0030.05011.20
5.2.150.0130.04711.22
5.2.140.0100.04311.21
5.2.130.0070.04311.14
5.2.120.0100.04311.15
5.2.110.0100.04311.14
5.2.100.0170.04311.14
5.2.90.0030.05311.22
5.2.80.0230.03011.20
5.2.70.0070.04711.20
5.2.60.0130.04011.10
5.2.50.0030.04711.06
5.2.40.0200.04311.04
5.2.30.0200.03310.96
5.2.20.0100.04010.95
5.2.10.0030.05310.85
5.2.00.0170.04010.91
5.1.60.0070.03710.00
5.1.50.0200.02310.09
5.1.40.0130.04310.06
5.1.30.0030.04310.39
5.1.20.0030.04310.57
5.1.10.0100.03710.17
5.1.00.0100.03310.26
5.0.50.0100.0278.76
5.0.40.0030.0308.50
5.0.30.0070.0438.25
5.0.20.0030.0378.27
5.0.10.0130.0238.27
5.0.00.0030.0478.16
4.4.90.0100.0235.88
4.4.80.0070.0205.82
4.4.70.0070.0205.88
4.4.60.0000.0275.89
4.4.50.0030.0335.85
4.4.40.0070.0335.91
4.4.30.0100.0175.92
4.4.20.0070.0205.88
4.4.10.0030.0235.95
4.4.00.0070.0335.84
4.3.110.0070.0235.79
4.3.100.0070.0205.74
4.3.90.0070.0205.80
4.3.80.0100.0335.76
4.3.70.0030.0235.79
4.3.60.0100.0175.80
4.3.50.0000.0275.81
4.3.40.0130.0275.74
4.3.30.0030.0304.58
4.3.20.0030.0234.52
4.3.10.0030.0234.47
4.3.00.0030.0206.93

preferences:
51.96 ms | 401 KiB | 5 Q