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)
This commit is contained in:
Josh Stone 2017-09-20 13:19:00 -07:00
parent 28d84ca3ac
commit 1ddbee7f37
1 changed files with 2 additions and 2 deletions

View File

@ -260,12 +260,12 @@ fn mac3(acc: &mut [BigDigit], b: &[BigDigit], c: &[BigDigit]) {
// The thresholds are somewhat arbitrary, chosen by evaluating the results
// of `cargo bench --bench bigint multiply`.
if x.len() <= 16 {
if x.len() <= 32 {
// Long multiplication:
for (i, xi) in x.iter().enumerate() {
mac_digit(&mut acc[i..], y, *xi);
}
} else if x.len() <= 300 {
} else if x.len() <= 256 {
/*
* Karatsuba multiplication:
*