Skip to content

Commit 1ddbee7

Browse files
committed
bigint mac3: tweak thresholds between algorithms
It's not too rigorous, but thresholds 32 and 256 give me better results. Before: test multiply_0 ... bench: 87 ns/iter (+/- 0) test multiply_1 ... bench: 11,926 ns/iter (+/- 19) test multiply_2 ... bench: 772,178 ns/iter (+/- 3,068) test multiply_3 ... bench: 2,034,237 ns/iter (+/- 9,618) After: test multiply_0 ... bench: 87 ns/iter (+/- 0) test multiply_1 ... bench: 11,927 ns/iter (+/- 64) test multiply_2 ... bench: 672,440 ns/iter (+/- 3,570) test multiply_3 ... bench: 1,577,065 ns/iter (+/- 11,137)
1 parent 28d84ca commit 1ddbee7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bigint/src/algorithms.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,12 @@ fn mac3(acc: &mut [BigDigit], b: &[BigDigit], c: &[BigDigit]) {
260260
// The thresholds are somewhat arbitrary, chosen by evaluating the results
261261
// of `cargo bench --bench bigint multiply`.
262262

263-
if x.len() <= 16 {
263+
if x.len() <= 32 {
264264
// Long multiplication:
265265
for (i, xi) in x.iter().enumerate() {
266266
mac_digit(&mut acc[i..], y, *xi);
267267
}
268-
} else if x.len() <= 300 {
268+
} else if x.len() <= 256 {
269269
/*
270270
* Karatsuba multiplication:
271271
*

0 commit comments

Comments
 (0)