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); 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.0100.01018.68
8.3.50.0100.00921.94
8.3.40.0040.01118.85
8.3.30.0030.01319.24
8.3.20.0000.00820.25
8.3.10.0040.00421.82
8.3.00.0090.00317.75
8.2.180.0180.00418.05
8.2.170.0040.01122.96
8.2.160.0150.00619.45
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0060.00319.77
8.2.110.0070.00319.30
8.2.100.0080.00317.75
8.2.90.0040.00419.14
8.2.80.0050.00317.97
8.2.70.0040.00417.50
8.2.60.0030.00518.05
8.2.50.0100.00318.07
8.2.40.0000.00718.32
8.2.30.0040.00418.07
8.2.20.0050.00317.78
8.2.10.0060.00318.04
8.2.00.0070.00017.79
8.1.280.0120.00325.92
8.1.270.0060.00318.83
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0000.00922.19
8.1.230.0000.01217.48
8.1.220.0050.00317.75
8.1.210.0000.00818.77
8.1.200.0060.00317.34
8.1.190.0050.00317.35
8.1.180.0070.00018.10
8.1.170.0080.00020.48
8.1.160.0050.00222.11
8.1.150.0000.00718.92
8.1.140.0000.00717.49
8.1.130.0030.00317.93
8.1.120.0000.00917.58
8.1.110.0040.00417.49
8.1.100.0000.00717.41
8.1.90.0000.00717.48
8.1.80.0070.00017.48
8.1.70.0000.00717.38
8.1.60.0040.00417.51
8.1.50.0080.00017.51
8.1.40.0040.00417.57
8.1.30.0080.00017.65
8.1.20.0000.00817.60
8.1.10.0000.00817.44
8.1.00.0080.00517.44
8.0.300.0050.00318.77
8.0.290.0040.00416.75
8.0.280.0000.00818.35
8.0.270.0000.00717.28
8.0.260.0000.00617.28
8.0.250.0030.00417.07
8.0.240.0030.00317.05
8.0.230.0030.00317.06
8.0.220.0030.00316.88
8.0.210.0000.00816.99
8.0.200.0000.00817.01
8.0.190.0080.00016.92
8.0.180.0070.00017.01
8.0.170.0050.00516.89
8.0.160.0000.00716.90
8.0.150.0050.00217.00
8.0.140.0040.00416.91
8.0.130.0000.00613.41
8.0.120.0090.00016.96
8.0.110.0050.00216.88
8.0.100.0070.00016.93
8.0.90.0000.00716.89
8.0.80.0040.01216.92
8.0.70.0080.00017.02
8.0.60.0070.00017.02
8.0.50.0000.00716.84
8.0.30.0120.01417.17
8.0.20.0140.01117.40
8.0.10.0070.00017.07
8.0.00.0090.00916.76
7.4.330.0030.00315.08
7.4.320.0060.00016.73
7.4.300.0000.00616.64
7.4.290.0030.00316.56
7.4.280.0080.00016.49
7.4.270.0040.00416.65
7.4.260.0030.00316.64
7.4.250.0080.00016.61
7.4.240.0020.00716.43
7.4.230.0080.00016.52
7.4.220.0060.01216.50
7.4.210.0100.00716.50
7.4.200.0030.00316.45
7.4.160.0150.00616.30
7.4.150.0080.01617.40
7.4.140.0100.00817.86
7.4.130.0080.00916.61
7.4.120.0120.00816.58
7.4.110.0200.00916.38
7.4.100.0140.00316.37
7.4.90.0060.01616.51
7.4.80.0000.01719.39
7.4.70.0070.01416.39
7.4.60.0100.00716.59
7.4.50.0000.00416.45
7.4.40.0090.01216.63
7.4.30.0160.00616.50
7.4.00.0050.00914.96
7.3.330.0060.00013.26
7.3.320.0050.01013.25
7.3.310.0000.00716.40
7.3.300.0070.00016.39
7.3.290.0030.00316.40
7.3.280.0080.00816.37
7.3.270.0090.01617.40
7.3.260.0070.01016.24
7.3.250.0050.01316.38
7.3.240.0090.01216.56
7.3.230.0030.01516.39
7.3.210.0000.01816.50
7.3.200.0100.01319.39
7.3.190.0100.00716.41
7.3.180.0130.00916.40
7.3.170.0130.00316.40
7.3.160.0140.00716.56
7.3.120.0030.01314.96
7.3.110.0060.01315.13
7.3.100.0090.00614.84
7.3.90.0030.00615.00
7.3.80.0070.01015.05
7.3.70.0000.00814.93
7.3.60.0040.01214.79
7.3.50.0100.00315.00
7.3.40.0000.01214.70
7.3.30.0060.00914.71
7.3.20.0060.00616.61
7.3.10.0080.00316.46
7.3.00.0050.00516.64
7.2.330.0110.00816.83
7.2.320.0130.00316.40
7.2.310.0090.00816.87
7.2.300.0070.01016.74
7.2.290.0130.00616.85
7.2.250.0040.01515.35
7.2.240.0060.01515.36
7.2.230.0000.01215.25
7.2.220.0030.00814.99
7.2.210.0100.00614.78
7.2.200.0040.00814.96
7.2.190.0040.01115.00
7.2.180.0030.00615.23
7.2.170.0070.00715.25
7.2.130.0060.00617.16
7.2.120.0030.00917.05
7.2.110.0080.00416.82
7.2.100.0090.00617.00
7.2.90.0040.01417.05
7.2.80.0060.00316.69
7.2.70.0040.00716.86
7.2.60.0050.00516.97
7.2.50.0000.00817.10
7.2.40.0040.00716.92
7.2.30.0070.00317.16
7.2.20.0060.00916.73
7.2.10.0000.01417.01
7.2.00.0110.00316.76
7.1.330.0030.01115.82
7.1.320.0090.00015.89
7.1.310.0030.00915.89
7.1.300.0040.01215.78
7.1.290.0030.00615.86
7.1.280.0080.00415.89
7.1.270.0090.00015.76
7.1.260.0110.00315.89
7.1.250.0070.00715.63
7.1.240.0030.00615.79
7.1.230.0040.01115.91
7.1.220.0040.00815.89
7.1.210.0060.00915.71
7.1.200.0030.00915.88
7.1.190.0060.00315.96
7.1.180.0070.00315.75
7.1.170.0070.00715.93
7.1.160.0000.01415.83
7.1.150.0030.01415.98
7.1.140.0030.01015.91
7.1.130.0070.00715.92
7.1.120.0030.01416.01
7.1.110.0000.01115.85
7.1.100.0070.00517.01
7.1.90.0070.00415.51
7.1.80.0070.00715.84
7.1.70.0040.00616.62
7.1.60.0060.00616.50
7.1.50.0090.01025.43
7.1.40.0030.00715.86
7.1.30.0040.01115.96
7.1.20.0060.00615.51
7.1.10.0080.00615.77
7.1.00.0070.04019.18
7.0.330.0070.00715.57
7.0.320.0040.00815.53
7.0.310.0050.00515.50
7.0.300.0050.00515.47
7.0.290.0000.01315.62
7.0.280.0000.01615.64
7.0.270.0070.00715.52
7.0.260.0110.00015.47
7.0.250.0030.00615.31
7.0.240.0030.00515.57
7.0.230.0100.00315.59
7.0.220.0060.00315.34
7.0.210.0090.00315.45
7.0.200.0050.01116.17
7.0.190.0030.00915.44
7.0.180.0070.00715.23
7.0.170.0110.00415.55
7.0.160.0120.00015.56
7.0.150.0080.00815.38
7.0.140.0030.02118.84
7.0.130.0000.01315.46
7.0.120.0030.01015.53
7.0.110.0070.01015.59
7.0.100.0030.01015.25
7.0.90.0060.00615.49
7.0.80.0110.00315.53
7.0.70.2270.01917.79
7.0.60.0130.03317.59
7.0.50.0050.04716.72
7.0.40.0070.04516.82
7.0.30.0160.04216.95
7.0.20.0120.03216.86
7.0.10.0160.02816.85
7.0.00.0110.02616.65
5.6.380.0070.00714.29
5.6.370.0050.00514.04
5.6.360.0070.00714.46
5.6.350.0030.00614.30
5.6.340.0100.00314.35
5.6.330.0030.00914.20
5.6.320.0070.00714.21
5.6.310.0040.00414.02
5.6.300.0000.01414.44
5.6.290.0040.01214.50
5.6.280.0040.04117.91
5.6.270.0080.00414.61
5.6.260.0030.01014.27
5.6.250.0040.00914.33
5.6.240.0120.00314.31
5.6.230.0090.00014.18
5.6.220.0040.00714.43
5.6.210.0020.04817.47
5.6.200.0070.02716.32
5.6.190.0050.04917.51
5.6.180.0200.03817.45
5.6.170.0230.04017.43
5.6.160.0050.02517.34
5.6.150.0070.04216.36
5.6.140.0060.03816.34
5.6.130.0080.02516.36
5.6.120.0040.04417.95
5.6.110.0030.04817.83
5.6.100.0090.04217.77
5.6.90.0070.04517.65
5.6.80.0020.04817.54
5.6.70.0220.03717.34
5.6.60.0000.01414.08
5.6.50.0120.00314.47
5.6.40.0060.00614.46
5.6.30.0090.00614.32
5.6.20.0100.00314.42
5.6.10.0060.00314.27
5.6.00.0130.00314.25
5.5.380.0040.00711.64
5.5.370.0060.00611.64
5.5.360.0060.00611.64
5.5.350.0070.03916.07
5.5.340.0070.04514.79
5.5.330.0070.04116.10
5.5.320.0040.02315.88
5.5.310.0200.02715.97
5.5.300.0050.02214.79
5.5.290.0080.04114.85
5.5.280.0030.02516.21
5.5.270.0090.02116.31
5.5.260.0040.04616.25
5.5.250.0070.02116.07
5.5.240.0070.04515.91
5.5.230.0040.00711.64
5.5.220.0030.01011.64
5.5.210.0030.00311.64
5.5.200.0030.00511.64
5.5.190.0060.00611.64
5.5.180.0090.00311.64
5.5.170.0030.00911.64
5.5.160.0090.00311.64
5.5.150.0030.00311.64
5.5.140.0060.00611.64
5.5.130.0070.00411.64
5.5.120.0040.00711.64
5.5.110.0060.00611.64
5.5.100.0030.00711.64
5.5.90.0040.00811.64
5.5.80.0060.00611.64
5.5.70.0000.00711.64
5.5.60.0000.00611.64
5.5.50.0000.01411.64
5.5.40.0030.00911.64
5.5.30.0070.00311.64
5.5.20.0040.00411.64
5.5.10.0100.00311.64
5.5.00.0060.00611.64
5.4.450.0020.02915.47
5.4.440.0030.03715.39
5.4.430.0850.03515.37
5.4.420.2240.02115.39
5.4.410.2330.02415.41
5.4.400.3030.01715.24
5.4.390.1950.02815.32
5.4.380.1600.02015.30
5.4.370.2020.02015.33
5.4.360.1880.02415.31
5.4.350.2280.02215.23
5.4.340.2270.02815.35
5.4.330.0070.00411.64
5.4.320.1800.02015.37
5.4.310.1630.02215.35
5.4.300.1880.02015.24
5.4.290.2010.01815.35
5.4.280.2000.02115.31
5.4.270.2130.02515.35
5.4.260.2100.02015.35
5.4.250.3000.02215.23
5.4.240.2000.02115.31
5.4.230.2160.02015.27
5.4.220.2000.02415.29
5.4.210.2420.01715.23
5.4.200.2400.02315.35
5.4.190.2130.01715.29
5.4.180.1850.02415.22
5.4.170.2000.01715.36
5.4.160.1350.02515.30
5.4.150.1080.02115.31
5.4.140.1650.02314.04
5.4.130.1690.02214.01
5.4.120.1570.02414.09
5.4.110.1660.02114.11
5.4.100.1280.02214.08
5.4.90.1430.01714.08
5.4.80.1300.02214.08
5.4.70.1870.02314.06
5.4.60.2130.01913.98
5.4.50.2450.01814.06
5.4.40.1980.02314.09
5.4.30.2380.02013.97
5.4.20.2380.02013.97
5.4.10.2020.02714.03
5.4.00.2310.02013.71
5.3.290.2030.02113.17
5.3.280.2340.02413.22
5.3.270.2000.02013.15
5.3.260.0830.02213.14
5.3.250.1450.02613.15
5.3.240.2100.02113.14
5.3.230.1400.02113.13
5.3.220.1610.02013.13
5.3.210.1660.02313.12
5.3.200.1640.02013.13
5.3.190.1420.02213.19
5.3.180.1450.02513.13
5.3.170.1650.01713.13
5.3.160.1930.02713.11
5.3.150.2310.02013.13
5.3.140.2960.02013.15
5.3.130.2070.01813.19
5.3.120.2060.02513.13
5.3.110.2200.02313.11
5.3.100.2720.02012.85
5.3.90.2010.02212.88
5.3.80.1750.02012.84
5.3.70.1950.01812.81
5.3.60.1830.01712.86
5.3.50.1930.02112.81
5.3.40.0050.02612.83
5.3.30.1050.03012.73
5.3.20.2370.01812.69
5.3.10.2460.01712.75
5.3.00.2410.01912.69
5.2.170.0950.01911.43
5.2.160.0050.02711.43
5.2.150.0020.02211.36
5.2.140.1820.01711.43
5.2.130.2080.01511.38
5.2.120.1880.01711.36
5.2.110.1870.01511.34
5.2.100.2030.01811.37
5.2.90.2050.01711.38
5.2.80.1950.01711.36
5.2.70.1610.01811.40
5.2.60.2000.02111.34
5.2.50.1700.01911.28
5.2.40.1670.01011.35
5.2.30.1470.01811.38
5.2.20.2050.02011.32
5.2.10.0150.02911.21
5.2.00.0010.03311.19
5.1.60.0020.02410.78
5.1.50.0010.02610.86
5.1.40.0080.01310.81
5.1.30.1570.01711.08
5.1.20.1360.01611.02
5.1.10.1450.01810.93
5.1.00.1610.01510.89
5.0.50.0950.01010.05
5.0.40.0920.01510.02
5.0.30.0900.0189.96
5.0.20.0780.0109.94
5.0.10.0920.0109.89
5.0.00.0900.0149.89
4.4.90.0750.0108.74
4.4.80.0750.0098.72
4.4.70.0570.0118.72
4.4.60.0720.0128.76
4.4.50.0770.0088.76
4.4.40.0060.0238.70
4.4.30.0000.0138.76
4.4.20.0600.0108.79
4.4.10.0880.0088.75
4.4.00.0770.0158.73
4.3.110.0750.0108.69
4.3.100.0880.0088.70
4.3.90.0820.0108.68
4.3.80.0820.0158.65
4.3.70.0630.0108.71
4.3.60.0620.0098.73
4.3.50.0650.0108.70
4.3.40.0730.0158.68
4.3.30.0450.0108.54
4.3.20.0430.0088.54
4.3.10.0450.0108.54
4.3.00.0480.0138.54

preferences:
36.38 ms | 401 KiB | 5 Q