1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext
Niels Dossche db8c331d07 array_unshift: Add fast optimized case for packed arrays (#20353)
Packed arrays are likely common in this case, as with array_shift which
already has a similar optimization.

For the following benchmark:
```php
<?php

for ($i = 0; $i < 10000000; $i++) {
    $a = [0, 1, 2, 3, 4, 5];
    array_unshift($a, -3, -2, -1);
}
```

On an i7-4790:
```
Benchmark 1: ./sapi/cli/php x.php
  Time (mean ± σ):     753.8 ms ±  23.8 ms    [User: 749.8 ms, System: 2.1 ms]
  Range (min … max):   734.3 ms … 818.6 ms    10 runs

Benchmark 2: ./sapi/cli/php_old x.php
  Time (mean ± σ):     972.5 ms ±   5.0 ms    [User: 968.8 ms, System: 1.4 ms]
  Range (min … max):   967.8 ms … 984.3 ms    10 runs

Summary
  ./sapi/cli/php x.php  ran
    1.29 ± 0.04 times faster than ./sapi/cli/php_old x.php
```
2025-11-06 18:49:23 +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-11-06 11:21:55 +01:00
2025-10-23 15:28:55 +02:00
2025-11-03 23:02:12 +01: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-11-04 08:33:55 +01: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-11-05 20:22:54 +01: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