3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [1, 2, 3, 5, 4, 7, 6, 8, 9]; $batches = generateBatches($input); function generateBatches($input) { $length = count($input); if (0 === $length) { return []; } $batches = []; $prev = $input[0]; $currentBatch = [$prev]; for ($i = 1; $i < $length; $i++) { if ($i < $prev) { $batches[] = $currentBatch; $currentBatch = []; } $currentBatch[] = $prev = $input[$i]; } $batches[] = $currentBatch; return $batches; } print_r($batches);

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.5.10.0100.00816.86
8.5.00.0120.01019.79
8.4.160.0100.01221.56
8.4.150.0030.00014.05
8.4.140.0130.00917.70
8.4.130.0080.00517.73
8.4.120.0170.00323.93
8.4.110.0140.00522.25
8.4.100.0060.00518.87
8.4.90.0130.00718.60
8.4.80.0080.00718.83
8.4.70.0080.00318.01
8.4.60.0100.01018.61
8.4.50.0100.01118.57
8.4.40.0080.00017.44
8.4.30.0170.00319.48
8.4.20.0150.00717.75
8.4.10.0060.00317.54
8.3.280.0150.00718.34
8.3.270.0120.00716.46
8.3.260.0140.00516.57
8.3.250.0070.00918.73
8.3.240.0110.00817.17
8.3.230.0130.00816.48
8.3.220.0130.00618.91
8.3.210.0060.00716.60
8.3.200.0100.01016.61
8.3.190.0100.00917.25
8.3.180.0040.00418.75
8.3.170.0090.00920.54
8.3.160.0110.00717.29
8.3.150.0160.00317.32
8.3.140.0120.00616.79
8.3.130.0040.00418.48
8.3.120.0040.00420.91
8.3.110.0060.00320.94
8.3.100.0040.00424.06
8.3.90.0120.00326.77
8.3.80.0090.00018.43
8.3.70.0180.00316.50
8.3.60.0090.00618.56
8.3.50.0150.00517.41
8.3.40.0120.00318.57
8.3.30.0160.00318.59
8.3.20.0040.00421.90
8.3.10.0050.00321.85
8.3.00.0070.00023.53
8.2.290.0090.00720.30
8.2.280.0040.00418.40
8.2.270.0040.00417.26
8.2.260.0030.00516.77
8.2.250.0000.00816.46
8.2.240.0040.00416.95
8.2.230.0000.00822.58
8.2.220.0060.00337.54
8.2.210.0140.00026.77
8.2.200.0070.00316.25
8.2.190.0120.00616.63
8.2.180.0140.00318.37
8.2.170.0120.00619.11
8.2.160.0100.00322.96
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0100.00719.38
8.2.110.0040.00422.16
8.2.100.0120.00017.84
8.2.90.0080.00017.97
8.2.80.0000.00918.22
8.2.70.0000.00918.05
8.2.60.0050.00318.04
8.2.50.0070.00018.16
8.2.40.0060.00319.22
8.2.30.0040.00421.18
8.2.20.0030.00518.18
8.2.10.0000.00718.03
8.2.00.0000.00718.04
8.1.330.0090.00822.09
8.1.320.0020.00616.16
8.1.310.0040.00418.53
8.1.300.0050.00315.91
8.1.290.0090.00030.84
8.1.280.0090.00625.92
8.1.270.0040.00423.96
8.1.260.0100.00626.35
8.1.250.0070.00028.09
8.1.240.0090.00023.92
8.1.230.0070.00721.05
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0040.00417.36
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0040.00418.54
8.1.160.0040.00418.88
8.1.150.0000.00719.05
8.1.140.0030.00517.66
8.1.130.0000.00819.00
8.1.120.0070.00017.51
8.1.110.0070.00017.49
8.1.100.0000.00717.34
8.1.90.0000.00717.34
8.1.80.0040.00417.41
8.1.70.0040.00417.46
8.1.60.0000.00817.52
8.1.50.0030.00917.52
8.1.40.0020.00517.52
8.1.30.0070.00017.62
8.1.20.0000.00717.69
8.1.10.0030.00617.61
8.1.00.0030.00617.51
8.0.300.0050.00220.03
8.0.290.0080.00016.63
8.0.280.0000.00818.39
8.0.270.0050.00517.27
8.0.260.0000.00817.26
8.0.250.0040.00417.00
8.0.240.0030.00616.84
8.0.230.0070.00016.91
8.0.220.0030.00316.81
8.0.210.0050.00316.82
8.0.200.0030.00316.84
8.0.190.0040.00416.90
8.0.180.0040.00416.81
8.0.170.0040.00716.93
8.0.160.0040.00416.96
8.0.150.0020.00716.73
8.0.140.0000.00716.77
8.0.130.0000.00613.38
8.0.120.0070.00016.77
8.0.110.0000.00716.94
8.0.100.0000.00716.89
8.0.90.0030.00516.91
8.0.80.0040.01116.83
8.0.70.0030.00516.76
8.0.60.0040.00416.93
8.0.50.0040.00416.76
8.0.30.0120.00817.13
8.0.20.0110.00717.40
8.0.10.0000.00716.83
8.0.00.0050.01216.72
7.4.330.0030.00316.79
7.4.320.0060.00016.50
7.4.300.0030.00316.49
7.4.290.0000.00716.59
7.4.280.0040.00416.59
7.4.270.0000.00816.59
7.4.260.0000.00716.47
7.4.250.0070.00016.46
7.4.240.0000.00716.63
7.4.230.0030.00316.53
7.4.220.0030.00516.66
7.4.210.0050.01016.53
7.4.200.0050.00316.62
7.4.160.0140.00516.61
7.4.140.0100.00717.86
7.4.130.0060.00916.48
7.4.120.0090.00916.48
7.4.110.0040.01316.66
7.4.100.0110.00616.37
7.4.90.0120.01016.36
7.4.80.0120.00619.39
7.4.70.0120.00916.49
7.4.60.0060.00916.74
7.4.50.0090.00916.58
7.4.40.0090.00616.48
7.4.00.0100.00614.93
7.3.330.0000.00513.32
7.3.320.0030.00313.14
7.3.310.0030.00316.39
7.3.300.0030.00316.37
7.3.290.0040.00416.23
7.3.280.0060.01016.36
7.3.260.0130.00416.40
7.3.240.0100.00616.43
7.3.230.0090.00916.36
7.3.210.0000.01616.35
7.3.200.0030.01316.69
7.3.190.0030.01216.36
7.3.180.0060.00916.44
7.3.170.0030.01416.50
7.3.160.0120.00416.65
7.2.330.0060.01816.50
7.2.320.0070.01016.61
7.2.310.0100.00716.73
7.2.300.0140.00316.72
7.2.290.0130.00916.37
7.2.60.0030.00917.01
7.2.40.0820.00818.03
7.2.30.0920.00718.03
7.2.20.0920.00818.06
7.2.10.0890.00617.73
7.2.00.0900.01018.16
7.1.200.0040.00415.84
7.1.160.0740.00816.84
7.1.150.1100.00916.98
7.1.140.0900.00917.09
7.1.130.0900.00816.66
7.1.120.1150.01516.68
7.1.110.1670.01016.03
7.1.100.1010.00816.27
7.1.90.1190.01416.29
7.1.80.0860.00716.31
7.1.70.1190.01215.45
7.1.60.0980.01233.24
7.1.50.1040.01033.20
7.1.40.1550.01632.77
7.1.30.1300.01132.55
7.1.20.1630.01432.83
7.1.10.1000.01214.76
7.1.00.1480.00814.99

preferences:
37.75 ms | 403 KiB | 5 Q