[php-src] PR #14229: ext/bcmath: Improving mul performance 2

From: Date: Tue, 14 May 2024 13:15:05 +0000
Subject: [php-src] PR #14229: ext/bcmath: Improving mul performance 2
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-26155@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/14229 Author: SakiTakamachi This is derived from #14213. bench codes: 1: ``` $num1 = '1.2345678'; $num2 = '2.1234567'; for ($i = 0; $i < 5000000; $i++) { bcmul($num1, $num2, 7); } ``` 2: ``` $num1 = str_repeat('1234567890', 300); $num2 = str_repeat('9876543210', 300); for ($i = 0; $i < 6000; $i++) { bcmul($num1, $num2, 0); } ``` 3: ``` $num1 = '1.2345678901234567890'; $num2 = '2.12345678901234567890'; for ($i = 0; $i < 3000000; $i++) { bcmul($num1, $num2, 20); } ``` 4: ``` $num1 = '-12345678901234567890.12345678901234567890'; $num2 = '-212345678901234567890.12345678901234567890'; for ($i = 0; $i < 1800000; $i++) { bcmul($num1, $num2, 20); } ``` 5: ``` $num1 = '12345678901234567890.00000000000000000000000000000000000000000000000000'; $num2 = '212345678901234567890.00000000000000000000000000000000000000000000000000'; for ($i = 0; $i < 3000000; $i++) { bcmul($num1, $num2, 20); } ``` ## before ``` hyperfine "php /bc/mul/1.php" --warmup 10 Time (mean ± σ): 620.9 ms ± 6.1 ms [User: 615.4 ms, System: 4.6 ms] Range (min … max): 612.6 ms … 632.7 ms 10 runs hyperfine "php /bc/mul/2.php" --warmup 10 Time (mean ± σ): 581.2 ms ± 6.0 ms [User: 578.2 ms, System: 2.3 ms] Range (min … max): 571.5 ms … 590.9 ms 10 runs hyperfine "php /bc/mul/3.php" --warmup 10 Time (mean ± σ): 628.7 ms ± 13.6 ms [User: 624.9 ms, System: 3.0 ms] Range (min … max): 614.6 ms … 656.8 ms 10 runs hyperfine "php /bc/mul/4.php" --warmup 10 Time (mean ± σ): 593.6 ms ± 10.1 ms [User: 589.6 ms, System: 3.1 ms] Range (min … max): 583.7 ms … 615.4 ms 10 runs hyperfine "php /bc/mul/5.php" --warmup 10 Time (mean ± σ): 680.9 ms ± 8.6 ms [User: 676.8 ms, System: 3.2 ms] Range (min … max): 671.1 ms … 694.5 ms 10 runs ``` ## after ``` hyperfine "php /bc/mul/1.php" --warmup 10 Time (mean ± σ): 604.5 ms ± 8.7 ms [User: 600.0 ms, System: 3.5 ms] Range (min … max): 596.1 ms … 625.3 ms 10 runs hyperfine "php /bc/mul/2.php" --warmup 10 Time (mean ± σ): 541.1 ms ± 9.0 ms [User: 537.9 ms, System: 2.4 ms] Range (min … max): 534.1 ms … 565.5 ms 10 runs hyperfine "php /bc/mul/3.php" --warmup 10 Time (mean ± σ): 506.8 ms ± 2.9 ms [User: 502.6 ms, System: 3.3 ms] Range (min … max): 501.7 ms … 512.0 ms 10 runs hyperfine "php /bc/mul/4.php" --warmup 10 Time (mean ± σ): 448.6 ms ± 8.1 ms [User: 444.9 ms, System: 2.9 ms] Range (min … max): 441.5 ms … 467.7 ms 10 runs hyperfine "php /bc/mul/5.php" --warmup 10 Time (mean ± σ): 561.4 ms ± 4.4 ms [User: 557.7 ms, System: 3.0 ms] Range (min … max): 556.7 ms … 570.7 ms 10 runs ```

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