]> Cypherpunks repositories - gostls13.git/commitdiff
mat/big: more optimal Karatsuba threshold
authorRobert Griesemer <gri@golang.org>
Thu, 12 Jul 2012 21:19:09 +0000 (14:19 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 12 Jul 2012 21:19:09 +0000 (14:19 -0700)
benchmark           old ns/op    new ns/op    delta
BenchmarkHilbert      6253043      6267289   +0.23%
BenchmarkMul         45355940     39490633  -12.93%

R=r
CC=golang-dev
https://golang.org/cl/6355104

src/pkg/math/big/nat.go

index 04f5dfd8babf82c17adb9192ef59dd2768f1a651..85b9acc0f5113f8ba3998fc9c0f01f460242091c 100644 (file)
@@ -236,7 +236,7 @@ func karatsubaSub(z, x nat, n int) {
 // Operands that are shorter than karatsubaThreshold are multiplied using
 // "grade school" multiplication; for longer operands the Karatsuba algorithm
 // is used.
-var karatsubaThreshold int = 32 // computed by calibrate.go
+var karatsubaThreshold int = 40 // computed by calibrate.go
 
 // karatsuba multiplies x and y and leaves the result in z.
 // Both x and y must have the same length n and n must be a