[php-src] PR #15001: Optimize ext/dom $wholeText
| From: | nielsdos | Date: | Wed, 17 Jul 2024 22:05:38 +0000 |
| Subject: | [php-src] PR #15001: Optimize ext/dom $wholeText | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-27327@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/15001
Author: nielsdos
Use our own string builder instead of using libxml's and then having to copy over.
For the following test:
```php
$dom = Dom\HTMLDocument::createEmpty();
$root = $dom->appendChild($dom->createElement('root'));
$root->append('abc', 'def', 'ghi');
$f = $root->firstChild;
for ($i = 0; $i < 1000000; $i++)
$f->wholeText;
```
The following results were obtained on an i7-4790:
```
Benchmark 1: ./sapi/cli/php x.php
Time (mean ± σ): 57.2 ms ± 2.3 ms [User: 53.2 ms, System: 3.4 ms]
Range (min … max): 54.7 ms … 69.3 ms 52 runs
Benchmark 2: ./sapi/cli/php_old x.php
Time (mean ± σ): 89.4 ms ± 3.4 ms [User: 85.6 ms, System: 3.0 ms]
Range (min … max): 86.1 ms … 105.8 ms 32 runs
Summary
./sapi/cli/php x.php ran
1.56 ± 0.09 times faster than ./sapi/cli/php_old x.php
```