3v4l.org

run code in 300+ PHP versions simultaneously
<?php function iterateOverIt($iterable) { // First foreach acts like a guard condition foreach ($iterable as $_) { // Pre-processing: echo "<ul>\n"; // Real looping, this won't start a *NEW* iteration process but will continue the one started above: foreach ($iterable as $item) { echo "<li>", $item instanceof DateTime ? $item->format("c") : ( isset($item["col"]) ? $item["col"] : $item ), "</li>\n"; } // Post-processing: echo "</ul>\n"; break; } } // Empty array iterateOverIt([]); iterateOverIt([1, 2, 3]); // Empty generator iterateOverIt(function () : Generator { return; yield; }); iterateOverIt((function () : Generator { yield 4; yield 5; yield 6; })()); // Class with no public properties iterateOverIt(new stdClass()); iterateOverIt(new class { public $a = 7, $b = 8, $c = 9;}); /* $db = mysqli_connect("localhost", "user", "pass", "db"); // Empty resultset iterateOverIt($db->query("SELECT 0 FROM DUAL WHERE false")); iterateOverIt($db->query("SELECT 10 AS col UNION SELECT 11 UNION SELECT 12")); */ // DatePeriod generating no dates iterateOverIt(new DatePeriod(new DateTime("2020-01-01 00:00:00"), new DateInterval("P1D"), new DateTime("2020-01-01 00:00:00"), DatePeriod::EXCLUDE_START_DATE)); iterateOverIt(new DatePeriod(new DateTime("2020-01-01 00:00:00"), new DateInterval("P1D"), 3, DatePeriod::EXCLUDE_START_DATE));

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.120.0030.00618.73
8.3.110.0050.00520.94
8.3.100.0080.01124.06
8.3.90.0100.01026.77
8.3.80.0050.00516.88
8.3.70.0030.01316.75
8.3.60.0030.01216.75
8.3.50.0100.00423.59
8.3.40.0110.00718.72
8.3.30.0000.01618.92
8.3.20.0040.00420.90
8.3.10.0040.00422.03
8.3.00.0080.00020.64
8.2.240.0060.00317.09
8.2.230.0060.00322.58
8.2.220.0060.00337.54
8.2.210.0040.00426.77
8.2.200.0030.00616.50
8.2.190.0110.00716.75
8.2.180.0040.01118.29
8.2.170.0110.00422.96
8.2.160.0070.00722.30
8.2.150.0060.00324.18
8.2.140.0070.00024.66
8.2.130.0000.00726.16
8.2.120.0000.01421.00
8.2.110.0110.00021.13
8.2.100.0090.00318.16
8.2.90.0000.01017.97
8.2.80.0040.00418.03
8.2.70.0030.00517.75
8.2.60.0060.00317.75
8.2.50.0040.00419.43
8.2.40.0060.00317.75
8.2.30.0070.00019.46
8.2.20.0040.00418.14
8.2.10.0040.00419.29
8.2.00.0000.00719.39
8.1.290.0090.00318.88
8.1.280.0110.00325.92
8.1.270.0030.00522.19
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0070.00323.83
8.1.230.0040.00720.91
8.1.220.0050.00317.78
8.1.210.0080.00018.84
8.1.200.0000.00817.48
8.1.190.0050.00517.48
8.1.180.0050.00318.10
8.1.170.0090.00018.63
8.1.160.0070.00018.99
8.1.150.0040.00418.99
8.1.140.0000.00718.99
8.1.130.0040.00420.23
8.1.120.0040.00417.70
8.1.110.0030.00717.61
8.1.100.0030.00617.69
8.1.90.0040.00417.58
8.1.80.0050.00317.66
8.1.70.0000.00717.55
8.1.60.0060.00317.75
8.1.50.0030.00517.65
8.1.40.0090.00017.69
8.1.30.0000.00817.73
8.1.20.0030.00517.77
8.1.10.0040.00417.73
8.1.00.0000.00917.72
8.0.300.0080.00020.03
8.0.290.0030.00516.88
8.0.280.0000.00718.58
8.0.270.0000.00718.15
8.0.260.0070.00020.02
8.0.250.0030.00317.11
8.0.240.0000.00617.16
8.0.230.0030.00317.03
8.0.220.0070.00017.01
8.0.210.0030.00317.09
8.0.200.0080.00017.13
8.0.190.0040.00417.05
8.0.180.0000.00917.03
8.0.170.0060.00317.14
8.0.160.0040.00417.02
8.0.150.0050.00316.91
8.0.140.0030.00616.98
8.0.130.0000.00613.50
8.0.120.0050.00317.09
8.0.110.0040.00416.95
8.0.100.0000.00817.14
8.0.90.0090.00017.01
8.0.80.0070.01017.06
8.0.70.0040.00417.14
8.0.60.0000.00816.98
8.0.50.0000.00816.98
8.0.30.0070.01417.16
8.0.20.0030.01817.21
8.0.10.0040.00417.10
8.0.00.0060.01416.91
7.4.330.0050.00015.55
7.4.320.0000.00616.74
7.4.300.0030.00316.66
7.4.290.0070.00016.74
7.4.280.0040.00416.73
7.4.270.0070.00016.73
7.4.260.0050.00013.40
7.4.250.0030.00316.64
7.4.240.0060.00216.64
7.4.230.0070.00016.64
7.4.220.0020.00516.71
7.4.210.0140.00616.79
7.4.200.0070.00016.84
7.4.130.0110.00816.67
7.4.120.0090.01416.57
7.4.110.0040.01716.94
7.4.100.0130.00716.80
7.4.90.0060.01216.77
7.4.80.0140.00719.39
7.4.70.0090.01216.62
7.4.60.0110.00616.77
7.4.50.0090.00316.78
7.4.40.0110.00716.69
7.4.30.0090.00916.55
7.4.20.0070.01816.46
7.4.10.0060.01316.33
7.4.00.0150.00316.56
7.3.330.0070.00016.61
7.3.320.0000.00513.27
7.3.310.0000.00716.55
7.3.300.0040.00316.47
7.3.290.0050.00916.46
7.3.280.0130.01316.48
7.3.260.0060.01316.55
7.3.240.0060.01216.59
7.3.230.0030.01316.52
7.3.210.0140.00416.56
7.3.200.0120.00616.59
7.3.190.0120.00316.67
7.3.180.0080.00816.45
7.3.170.0170.00616.56
7.3.160.0130.00316.77
7.3.150.0100.00716.83
7.3.140.0130.00616.45
7.3.130.0080.01116.80
7.3.120.0110.00516.55
7.3.110.0140.00616.74
7.3.100.0160.00316.52
7.3.90.0090.00916.61
7.3.80.0090.00916.51
7.3.70.0060.01116.36
7.3.60.0060.00916.62
7.3.50.0070.01316.50
7.3.40.0170.00916.67
7.3.30.0170.00316.69
7.3.20.0150.01116.49
7.3.10.0070.01716.67
7.3.00.0100.01016.59
7.2.330.0060.01216.56
7.2.320.0120.00616.79
7.2.310.0100.01016.94
7.2.300.0080.01416.89
7.2.290.0060.01716.90
7.2.280.0110.01116.51
7.2.270.0140.00616.94
7.2.260.0170.00716.97
7.2.250.0090.00916.99
7.2.240.0070.01016.91
7.2.230.0080.01417.00
7.2.220.0060.01216.66
7.2.210.0100.01316.64
7.2.200.0070.01116.74
7.2.190.0120.00616.75
7.2.180.0130.00716.91
7.2.170.0100.01616.66
7.2.160.0150.01216.79
7.2.150.0160.00816.79
7.2.140.0180.00916.84
7.2.130.0110.01316.88
7.2.120.0210.00716.92
7.2.110.0100.01016.85
7.2.100.0160.00616.80
7.2.90.0200.00516.78
7.2.80.0160.00316.77
7.2.70.0160.00516.91
7.2.60.0040.01816.89
7.2.50.0130.00816.69
7.2.40.0170.00316.96
7.2.30.0120.00816.78
7.2.20.0120.01216.91
7.2.10.0110.01416.75
7.2.00.0150.00316.75

preferences:
20.86 ms | 403 KiB | 5 Q