Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve performance of multi-array array_map() #20350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ndossche wants to merge 6 commits into php:master
base: master
Choose a base branch
Loading
from ndossche:array-map-opt-1

Conversation

@ndossche
Copy link
Member

@ndossche ndossche commented Oct 31, 2025
edited
Loading

For this benchmark script:

<?php
function sum($a, $b) {
 return $a+$b;
}
$cb = sum(...);
for ($i = 0; $i < 1000000; $i++) {
 array_map($cb, [1,2,3], [4,5,6]);
}

On an i7-4790:

Benchmark 1: ./sapi/cli/php x.php
 Time (mean ± σ): 171.9 ms ± 2.1 ms [User: 168.6 ms, System: 2.3 ms]
 Range (min ... max): 168.8 ms ... 176.1 ms 17 runs
 
Benchmark 2: ./sapi/cli/php_old x.php
 Time (mean ± σ): 206.3 ms ± 4.1 ms [User: 201.8 ms, System: 2.7 ms]
 Range (min ... max): 201.8 ms ... 217.3 ms 14 runs
 
Summary
 ./sapi/cli/php x.php ran
 1.20 ± 0.03 times faster than ./sapi/cli/php_old x.php

On an i7-1185G7:

Benchmark 1: ./sapi/cli/php x.php
 Time (mean ± σ): 98.9 ms ± 2.0 ms [User: 97.3 ms, System: 1.4 ms]
 Range (min ... max): 96.3 ms ... 102.8 ms 30 runs
 
Benchmark 2: ./sapi/cli/php_old x.php
 Time (mean ± σ): 122.1 ms ± 1.0 ms [User: 120.0 ms, System: 1.9 ms]
 Range (min ... max): 120.8 ms ... 123.9 ms 24 runs
 
Summary
 ./sapi/cli/php x.php ran
 1.23 ± 0.03 times faster than ./sapi/cli/php_old x.php

@ndossche ndossche marked this pull request as ready for review November 1, 2025 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Girgias Girgias Girgias approved these changes

@bukka bukka Awaiting requested review from bukka bukka is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /