3v4l.org

run code in 300+ PHP versions simultaneously
<?php function littleEndianMinChunk(array $array, int $minChunkSize): array { if ($minChunkSize < 1) { throw new InvalidArgumentException('$minChunkSize must be 1 or greater'); } if (count($array) < $minChunkSize) { throw new InvalidArgumentException('$minChunkSize must not be less than the size of $array'); } $result = []; while ($array) { $count = count($array); $modulus = $count % $minChunkSize; if (!$modulus) { array_unshift($result, ...array_chunk($array, $minChunkSize)); break; } $expectedRemainingChunks = max(1, intdiv($count, $minChunkSize)); $sizeIncrease = ceil($modulus / $expectedRemainingChunks); array_unshift($result, array_splice($array, -$minChunkSize - $sizeIncrease)); } return $result; } $arraySize = 13; for ($n = 1; $n <= $arraySize; ++$n) { echo "arraySize $n \n"; $array = range(1, $n); for ($x = 1; $x <= 13; ++$x) { echo "chunkSize $x: "; try { echo json_encode(littleEndianMinChunk($array, $x)) . "\n"; } catch (Exception $e) { echo $e->getMessage() . "\n"; } } }

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.4.120.0140.00722.22
8.4.110.0130.00618.98
8.4.100.0120.01017.88
8.4.90.0150.00517.82
8.4.80.0050.00417.90
8.4.70.0060.00419.74
8.4.60.0060.00418.12
8.4.50.0110.00918.95
8.4.40.0000.00917.77
8.4.30.0100.01020.83
8.4.20.0100.01017.92
8.4.10.0040.00419.39
8.3.250.0130.00718.80
8.3.240.0060.00316.66
8.3.230.0070.00316.64
8.3.220.0040.00417.13
8.3.210.0120.00716.72
8.3.200.0130.00716.61
8.3.190.0110.01017.18
8.3.180.0130.00517.16
8.3.170.0090.00918.64
8.3.160.0000.01017.12
8.3.150.0130.01017.23
8.3.140.0160.00318.98
8.3.130.0060.00318.50
8.3.120.0030.00619.00
8.3.110.0040.00420.94
8.3.100.0060.00324.06
8.3.90.0040.00426.77
8.3.80.0000.00917.97
8.3.70.0160.00616.50
8.3.60.0030.01616.74
8.3.50.0100.01316.54
8.3.40.0080.00822.02
8.3.30.0130.01022.96
8.3.20.0120.00923.65
8.3.10.0130.00823.64
8.3.00.0160.00922.96
8.2.290.0100.01020.13
8.2.280.0090.00816.64
8.2.270.0160.00617.15
8.2.260.0000.01916.43
8.2.250.0030.00618.28
8.2.240.0030.00718.95
8.2.230.0050.00522.58
8.2.220.0110.00037.54
8.2.210.0150.00026.77
8.2.200.0050.00516.63
8.2.190.0150.00317.00
8.2.180.0060.01616.63
8.2.170.0120.00322.96
8.2.160.0110.01122.96
8.2.150.0090.00922.96
8.2.140.0140.00322.96
8.2.130.0150.00322.96
8.2.120.0110.01122.96
8.2.110.0090.01222.96
8.2.100.0100.00622.96
8.2.90.0130.00322.96
8.2.80.0150.00622.96
8.2.70.0090.00622.96
8.2.60.0100.01322.96
8.2.50.0110.00422.96
8.2.40.0080.00822.96
8.2.30.0060.00922.96
8.2.20.0060.01022.96
8.2.10.0180.00422.96
8.2.00.0160.00722.96
8.1.330.0120.00818.61
8.1.320.0120.00816.13
8.1.310.0030.00618.64
8.1.300.0040.00720.02
8.1.290.0030.00630.84
8.1.280.0120.00325.92
8.1.270.0110.01122.96
8.1.260.0060.00922.96
8.1.250.0070.00722.96
8.1.240.0130.01022.96
8.1.230.0110.01122.96
8.1.220.0070.00722.96
8.1.210.0130.00922.96
8.1.200.0090.00622.96
8.1.190.0140.00322.96
8.1.180.0130.00722.96
8.1.170.0150.00422.96
8.1.160.0070.01322.96
8.1.150.0100.00722.96
8.1.140.0170.00022.96
8.1.130.0120.00322.96
8.1.120.0000.01522.96
8.1.110.0140.00322.96
8.1.100.0170.00022.96
8.1.90.0090.00922.96
8.1.80.0140.00322.96
8.1.70.0090.00622.96
8.1.60.0060.00922.96
8.1.50.0090.00622.96
8.1.40.0120.00322.96
8.1.30.0080.00822.96
8.1.20.0060.00922.96
8.1.10.0090.00622.96
8.1.00.0070.00722.96

preferences:
25.55 ms | 403 KiB | 5 Q