[php-src] PR #20408: [PoC] support sorting packed arrays without converting to hashed arrays first
| From: | ndossche | Date: | Thu, 06 Nov 2025 20:19:39 +0000 |
| Subject: | [php-src] PR #20408: [PoC] support sorting packed arrays without converting to hashed arrays first | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33948@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20408
Author: ndossche
This is a proof-of-concept.
Demo speedup on i7-4790:
```php
<?php
$x = range(20, 0);
for ($i = 0; $i < 500000; $i++)
sort($x);
var_dump($x);
```
```
Benchmark 1: ./sapi/cli/php x.php
Time (mean ± σ): 123.2 ms ± 3.0 ms [User: 119.5 ms, System: 2.6 ms]
Range (min … max): 119.2 ms … 134.1 ms 24 runs
Benchmark 2: ./sapi/cli/php_old x.php
Time (mean ± σ): 176.8 ms ± 2.5 ms [User: 173.9 ms, System: 2.1 ms]
Range (min … max): 174.3 ms … 183.2 ms 17 runs
Summary
./sapi/cli/php x.php ran
1.44 ± 0.04 times faster than ./sapi/cli/php_old x.php
```