3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface IDBResult { function FetchAssoc(); function Rewind(); function NumRows(); } 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; } function NumRows() { return count($this->_records); } } class ResultIterator implements Iterator { private $_rs; private $_rec = false; 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 $this->_index < $this->_rs->NumRows(); } } $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.0130.00716.61
8.3.50.0310.00522.13
8.3.40.0090.00619.02
8.3.30.0130.00619.22
8.3.20.0070.00020.16
8.3.10.0030.00521.67
8.3.00.0080.00417.75
8.2.180.0110.01118.66
8.2.170.0070.00722.96
8.2.160.0030.01022.26
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0080.00019.76
8.2.110.0030.00619.14
8.2.100.0000.01117.63
8.2.90.0030.00519.17
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0040.00418.03
8.2.50.0030.00618.07
8.2.40.0050.00318.32
8.2.30.0040.00418.11
8.2.20.0000.00817.88
8.2.10.0030.00518.17
8.2.00.0030.00517.74
8.1.280.0120.01225.92
8.1.270.0060.00318.75
8.1.260.0070.00026.35
8.1.250.0030.00628.09
8.1.240.0110.00022.19
8.1.230.0080.00317.48
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0040.00417.48
8.1.190.0030.00517.23
8.1.180.0000.00918.10
8.1.170.0030.00620.44
8.1.160.0070.00022.05
8.1.150.0070.00018.81
8.1.140.0070.00017.42
8.1.130.0030.00317.91
8.1.120.0000.00717.38
8.1.110.0080.00017.49
8.1.100.0070.00017.51
8.1.90.0040.00417.39
8.1.80.0000.00717.41
8.1.70.0030.00317.51
8.1.60.0030.00617.52
8.1.50.0080.00017.53
8.1.40.0030.00617.52
8.1.30.0060.00317.72
8.1.20.0030.00617.76
8.1.10.0000.00817.48
8.1.00.0080.00317.60
8.0.300.0040.00418.77
8.0.290.0060.00316.75
8.0.280.0000.00818.39
8.0.270.0050.00317.23
8.0.260.0030.00317.18
8.0.250.0070.00017.06
8.0.240.0000.00717.00
8.0.230.0000.00717.06
8.0.220.0000.00716.96
8.0.210.0000.00716.95
8.0.200.0000.00717.03
8.0.190.0030.00516.94
8.0.180.0000.00717.02
8.0.170.0030.00616.98
8.0.160.0000.00817.10
8.0.150.0040.00417.05
8.0.140.0000.00716.96
8.0.130.0030.00313.43
8.0.120.0080.00016.85
8.0.110.0000.00817.00
8.0.100.0070.00017.10
8.0.90.0040.00417.10
8.0.80.0140.00317.04
8.0.70.0040.00416.87
8.0.60.0000.00816.98
8.0.50.0040.00416.97
8.0.30.0160.00717.10
8.0.20.0160.01317.41
8.0.10.0040.00416.94
8.0.00.0120.00616.90
7.4.330.0030.00215.03
7.4.320.0000.00616.58
7.4.300.0030.00316.67
7.4.290.0000.00716.54
7.4.280.0040.00416.58
7.4.270.0040.00416.62
7.4.260.0030.00316.57
7.4.250.0040.00416.48
7.4.240.0000.00716.66
7.4.230.0030.00516.70
7.4.220.0110.00716.50
7.4.210.0070.00916.55
7.4.200.0000.00716.52
7.4.160.0040.01316.52
7.4.150.0100.01617.40
7.4.140.0140.00817.86
7.4.130.0110.00616.54
7.4.120.0090.01116.54
7.4.110.0160.00716.55
7.4.100.0000.01716.38
7.4.90.0070.01016.41
7.4.80.0120.00619.39
7.4.70.0160.00416.54
7.4.60.0070.01116.33
7.4.50.0050.00016.38
7.4.40.0030.01316.52
7.4.30.0120.00616.55
7.4.00.0100.00614.89
7.3.330.0030.00313.25
7.3.320.0070.00813.17
7.3.310.0070.00016.25
7.3.300.0040.00416.39
7.3.290.0070.00016.25
7.3.280.0080.00916.32
7.3.270.0130.00717.40
7.3.260.0140.00316.44
7.3.250.0140.00716.57
7.3.240.0030.01316.42
7.3.230.0210.00316.39
7.3.210.0060.01316.60
7.3.200.0130.01019.39
7.3.190.0060.01116.78
7.3.180.0110.00816.55
7.3.170.0180.00016.51
7.3.160.0120.01216.59
7.2.330.0100.01016.65
7.2.320.0100.00716.87
7.2.310.0120.00616.65
7.2.300.0070.01116.38
7.2.290.0110.01416.72
7.2.00.0030.01019.51
7.1.100.0040.00418.18
7.1.70.0000.01017.18
7.1.60.0070.01619.46
7.1.50.0150.00934.97
7.1.00.0100.07022.31
7.0.200.0030.00716.62
7.0.140.0000.06322.00
7.0.70.4270.05020.00
7.0.60.0100.07720.05
7.0.50.0070.05017.93
7.0.40.0070.05020.39
7.0.30.0230.07020.14
7.0.20.0370.07320.19
7.0.10.0100.04720.08
7.0.00.0130.05020.33
5.6.280.0000.07720.84
5.6.210.0100.06720.75
5.6.200.0000.08318.29
5.6.190.0130.08020.47
5.6.180.0270.08020.46
5.6.170.0270.05020.43
5.6.160.0070.03720.45
5.6.150.0130.07018.27
5.6.140.0100.08018.13
5.6.130.0070.07318.15
5.6.120.0130.07721.05
5.6.110.0070.08721.16
5.6.100.0100.08021.13
5.6.90.0170.06321.12
5.6.80.0100.05720.31
5.6.70.3770.03320.38
5.5.350.0070.08320.40
5.5.340.0070.07017.99
5.5.330.0070.04020.13
5.5.320.0030.08720.32
5.5.310.0100.04320.32
5.5.300.0030.04017.98
5.5.290.0030.09018.04
5.5.280.0130.06320.82
5.5.270.0100.06020.98
5.5.260.0030.06720.70
5.5.250.0070.03720.68
5.5.240.0070.08320.16
5.4.450.0300.06719.31
5.4.440.0800.06019.45
5.4.430.1030.05019.58
5.4.420.0130.05719.58
5.4.410.0930.06019.45
5.4.400.0200.04718.84
5.4.390.0130.06318.60
5.4.380.0100.06018.78
5.4.370.0170.05318.48
5.4.360.0170.05718.75
5.4.350.0170.07718.59
5.4.340.0270.06318.77
5.4.320.0200.05018.55
5.4.310.0200.07718.76
5.4.300.0070.06718.76
5.4.290.0200.05018.78
5.4.280.0200.05018.59
5.4.270.0170.06318.59
5.4.260.0030.06318.79
5.4.250.0200.05318.62
5.4.240.0200.05018.71
5.4.230.0200.06018.64
5.4.220.0130.06018.73
5.4.210.0230.04718.75
5.4.200.0170.05316.61
5.4.190.0170.04718.59
5.4.180.0070.06018.75
5.4.170.0200.05018.76
5.4.160.0170.04718.74
5.4.150.0100.05718.81
5.4.140.0170.05016.32
5.4.130.0100.05016.34
5.4.120.0100.05016.29
5.4.110.0100.05016.35
5.4.100.0130.05016.35
5.4.90.0130.05316.27
5.4.80.0130.05016.20
5.4.70.0130.05016.43
5.4.60.0070.06016.20
5.4.50.0130.04716.22
5.4.40.0000.06316.20
5.4.30.0130.05016.27
5.4.20.0130.05316.39
5.4.10.0100.05716.26
5.4.00.0200.06015.76
5.3.290.0170.05314.80
5.3.280.0130.05014.85
5.3.270.0200.05014.63
5.3.260.0200.05714.81
5.3.250.0100.05314.73
5.3.240.0200.06714.68
5.3.230.0070.06314.83
5.3.220.0070.06014.63
5.3.210.0200.06314.59
5.3.200.0170.04714.65
5.3.190.0130.05314.73
5.3.180.0070.05714.77
5.3.170.0130.05014.57
5.3.160.0230.04314.69
5.3.150.0100.05314.64
5.3.140.0270.04714.73
5.3.130.0170.05014.63
5.3.120.0200.05314.67
5.3.110.0100.05714.68
5.3.100.0170.05014.24
5.3.90.0200.04314.10
5.3.80.0170.05014.09
5.3.70.0130.05014.09
5.3.60.0030.06014.16
5.3.50.0200.04314.09
5.3.40.0230.04714.08
5.3.30.0100.05014.00
5.3.20.0230.06013.84
5.3.10.0070.05313.85
5.3.00.0200.04313.73
5.2.170.0070.04711.27
5.2.160.0100.04011.36
5.2.150.0100.04711.18
5.2.140.0130.04011.27
5.2.130.0200.03311.18
5.2.120.0100.04011.09
5.2.110.0130.03711.32
5.2.100.0130.03711.19
5.2.90.0130.03711.19
5.2.80.0130.04011.34
5.2.70.0130.05311.09
5.2.60.0030.05011.10
5.2.50.0170.05311.13
5.2.40.0100.04311.11
5.2.30.0200.03011.05
5.2.20.0070.04311.00
5.2.10.0070.04310.97
5.2.00.0170.03310.75
5.1.60.0130.03010.00
5.1.50.0100.03310.02
5.1.40.0070.0409.99
5.1.30.0130.03310.44
5.1.20.0030.04010.36
5.1.10.0100.03310.09
5.1.00.0200.02710.08
5.0.50.0100.0278.76
5.0.40.0100.0238.62
5.0.30.0100.0408.22
5.0.20.0030.0308.30
5.0.10.0070.0278.18
5.0.00.0070.0408.37
4.4.90.0070.0205.87
4.4.80.0070.0205.86
4.4.70.0030.0235.84
4.4.60.0030.0235.90
4.4.50.0070.0205.89
4.4.40.0070.0335.94
4.4.30.0030.0235.85
4.4.20.0130.0135.94
4.4.10.0130.0236.00
4.4.00.0030.0375.84
4.3.110.0070.0205.88
4.3.100.0030.0275.83
4.3.90.0030.0205.86
4.3.80.0100.0275.78
4.3.70.0000.0235.89
4.3.60.0030.0205.79
4.3.50.0030.0275.77
4.3.40.0030.0335.77
4.3.30.0000.0234.55
4.3.20.0000.0234.57
4.3.10.0030.0204.49
4.3.00.0000.0236.93

preferences:
46.49 ms | 401 KiB | 5 Q