[php-src] PR #20350: Improve performance of multi-array array_map()
| From: | ndossche | Date: | Fri, 31 Oct 2025 22:33:41 +0000 |
| Subject: | [php-src] PR #20350: Improve performance of multi-array array_map() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33869@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20350
Author: ndossche
For this benchmark script:
```php
<?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
```