Commit 73c2e3c
authored
Avoid pointless refcounting in array_reduce (#18180)
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
```1 parent 5dd9b0d commit 73c2e3c
1 file changed
+8
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6437 | 6437 | | |
6438 | 6438 | | |
6439 | 6439 | | |
6440 | | - | |
6441 | 6440 | | |
6442 | 6441 | | |
6443 | 6442 | | |
| |||
6450 | 6449 | | |
6451 | 6450 | | |
6452 | 6451 | | |
6453 | | - | |
6454 | | - | |
| 6452 | + | |
6455 | 6453 | | |
6456 | 6454 | | |
6457 | 6455 | | |
| |||
6466 | 6464 | | |
6467 | 6465 | | |
6468 | 6466 | | |
6469 | | - | |
| 6467 | + | |
6470 | 6468 | | |
| 6469 | + | |
6471 | 6470 | | |
6472 | 6471 | | |
6473 | 6472 | | |
6474 | | - | |
6475 | | - | |
| 6473 | + | |
6476 | 6474 | | |
6477 | | - | |
6478 | | - | |
6479 | | - | |
6480 | | - | |
| 6475 | + | |
| 6476 | + | |
| 6477 | + | |
| 6478 | + | |
6481 | 6479 | | |
6482 | 6480 | | |
6483 | 6481 | | |
6484 | 6482 | | |
6485 | | - | |
6486 | | - | |
6487 | 6483 | | |
6488 | 6484 | | |
6489 | 6485 | | |
| |||
0 commit comments