3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Connection { public function query() { return new Result(); } } class Result implements \IteratorAggregate { private $rows; public function __construct() { $this->rows = new \ArrayObject([ [0, 1, 2], [3, 4, 5], [6, 7, 8], ]); } public function getIterator() { return $this->rows->getIterator(); } } $conn = new Connection(); // Here $result holds an instance of "Result" // *** THIS IS YOUR CASE 2 *** $result = $conn->query(); var_dump($result); // "Result" is iterable, so we can do like this foreach($result as $row) { var_dump($row); } // Or we can skip the intermediate variable and loop over the result immediately. // *** THIS IS YOUR CASE 1 *** foreach($conn->query() as $row) { var_dump($row); }

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.0070.01118.39
8.3.50.0090.01221.99
8.3.40.0070.01118.59
8.3.30.0040.01118.71
8.3.20.0040.00420.91
8.3.10.0030.00621.73
8.3.00.0080.00019.43
8.2.180.0150.00018.66
8.2.170.0110.00422.96
8.2.160.0070.01120.39
8.2.150.0050.00325.66
8.2.140.0040.00424.66
8.2.130.0080.00019.22
8.2.120.0040.00426.35
8.2.110.0000.00920.93
8.2.100.0080.00317.78
8.2.90.0060.00319.08
8.2.80.0030.00519.36
8.2.70.0030.00617.50
8.2.60.0080.00018.05
8.2.50.0040.00418.10
8.2.40.0000.00820.19
8.2.30.0030.00521.13
8.2.20.0000.00817.94
8.2.10.0030.00517.97
8.2.00.0040.00417.73
8.1.280.0040.01225.92
8.1.270.0040.00423.99
8.1.260.0050.00226.35
8.1.250.0040.00428.09
8.1.240.0060.00320.64
8.1.230.0100.00020.31
8.1.220.0050.00317.74
8.1.210.0050.00318.77
8.1.200.0090.00017.35
8.1.190.0060.00317.48
8.1.180.0090.00018.10
8.1.170.0040.00418.36
8.1.160.0050.00318.84
8.1.150.0070.00020.14
8.1.140.0000.00719.45
8.1.130.0070.00017.41
8.1.120.0000.00717.36
8.1.110.0050.00317.33
8.1.100.0070.00017.36
8.1.90.0000.00817.46
8.1.80.0030.00517.32
8.1.70.0040.00417.38
8.1.60.0000.00817.57
8.1.50.0080.00017.55
8.1.40.0000.00817.43
8.1.30.0000.00917.57
8.1.20.0030.00617.63
8.1.10.0040.00417.59
8.1.00.0050.00317.52
8.0.300.0070.00018.77
8.0.290.0000.00716.75
8.0.280.0000.00718.37
8.0.270.0030.00317.18
8.0.260.0070.00016.81
8.0.250.0080.00016.98
8.0.240.0040.00416.95
8.0.230.0000.00716.96
8.0.220.0070.00016.95
8.0.210.0030.00316.82
8.0.200.0030.00316.88
8.0.190.0000.00816.95
8.0.180.0000.00716.88
8.0.170.0040.00416.95
8.0.160.0040.00416.91
8.0.150.0000.00716.85
8.0.140.0000.00816.83
8.0.130.0000.00813.25
8.0.120.0030.00516.90
8.0.110.0040.00416.94
8.0.100.0030.00516.71
8.0.90.0050.00216.93
8.0.80.0040.01116.93
8.0.70.0000.00816.68
8.0.60.0040.00416.69
8.0.50.0000.00816.88
8.0.30.0110.00816.91
8.0.20.0110.00917.40
8.0.10.0080.00017.05
8.0.00.0070.01016.79
7.4.330.0000.00515.55
7.4.320.0030.00316.60
7.4.300.0000.00616.49
7.4.290.0050.00316.38
7.4.280.0030.00516.61
7.4.270.0060.00316.50
7.4.260.0070.00016.53
7.4.250.0070.00016.48
7.4.240.0040.00416.48
7.4.230.0070.00016.40
7.4.220.0130.00916.45
7.4.210.0100.00716.63
7.4.200.0040.00416.63
7.4.160.0160.00216.46
7.4.150.0060.01517.40
7.4.140.0120.00817.86
7.4.130.0080.01316.54
7.4.120.0080.01216.45
7.4.110.0030.01316.29
7.4.100.0100.00716.60
7.4.90.0100.00716.56
7.4.80.0130.01019.39
7.4.70.0100.00716.51
7.4.60.0140.00716.46
7.4.50.0110.00416.50
7.4.40.0110.01116.36
7.4.30.0070.01016.52
7.4.10.0090.00915.06
7.4.00.0030.01515.04
7.3.330.0030.00313.29
7.3.320.0000.00613.16
7.3.310.0030.00616.30
7.3.300.0030.00316.14
7.3.290.0070.00016.34
7.3.280.0070.00916.27
7.3.270.0070.01117.40
7.3.260.0130.00816.33
7.3.250.0070.01016.43
7.3.240.0130.00516.31
7.3.230.0120.00916.63
7.3.210.0030.02016.50
7.3.200.0080.00816.36
7.3.190.0160.00016.56
7.3.180.0150.00416.57
7.3.170.0100.00616.59
7.3.160.0130.00616.65
7.3.130.0030.01714.38
7.3.120.0050.01414.69
7.3.110.0090.01114.77
7.3.100.0030.01214.71
7.3.90.0050.00914.88
7.3.80.0040.01115.02
7.3.70.0030.01214.91
7.3.60.0050.00714.99
7.3.50.0080.00714.89
7.3.40.0050.00914.91
7.3.30.0000.01214.75
7.3.20.0060.00816.83
7.3.10.0050.00616.74
7.3.00.0080.00716.74
7.2.330.0170.00616.61
7.2.320.0180.00616.72
7.2.310.0190.00316.77
7.2.300.0150.00916.49
7.2.290.0080.01116.69
7.2.260.0100.01015.27
7.2.250.0080.01115.04
7.2.240.0070.00714.98
7.2.230.0030.01215.25
7.2.220.0070.00815.21
7.2.210.0030.01215.15
7.2.200.0070.00615.10
7.2.190.0050.01014.97
7.2.180.0030.00815.04
7.2.170.0070.01014.93
7.2.160.0030.01014.93
7.2.150.0030.00916.93
7.2.140.0030.00617.02
7.2.130.0000.01017.04
7.2.120.0000.01116.95
7.2.110.0000.01317.07
7.2.100.0130.00017.11
7.2.90.0000.01817.04
7.2.80.0090.00916.98
7.2.70.0150.00316.99
7.2.60.0080.00817.09
7.2.50.0100.00716.96
7.2.40.0090.01017.08
7.2.30.0070.00717.13
7.2.20.0070.00717.09
7.2.10.0090.00617.09
7.2.00.0040.01217.11
7.1.330.0090.00515.71
7.1.320.0050.00915.81
7.1.310.0060.00815.68
7.1.300.0060.00815.56
7.1.290.0030.00815.55
7.1.280.0100.00415.78
7.1.270.0020.01215.66
7.1.260.0040.00815.67
7.1.250.0130.00715.77
7.1.240.0030.00915.58
7.1.230.0040.00415.89
7.1.220.0030.00615.82
7.1.210.0030.01315.70
7.1.200.0060.00715.78
7.1.190.0070.00715.68
7.1.180.0070.00715.65
7.1.170.0030.01315.80
7.1.160.0100.00315.45
7.1.150.0040.01115.79
7.1.140.0130.00015.86
7.1.130.0000.01015.68
7.1.120.0070.00715.77
7.1.110.0050.00515.43
7.1.100.0000.01016.02
7.1.90.0030.01015.72
7.1.80.0030.01015.84
7.1.70.0060.00716.55
7.1.60.0060.01316.54
7.1.50.0060.00315.75
7.1.40.0070.00315.86
7.1.30.0080.00315.80
7.1.20.0000.00815.76
7.1.10.0080.00315.63
7.1.00.0050.03419.18
7.0.330.0100.00715.20
7.0.320.0050.00515.42
7.0.310.0030.01415.10
7.0.300.0100.00315.63
7.0.290.0040.00415.62
7.0.280.0060.00315.53
7.0.270.0070.00415.49
7.0.260.0030.00715.13
7.0.250.0030.00615.57
7.0.240.0070.00415.23
7.0.230.0070.00715.45
7.0.220.0030.01015.39
7.0.210.0030.00915.29
7.0.200.0020.00916.00
7.0.190.0000.01115.48
7.0.180.0060.01015.11
7.0.170.0040.00415.21
7.0.160.0070.01015.58
7.0.150.0030.01015.46
7.0.140.0100.02818.77
7.0.130.0070.03018.81
7.0.120.0070.02818.74
7.0.110.0050.03518.82
7.0.100.0130.03718.74
7.0.90.0080.03118.71
7.0.80.0070.03218.74
7.0.70.0080.03018.88
7.0.60.0050.03118.79
7.0.50.0040.03318.81
7.0.40.0030.03517.74
7.0.30.0120.03817.79
7.0.20.0070.04317.85
7.0.10.0100.03017.73
7.0.00.0110.02917.76
5.6.400.0030.01014.48
5.6.390.0100.01014.55
5.6.380.0140.00314.53
5.6.370.0090.00914.58
5.6.360.0120.00014.18
5.6.350.0070.00414.49
5.6.340.0060.00914.39
5.6.330.0030.00714.39
5.6.320.0070.00714.30
5.6.310.0110.00314.49
5.6.300.0070.01114.30
5.6.290.0090.03317.69
5.6.280.0050.03617.63
5.6.270.0020.03717.71
5.6.260.0120.02517.68
5.6.250.0080.03217.60
5.6.240.0060.03617.65
5.6.230.0080.03417.67
5.6.220.0020.03717.72
5.6.210.0080.03017.58
5.6.200.0050.03317.57
5.6.190.0070.03717.69
5.6.180.0120.02417.78
5.6.170.0100.03017.63
5.6.160.0030.03417.65
5.6.150.0050.03417.70
5.6.140.0050.04017.46
5.6.130.0090.03017.42
5.6.120.0030.03617.68
5.6.110.0100.03017.60
5.6.100.0020.03617.67
5.6.90.0050.03217.56
5.6.80.0050.04217.33
5.6.70.0070.03017.27
5.6.60.0030.03317.33
5.6.50.0120.03717.25
5.6.40.0050.03517.28
5.6.30.0120.02817.40
5.6.20.0030.03517.31
5.6.10.0050.03217.27
5.6.00.0020.03517.42

preferences:
33.43 ms | 401 KiB | 5 Q