1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext
Niels Dossche 7b6b233ce8 Optimize array_fill_keys() (#20347)
Move the refcount update outside of the loop.

For the following benchmark:
```php
$r = range(0, 1000);
$v = new stdClass();

for ($i = 0; $i < 100000; $i++) {
    array_fill_keys($r, $v);
}
```

On an i7-4790:
```
Benchmark 1: ./sapi/cli/php_old ../x.php
  Time (mean ± σ):     507.5 ms ±   4.8 ms    [User: 505.1 ms, System: 1.2 ms]
  Range (min … max):   501.2 ms … 518.4 ms    10 runs

Benchmark 2: ./sapi/cli/php ../x.php
  Time (mean ± σ):     479.8 ms ±   3.1 ms    [User: 476.8 ms, System: 1.8 ms]
  Range (min … max):   475.0 ms … 486.7 ms    10 runs

Summary
  ./sapi/cli/php ../x.php ran
    1.06 ± 0.01 times faster than ./sapi/cli/php_old ../x.php
```

On an i7-1185G7:
```
Benchmark 1: ./sapi/cli/php x.php
  Time (mean ± σ):     343.9 ms ±   3.1 ms    [User: 341.1 ms, System: 2.3 ms]
  Range (min … max):   337.9 ms … 347.8 ms    10 runs

Benchmark 2: ./sapi/cli/php_old x.php
  Time (mean ± σ):     357.8 ms ±   2.3 ms    [User: 355.7 ms, System: 1.6 ms]
  Range (min … max):   355.0 ms … 362.6 ms    10 runs

Summary
  ./sapi/cli/php x.php ran
    1.04 ± 0.01 times faster than ./sapi/cli/php_old x.php
```
2025-11-03 22:35:26 +01:00
..
2025-10-15 19:39:39 +02:00
2025-10-07 18:33:17 +02:00
2025-10-06 10:32:28 +02:00
2025-11-03 18:46:56 +01:00
2025-10-15 20:24:55 +02:00
2025-10-26 23:40:01 +01:00
2025-10-27 17:46:02 +00:00
2025-10-29 14:40:01 -03:00
2025-10-14 22:15:15 +02:00
2025-10-29 18:37:29 +00:00
2025-10-15 21:49:39 +02:00
2025-09-29 12:45:45 -03:00
2025-10-31 17:50:49 +01:00
2025-10-23 15:28:55 +02:00
2025-07-29 14:00:37 +02:00
2025-10-29 18:37:29 +00:00
2025-10-24 21:20:58 +02:00
2025-10-19 14:14:02 +02:00
2025-10-31 08:08:26 +01:00
2025-10-08 17:39:26 +02:00
2025-10-22 10:04:02 +02:00
2025-10-12 11:25:46 +02:00
2025-10-11 18:05:18 +02:00
2025-10-29 18:37:29 +00:00
2025-10-24 21:20:58 +02:00
2025-11-03 21:52:23 +01:00
2025-10-11 23:57:49 +02:00
2025-11-02 21:17:19 +00:00
2025-11-01 09:30:59 +01:00