Skip to content

Conversation

nielsdos
Copy link
Member

See individual commits.

nielsdos added 2 commits July 20, 2025 16:43
For this benchmark:
```php
$length = 25;
for ($i=0;$i<1000;$i++)
  array_chunk(range(0, 10000), $length);
```

On an i7-4790, length=25 speeds up by 1.8x and length=1 by 1.27x.
On an i7-1185G7, length=25 speeds up by 1.08x and length=1 by 1.02x.
By preallocating it as a packed array, we save the initial
initialization overhead.
Gives a few extra percentage points improvement.
@nielsdos nielsdos merged commit 1b169bf into php:master Jul 21, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants