[php-src] PR #18859: ext/bcmath: use vector in compare

From: Date: Mon, 16 Jun 2025 12:29:32 +0000
Subject: [php-src] PR #18859: ext/bcmath: use vector in compare
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-32087@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/18859 Author: SakiTakamachi # Benchmark The theoretical expectation is that it should be just slightly slower with small values, but in practice, it seems almost unchanged. ### Small value ``` for ($i = 0; $i < 10000000; $i++) { bccomp('1.2345', '1.23456', 5); } ``` ``` Benchmark 1: /php-dev2/sapi/cli/php /mount/bc/cmp/0.php Time (mean ± σ): 439.0 ms ± 2.6 ms [User: 433.7 ms, System: 2.9 ms] Range (min … max): 434.4 ms … 444.2 ms 10 runs Benchmark 2: /master/sapi/cli/php /mount/bc/cmp/0.php Time (mean ± σ): 443.4 ms ± 5.5 ms [User: 437.4 ms, System: 3.5 ms] Range (min … max): 434.0 ms … 452.2 ms 10 runs Summary '/php-dev2/sapi/cli/php /mount/bc/cmp/0.php' ran 1.01 ± 0.01 times faster than '/master/sapi/cli/php /mount/bc/cmp/0.php' ``` ### Middle value 1 ``` for ($i = 0; $i < 10000000; $i++) { bccomp('1.234567890123', '1.234567890123', 15); } ``` ``` Benchmark 1: /php-dev2/sapi/cli/php /mount/bc/cmp/1.php Time (mean ± σ): 475.9 ms ± 1.7 ms [User: 469.5 ms, System: 3.9 ms] Range (min … max): 472.0 ms … 477.4 ms 10 runs Benchmark 2: /master/sapi/cli/php /mount/bc/cmp/1.php Time (mean ± σ): 489.9 ms ± 4.3 ms [User: 483.9 ms, System: 3.5 ms] Range (min … max): 485.0 ms … 497.7 ms 10 runs Summary '/php-dev2/sapi/cli/php /mount/bc/cmp/1.php' ran 1.03 ± 0.01 times faster than '/master/sapi/cli/php /mount/bc/cmp/1.php' ``` ### Middle value 2 ``` for ($i = 0; $i < 10000000; $i++) { bccomp('1.23456789012345678901234567890123456789012345678901234567890123456789', '1.23456789012345678901234567890123456789012345678901234567890123456789', 40); } ``` ``` Benchmark 1: /php-dev2/sapi/cli/php /mount/bc/cmp/2.php Time (mean ± σ): 492.9 ms ± 3.0 ms [User: 486.2 ms, System: 4.3 ms] Range (min … max): 487.9 ms … 498.1 ms 10 runs Benchmark 2: /master/sapi/cli/php /mount/bc/cmp/2.php Time (mean ± σ): 590.1 ms ± 2.9 ms [User: 584.2 ms, System: 3.4 ms] Range (min … max): 585.6 ms … 593.9 ms 10 runs Summary '/php-dev2/sapi/cli/php /mount/bc/cmp/2.php' ran 1.20 ± 0.01 times faster than '/master/sapi/cli/php /mount/bc/cmp/2.php' ``` ### Large value ``` for ($i = 0; $i < 100000; $i++) { bccomp(str_repeat('1234567890', 3000), str_repeat('1234567890', 3000), 0); } ``` ``` Benchmark 1: /php-dev2/sapi/cli/php /mount/bc/cmp/3.php Time (mean ± σ): 571.7 ms ± 22.2 ms [User: 566.5 ms, System: 2.8 ms] Range (min … max): 561.6 ms … 634.5 ms 10 runs Benchmark 2: /master/sapi/cli/php /mount/bc/cmp/3.php Time (mean ± σ): 1.322 s ± 0.002 s [User: 1.316 s, System: 0.004 s] Range (min … max): 1.319 s … 1.326 s 10 runs Summary '/php-dev2/sapi/cli/php /mount/bc/cmp/3.php' ran 2.31 ± 0.09 times faster than '/master/sapi/cli/php /mount/bc/cmp/3.php' ```

« previous php.git-pulls (#32087) next »