[php-src] PR #18065: ext/bcmath: If size of `BC_VECTOR` array is within 64 bytes, stack area is now used
| From: | SakiTakamachi | Date: | Fri, 14 Mar 2025 11:30:02 +0000 |
| Subject: | [php-src] PR #18065: ext/bcmath: If size of `BC_VECTOR` array is within 64 bytes, stack area is now used | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-31073@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/18065
Author: SakiTakamachi
# Benchmark
## Divide
### Codes
1:
```
for ($i = 0; $i < 2000000; $i++) {
bcdiv('1.23', '2', 5);
}
```
2:
```
for ($i = 0; $i < 50000; $i++) {
bcdiv(str_repeat('1234567890', 300), str_repeat('9876543210', 300), 10);
}
```
3:
```
for ($i = 0; $i < 2000000; $i++) {
bcdiv('12345678.901234', '1.2345678912', 10);
}
```
### Results
1:
```
Benchmark 1: /php-dev/sapi/cli/php /mount/bc/div/1.php
Time (mean ± σ): 285.9 ms ± 1.8 ms [User: 275.4 ms, System: 5.6 ms]
Range (min … max): 282.0 ms … 289.1 ms 10 runs
Benchmark 2: /master/sapi/cli/php /mount/bc/div/1.php
Time (mean ± σ): 303.7 ms ± 2.8 ms [User: 292.5 ms, System: 5.9 ms]
Range (min … max): 300.3 ms … 308.3 ms 10 runs
Summary
'/php-dev/sapi/cli/php /mount/bc/div/1.php' ran
1.06 ± 0.01 times faster than '/master/sapi/cli/php /mount/bc/div/1.php'
```
2:
```
Benchmark 1: /php-dev/sapi/cli/php /mount/bc/div/2.php
Time (mean ± σ): 417.6 ms ± 4.9 ms [User: 406.4 ms, System: 6.0 ms]
Range (min … max): 411.5 ms … 425.7 ms 10 runs
Benchmark 2: /master/sapi/cli/php /mount/bc/div/2.php
Time (mean ± σ): 426.9 ms ± 9.1 ms [User: 415.7 ms, System: 5.6 ms]
Range (min … max): 415.5 ms … 439.7 ms 10 runs
Summary
'/php-dev/sapi/cli/php /mount/bc/div/2.php' ran
1.02 ± 0.02 times faster than '/master/sapi/cli/php /mount/bc/div/2.php'
```
3:
```
Benchmark 1: /php-dev/sapi/cli/php /mount/bc/div/3.php
Time (mean ± σ): 383.8 ms ± 4.0 ms [User: 372.5 ms, System: 6.1 ms]
Range (min … max): 376.7 ms … 388.6 ms 10 runs
Benchmark 2: /master/sapi/cli/php /mount/bc/div/3.php
Time (mean ± σ): 401.5 ms ± 3.0 ms [User: 389.4 ms, System: 6.8 ms]
Range (min … max): 397.9 ms … 407.3 ms 10 runs
Summary
'/php-dev/sapi/cli/php /mount/bc/div/3.php' ran
1.05 ± 0.01 times faster than '/master/sapi/cli/php /mount/bc/div/3.php'
```