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() { return call_user_func_array($this->_onLoad, array($this->_rec, $this->_index)); } public function key() { return $this->_index; } public function next() { $this->_index++; $this->_rec = $this->_rs->FetchAssoc(); } public function rewind() { $this->_index = 0; $this->_rs->Rewind(); } public function valid() { 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.60.0040.01116.88
8.3.50.0080.01221.99
8.3.40.0100.00318.92
8.3.30.0070.00719.21
8.3.20.0030.00620.20
8.3.10.0000.00821.76
8.3.00.0100.00317.75
8.2.180.0140.00716.88
8.2.170.0120.00322.96
8.2.160.0130.00022.13
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00419.66
8.2.110.0000.01119.18
8.2.100.0090.00317.50
8.2.90.0090.00019.22
8.2.80.0040.00417.97
8.2.70.0080.00017.50
8.2.60.0040.00418.05
8.2.50.0070.00718.07
8.2.40.0000.00718.15
8.2.30.0040.00418.00
8.2.20.0000.00817.76
8.2.10.0040.00418.15
8.2.00.0040.00417.79
8.1.280.0070.01125.92
8.1.270.0000.00824.66
8.1.260.0070.00026.35
8.1.250.0050.00228.09
8.1.240.0050.00522.01
8.1.230.0120.00017.42
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0090.00017.22
8.1.180.0060.00318.10
8.1.170.0030.00620.34
8.1.160.0080.00022.04
8.1.150.0000.00718.79
8.1.140.0000.00817.48
8.1.130.0000.00717.85
8.1.120.0080.00017.45
8.1.110.0040.00417.51
8.1.100.0030.00517.30
8.1.90.0030.00417.47
8.1.80.0070.00017.34
8.1.70.0000.00717.38
8.1.60.0040.00417.62
8.1.50.0030.00617.47
8.1.40.0040.00417.43
8.1.30.0040.00417.76
8.1.20.0030.00617.64
8.1.10.0000.00917.55
8.1.00.0120.00017.47
8.0.300.0030.00618.77
8.0.290.0000.00816.75
8.0.280.0060.00318.46
8.0.270.0000.00717.27
8.0.260.0060.00017.23
8.0.250.0000.00717.05
8.0.240.0000.00716.89
8.0.230.0000.00716.94
8.0.220.0030.00316.98
8.0.210.0000.00716.99
8.0.200.0000.00717.03
8.0.190.0040.00417.04
8.0.180.0030.00317.01
8.0.170.0080.00016.92
8.0.160.0040.00416.96
8.0.150.0000.00716.89
8.0.140.0000.00816.99
8.0.130.0030.00313.39
8.0.120.0040.00416.85
8.0.110.0070.00017.04
8.0.100.0080.00016.85
8.0.90.0070.00016.93
8.0.80.0060.01017.02
8.0.70.0040.00416.94
8.0.60.0000.00716.79
8.0.50.0000.00817.01
8.0.30.0110.01117.12
8.0.20.0080.01917.40
8.0.10.0000.00717.13
8.0.00.0080.01016.96
7.4.330.0000.00515.03
7.4.320.0050.00216.43
7.4.300.0040.00416.64
7.4.290.0030.00316.52
7.4.280.0020.00516.56
7.4.270.0030.00316.62
7.4.260.0000.00816.58
7.4.250.0000.00716.50
7.4.240.0040.00416.62
7.4.230.0000.00716.65
7.4.220.0060.01216.40
7.4.210.0110.00616.63
7.4.200.0030.00316.73
7.4.160.0080.00816.61
7.4.150.0210.00617.40
7.4.140.0140.01117.86
7.4.130.0050.01516.53
7.4.120.0130.00416.58
7.4.110.0130.01016.42
7.4.100.0080.01516.46
7.4.90.0070.01116.45
7.4.80.0140.00719.39
7.4.70.0160.00216.47
7.4.60.0100.00716.62
7.4.50.0080.00016.38
7.4.40.0100.00716.61
7.4.30.0130.00916.68
7.4.00.0030.01015.01
7.3.330.0000.00513.38
7.3.320.0110.00413.20
7.3.310.0030.00616.43
7.3.300.0000.00716.34
7.3.290.0000.00716.33
7.3.280.0100.00616.38
7.3.270.0030.01317.40
7.3.260.0060.01116.41
7.3.250.0090.01316.43
7.3.240.0060.01316.58
7.3.230.0100.00716.40
7.3.210.0110.00616.58
7.3.200.0160.00319.39
7.3.190.0110.00816.58
7.3.180.0150.00616.46
7.3.170.0150.00616.65
7.3.160.0120.00616.48
7.2.330.0130.00316.79
7.2.320.0030.01316.89
7.2.310.0070.01116.53
7.2.300.0090.00916.87
7.2.290.0080.01216.80
7.2.00.0000.01419.45
7.1.100.0000.01218.38
7.1.70.0030.00917.03
7.1.60.0100.01419.46
7.1.50.0230.01334.85
7.1.00.0100.07022.42
7.0.200.0090.00316.89
7.0.140.0000.04722.21
7.0.70.4500.03719.92
7.0.60.0030.07719.91
7.0.50.0030.08017.99
7.0.40.0070.08320.14
7.0.30.0330.06320.25
7.0.20.0370.07020.25
7.0.10.0170.04020.06
7.0.00.0100.08320.09
5.6.210.0030.08020.75
5.6.200.0100.06718.25
5.6.190.0100.07320.39
5.6.180.0300.05020.45
5.6.170.0270.07020.54
5.6.160.0000.04320.47
5.6.150.0130.06018.19
5.6.140.0100.07018.15
5.6.130.0070.04318.18
5.6.120.0100.08021.03
5.6.110.0170.07721.01
5.6.100.0100.08321.00
5.6.90.0000.06721.12
5.6.80.0170.04720.56
5.6.70.0230.04020.43
5.5.350.0030.08720.42
5.5.340.0070.04017.97
5.5.330.0030.05020.40
5.5.320.0030.07320.22
5.5.310.0200.03720.19
5.5.300.0070.08018.08
5.5.290.0070.04717.96
5.5.280.0000.07020.79
5.5.270.0000.08720.98
5.5.260.0130.07320.99
5.5.250.0030.04020.52
5.5.240.0200.06320.27
5.4.450.0130.05719.60
5.4.440.0870.06019.20
5.4.430.0170.05319.63
5.4.420.0900.06019.18
5.4.410.0870.05719.18
5.4.400.0100.05318.84
5.4.390.0100.06718.51
5.4.380.0130.06318.70
5.4.370.0230.04318.77
5.4.360.0230.04318.48
5.4.350.0130.05718.77
5.4.340.0130.05718.43
5.4.320.0030.06718.75
5.4.310.0170.05018.62
5.4.300.0130.05318.46
5.4.290.0170.06018.73
5.4.280.0130.05318.73
5.4.270.0170.05018.54
5.4.260.0170.05018.75
5.4.250.0130.05718.74
5.4.240.0130.06318.70
5.4.230.0100.05318.79
5.4.220.0170.05018.50
5.4.210.0300.03718.59
5.4.200.0130.05316.61
5.4.190.0100.05718.72
5.4.180.0100.05718.75
5.4.170.0130.05318.52
5.4.160.0170.05018.81
5.4.150.0200.05018.77
5.4.140.0200.05016.23
5.4.130.0130.04716.45
5.4.120.0070.05316.20
5.4.110.0170.04316.29
5.4.100.0130.05316.18
5.4.90.0130.05016.29
5.4.80.0200.04316.40
5.4.70.0100.05716.28
5.4.60.0100.05716.23
5.4.50.0130.04716.22
5.4.40.0070.06016.29
5.4.30.0200.05016.39
5.4.20.0130.07016.21
5.4.10.0200.06016.22
5.4.00.0170.04715.86
5.3.290.0170.05314.75
5.3.280.0070.05714.61
5.3.270.0200.05014.64
5.3.260.0070.06014.75
5.3.250.0300.04014.69
5.3.240.0130.05314.68
5.3.230.0170.05014.67
5.3.220.0130.05314.81
5.3.210.0170.05014.81
5.3.200.0170.05714.65
5.3.190.0200.05014.62
5.3.180.0230.05314.63
5.3.170.0100.05714.64
5.3.160.0130.05314.72
5.3.150.0100.06014.59
5.3.140.0130.05014.76
5.3.130.0200.07014.55
5.3.120.0230.06714.70
5.3.110.0070.06014.59
5.3.100.0100.05714.10
5.3.90.0170.05714.09
5.3.80.0230.06014.04
5.3.70.0130.05314.24
5.3.60.0130.06714.04
5.3.50.0200.06014.20
5.3.40.0170.04714.03
5.3.30.0130.05314.06
5.3.20.0130.05713.74
5.3.10.0100.05313.78
5.3.00.0100.05713.77
5.2.170.0230.04711.13
5.2.160.0030.05011.26
5.2.150.0170.04311.15
5.2.140.0100.04311.25
5.2.130.0070.04711.11
5.2.120.0170.03711.18
5.2.110.0070.04711.16
5.2.100.0230.04711.17
5.2.90.0200.03011.10
5.2.80.0200.03711.23
5.2.70.0100.04311.13
5.2.60.0070.04311.14
5.2.50.0070.04311.05
5.2.40.0030.04711.09
5.2.30.0130.04011.09
5.2.20.0100.04310.99
5.2.10.0170.03311.07
5.2.00.0100.04010.75
5.1.60.0100.03310.03
5.1.50.0070.04010.20
5.1.40.0100.03310.06
5.1.30.0100.03710.42
5.1.20.0070.04010.46
5.1.10.0170.03710.08
5.1.00.0070.04710.21
5.0.50.0130.0238.55
5.0.40.0100.0278.40
5.0.30.0030.0478.27
5.0.20.0070.0278.19
5.0.10.0100.0338.19
5.0.00.0000.0478.27
4.4.90.0030.0235.95
4.4.80.0070.0205.88
4.4.70.0030.0235.90
4.4.60.0070.0205.92
4.4.50.0100.0235.88
4.4.40.0030.0375.89
4.4.30.0030.0235.92
4.4.20.0030.0235.88
4.4.10.0030.0235.88
4.4.00.0000.0375.92
4.3.110.0030.0235.84
4.3.100.0100.0175.85
4.3.90.0070.0175.82
4.3.80.0030.0335.80
4.3.70.0100.0135.78
4.3.60.0030.0205.77
4.3.50.0070.0205.80
4.3.40.0000.0375.74
4.3.30.0000.0234.55
4.3.20.0030.0204.55
4.3.10.0070.0204.46
4.3.00.0000.0236.93

preferences:
34.43 ms | 401 KiB | 5 Q