[php-src] Issue #11192: improve `max()` performance

From: Date: Sat, 06 May 2023 06:45:46 +0000
Subject: [php-src] Issue #11192: improve `max()` performance
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244383@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11192
Author: staabm

### Description

In a recent performance investigation I identified max() as a perf bottleneck in https://github.com/sebastianbergmann/diff/pull/118

@bwoebi chimmed in and suggested max() should be improved at the php-src level.
see his in-detail investigation at https://github.com/sebastianbergmann/diff/pull/118#issuecomment-1531185370

The following code:

```php
<?php
~/php-src-8.2 # time ./sapi/cli/php -r '$b = 1; $c = 2; for ($i = 0; $i < 430000000; ++$i) {
$a = max($b, $c); }'

real	0m6.924s
user	0m6.917s
sys	0m0.004s
~/php-src-8.2 # time ./sapi/cli/php -r '$b = 1; $c = 2; for ($i = 0; $i < 430000000; ++$i) {
if ($b < $c) { $a = $b; } else { $a = $c; } }'

real	0m2.523s
user	0m2.514s
sys	0m0.008s
```

max() should be faster


### PHP Version

8.2.5

### Operating System

macos


Thread (1 message)

  • staabm
« previous php.bugs (#244383) next »