[php-src] PR #18180: Avoid pointless refcounting in array_reduce
| From: | nielsdos | Date: | Sat, 29 Mar 2025 13:38:56 +0000 |
| Subject: | [php-src] PR #18180: Avoid pointless refcounting in array_reduce | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-31217@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/18180
Author: nielsdos
For this script:
```php
for ($i=0;$i < 100; $i++)
array_reduce(range(1, 100000), fn ($a,$b)=>$a+$b,1);
```
On an i7-4790:
```
Benchmark 1: ./sapi/cli/php reduce_bench.php
Time (mean ± σ): 272.0 ms ± 3.7 ms [User: 268.9 ms, System: 2.1 ms]
Range (min … max): 268.9 ms … 281.3 ms 11 runs
Benchmark 2: ./sapi/cli/php_old reduce_bench.php
Time (mean ± σ): 288.2 ms ± 3.5 ms [User: 284.5 ms, System: 2.7 ms]
Range (min … max): 285.0 ms … 295.9 ms 10 runs
Summary
./sapi/cli/php reduce_bench.php ran
1.06 ± 0.02 times faster than ./sapi/cli/php_old reduce_bench.php
```
On an i7-1185G7:
```
Benchmark 1: ./sapi/cli/php test.php
Time (mean ± σ): 189.6 ms ± 3.5 ms [User: 178.5 ms, System: 10.7 ms]
Range (min … max): 187.3 ms … 201.6 ms 15 runs
Benchmark 2: ./sapi/cli/php_old test.php
Time (mean ± σ): 204.2 ms ± 2.9 ms [User: 190.1 ms, System: 13.6 ms]
Range (min … max): 200.6 ms … 210.2 ms 14 runs
Summary
./sapi/cli/php test.php ran
1.08 ± 0.02 times faster than ./sapi/cli/php_old test.php
```