Преглед на файлове

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)
Josh Stone преди 7 години
родител
ревизия
1ddbee7f37
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      bigint/src/algorithms.rs

+ 2 - 2
bigint/src/algorithms.rs

@@ -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:
          *