[php-src] PR #20357: Improve performance of intval('+0b...', 2) and intval('0b...', 2)
| From: | ndossche | Date: | Sun, 02 Nov 2025 10:33:34 +0000 |
| Subject: | [php-src] PR #20357: Improve performance of intval('+0b...', 2) and intval('0b...', 2) | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33878@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20357
Author: ndossche
For this benchmark:
```php
<?php
for ($i = 0; $i < 10000000; $i++) {
intval('+0b11111111111100000000', 2);
}
```
On an i7-4790:
```
Benchmark 1: ./sapi/cli/php x.php
Time (mean ± σ): 527.3 ms ± 8.1 ms [User: 523.5 ms, System: 2.4 ms]
Range (min … max): 515.4 ms … 545.1 ms 10 runs
Benchmark 2: ./sapi/cli/php_old x.php
Time (mean ± σ): 629.3 ms ± 6.0 ms [User: 625.9 ms, System: 1.8 ms]
Range (min … max): 622.8 ms … 643.2 ms 10 runs
Summary
./sapi/cli/php x.php ran
1.19 ± 0.02 times faster than ./sapi/cli/php_old x.php
```