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'), array('foo' => 'bar'), array('fizz' => 'buzz'), ); private $_i = 0; function FetchAssoc() { return isset($this->_records[$this->_i]) ? $this->_records[$this->_i++] : null; } function Rewind() { $this->_i = 0; } function NumRows() { return count($this->_records); } } 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->_rec = $this->_rs->FetchAssoc(); $this->_index++; } public function rewind() { $this->_index = 0; $this->_rs->Rewind(); $this->_rec = $this->_rs->FetchAssoc(); } public function valid() { return $this->_index < $this->_rs->NumRows(); } } $rs = new DBResult(); $it = new ResultIterator($rs, function($rec, $i) { return array($i, key($rec), $rec[key($rec)]); }); 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.0060.01418.55
8.3.50.0130.00621.97
8.3.40.0070.00718.98
8.3.30.0140.00719.27
8.3.20.0040.00420.24
8.3.10.0050.00321.86
8.3.00.0030.00917.75
8.2.180.0140.00718.42
8.2.170.0040.01122.96
8.2.160.0030.01022.09
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00419.76
8.2.110.0030.00721.03
8.2.100.0060.00617.84
8.2.90.0050.00319.21
8.2.80.0060.00317.97
8.2.70.0000.00817.63
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0040.00418.28
8.2.30.0080.00018.21
8.2.20.0080.00017.77
8.2.10.0000.00818.14
8.2.00.0000.00817.80
8.1.280.0110.00325.92
8.1.270.0040.00418.83
8.1.260.0030.00526.35
8.1.250.0080.00028.09
8.1.240.0070.01422.67
8.1.230.0040.00719.04
8.1.220.0050.00317.79
8.1.210.0000.00918.77
8.1.200.0030.00717.25
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0040.00420.38
8.1.160.0000.00821.93
8.1.150.0000.00718.98
8.1.140.0070.00017.48
8.1.130.0040.00417.74
8.1.120.0000.00717.57
8.1.110.0000.00817.46
8.1.100.0000.00717.38
8.1.90.0000.00717.54
8.1.80.0040.00417.54
8.1.70.0000.00717.48
8.1.60.0060.00317.65
8.1.50.0000.00717.55
8.1.40.0060.00317.58
8.1.30.0090.00017.69
8.1.20.0040.00417.62
8.1.10.0050.00317.55
8.1.00.0060.00917.54
8.0.300.0040.00418.77
8.0.290.0080.00016.75
8.0.280.0000.00718.43
8.0.270.0000.00717.32
8.0.260.0060.00017.32
8.0.250.0000.00717.04
8.0.240.0000.00717.01
8.0.230.0070.00016.99
8.0.220.0070.00017.01
8.0.210.0040.00416.99
8.0.200.0030.00317.05
8.0.190.0000.00817.08
8.0.180.0070.00017.04
8.0.170.0050.00316.93
8.0.160.0070.00017.05
8.0.150.0030.00316.83
8.0.140.0030.00516.89
8.0.130.0000.00613.38
8.0.120.0050.00316.85
8.0.110.0040.00416.88
8.0.100.0070.00016.79
8.0.90.0040.00417.01
8.0.80.0030.01316.93
8.0.70.0070.00017.01
8.0.60.0030.00516.92
8.0.50.0030.00516.81
8.0.30.0070.01617.25
8.0.20.0110.01317.40
8.0.10.0040.00417.09
8.0.00.0070.01016.83
7.4.330.0000.00515.10
7.4.320.0000.00616.53
7.4.300.0030.00316.68
7.4.290.0070.00016.56
7.4.280.0000.00816.57
7.4.270.0000.00716.55
7.4.260.0030.00316.59
7.4.250.0070.00016.53
7.4.240.0020.00516.51
7.4.230.0040.00416.64
7.4.220.0120.00616.59
7.4.210.0120.00516.68
7.4.200.0000.00716.40
7.4.160.0110.01116.61
7.4.150.0220.00417.40
7.4.140.0170.00517.86
7.4.130.0100.00716.59
7.4.120.0130.00516.54
7.4.110.0080.01216.57
7.4.100.0040.01416.54
7.4.90.0070.01016.73
7.4.80.0070.01319.39
7.4.70.0070.01416.43
7.4.60.0030.01516.46
7.4.50.0020.00216.57
7.4.40.0120.00916.64
7.4.30.0110.01016.60
7.4.00.0000.01414.80
7.3.330.0030.00313.45
7.3.320.0070.00713.40
7.3.310.0000.00716.42
7.3.300.0070.00016.32
7.3.290.0030.00316.26
7.3.280.0040.01116.41
7.3.270.0130.00917.40
7.3.260.0100.00716.33
7.3.250.0120.00616.52
7.3.240.0040.01816.53
7.3.230.0130.01016.65
7.3.210.0130.00616.58
7.3.200.0160.00619.39
7.3.190.0130.00316.46
7.3.180.0070.01416.48
7.3.170.0090.00816.53
7.3.160.0080.01116.44
7.3.10.0040.01116.75
7.3.00.0040.00716.59
7.2.330.0090.00916.75
7.2.320.0050.01116.74
7.2.310.0090.00616.76
7.2.300.0060.01216.45
7.2.290.0130.01016.81
7.2.130.0090.00616.80
7.2.120.0100.00717.02
7.2.110.0040.01216.95
7.2.100.0080.00417.07
7.2.90.0080.00617.05
7.2.80.0100.00316.79
7.2.70.0030.00617.06
7.2.60.0040.01516.89
7.2.50.0060.00917.16
7.2.40.0000.01116.88
7.2.30.0090.00617.16
7.2.20.0070.00716.76
7.2.10.0060.00616.99
7.2.00.0070.00918.28
7.1.250.0030.00615.91
7.1.200.0000.01415.44
7.1.100.0000.01218.04
7.1.70.0000.00717.09
7.1.60.0100.01019.46
7.1.50.0270.00734.90
7.1.00.0100.07022.36
7.0.200.0120.00016.85
7.0.140.0030.05722.18
7.0.70.4700.02719.95
7.0.60.0130.04320.11
7.0.50.0030.04717.95
7.0.40.0030.09320.21
7.0.30.0200.04320.09
7.0.20.0330.06320.15
7.0.10.0170.04020.08
7.0.00.0100.08720.08
5.6.280.0030.07321.12
5.6.210.0070.07720.66
5.6.200.0100.07718.22
5.6.190.0070.05320.57
5.6.180.0270.07720.53
5.6.170.0270.07020.51
5.6.160.0070.03720.39
5.6.150.0000.05318.25
5.6.140.0130.04718.24
5.6.130.0000.08018.11
5.6.120.0070.07721.05
5.6.110.0100.07721.00
5.6.100.0130.07721.02
5.6.90.0130.07720.98
5.6.80.0030.05020.54
5.6.70.0130.05720.46
5.5.350.0070.08720.38
5.5.340.0100.08018.09
5.5.330.0030.04320.47
5.5.320.0070.07320.29
5.5.310.0200.03720.32
5.5.300.0030.07317.94
5.5.290.0030.08718.08
5.5.280.0130.05320.83
5.5.270.0100.06320.87
5.5.260.0070.04020.78
5.5.250.0070.04020.48
5.5.240.0030.08720.18
5.4.450.0200.07019.58
5.4.440.0930.05019.46
5.4.430.0100.05319.47
5.4.420.0700.04319.54
5.4.410.1170.06719.26
5.4.400.0930.05318.83
5.4.390.1000.05018.72
5.4.380.0770.05718.60
5.4.370.0830.04718.60
5.4.360.0800.05018.80
5.4.350.0900.05318.82
5.4.340.1000.05718.76
5.4.320.0770.06018.54
5.4.310.0970.04718.49
5.4.300.1130.06018.54
5.4.290.0970.05018.58
5.4.280.0900.05318.49
5.4.270.1170.05018.76
5.4.260.1070.06318.58
5.4.250.0970.05018.54
5.4.240.0730.06018.79
5.4.230.0730.05718.75
5.4.220.0770.05718.59
5.4.210.0830.05318.73
5.4.200.0930.05016.70
5.4.190.0900.07018.82
5.4.180.0870.05718.74
5.4.170.1030.05718.50
5.4.160.1000.04318.62
5.4.150.0900.05718.73
5.4.140.0800.05316.32
5.4.130.0800.05316.37
5.4.120.0830.04716.31
5.4.110.0970.07016.25
5.4.100.1070.06316.23
5.4.90.1030.04016.35
5.4.80.1030.04316.25
5.4.70.0930.06016.20
5.4.60.0800.06016.29
5.4.50.0870.05316.25
5.4.40.0930.05016.28
5.4.30.0930.04716.40
5.4.20.0970.04316.40
5.4.10.0870.05316.20
5.4.00.1030.05015.70
5.3.290.0970.05714.88
5.3.280.0830.06314.80
5.3.270.0870.05014.77
5.3.260.0870.05314.70
5.3.250.0800.05314.66
5.3.240.0930.05014.80
5.3.230.0970.04314.85
5.3.220.0870.05314.65
5.3.210.0930.05314.58
5.3.200.0870.04314.64
5.3.190.0730.05714.82
5.3.180.0770.05014.65
5.3.170.0830.04714.59
5.3.160.0830.05314.70
5.3.150.0970.04714.70
5.3.140.0800.05014.63
5.3.130.0770.05314.61
5.3.120.0830.05014.75
5.3.110.0600.07014.59
5.3.100.0730.06014.22
5.3.90.1000.03314.27
5.3.80.0300.05014.14
5.3.70.0200.05014.13
5.3.60.0270.05314.08
5.3.50.0200.04314.09
5.3.40.0130.05013.98
5.3.30.0170.05013.99
5.3.20.0230.04013.84
5.3.10.0130.05713.74
5.3.00.0170.05013.74
5.2.170.0100.04311.37
5.2.160.0170.03711.21
5.2.150.0170.03711.27
5.2.140.0030.05311.26
5.2.130.0100.04311.32
5.2.120.0070.04711.24
5.2.110.0100.04011.11
5.2.100.0170.03311.10
5.2.90.0030.04711.22
5.2.80.0030.05311.11
5.2.70.0130.04011.09
5.2.60.0170.03311.09
5.2.50.0130.04011.07
5.2.40.0100.03711.13
5.2.30.0070.04311.03
5.2.20.0230.02711.10
5.2.10.0070.04710.86
5.2.00.0270.02710.78
5.1.60.0070.03310.05
5.1.50.0100.03310.04
5.1.40.0170.0339.98
5.1.30.0070.04010.40
5.1.20.0070.04010.47
5.1.10.0170.03010.20
5.1.00.0030.05010.27
5.0.50.0030.0338.66
5.0.40.0030.0308.63
5.0.30.0000.0538.36
5.0.20.0100.0278.24
5.0.10.0070.0278.24
5.0.00.0100.0378.22
4.4.90.0030.0235.83
4.4.80.0070.0205.91
4.4.70.0030.0235.90
4.4.60.0070.0205.80
4.4.50.0070.0205.93
4.4.40.0070.0335.88
4.4.30.0070.0205.88
4.4.20.0070.0205.95
4.4.10.0030.0235.96
4.4.00.0100.0305.93
4.3.110.0070.0205.83
4.3.100.0070.0205.75
4.3.90.0070.0175.82
4.3.80.0030.0375.77
4.3.70.0000.0235.78
4.3.60.0100.0175.91
4.3.50.0030.0235.82
4.3.40.0070.0305.74
4.3.30.0000.0274.63
4.3.20.0000.0234.62
4.3.10.0030.0204.52
4.3.00.0030.0236.93

preferences:
36.99 ms | 401 KiB | 5 Q