Commits

Anonymous committed 4623445

pidigits: ~10% performance win by using adds instead of shifts

user time for pidigits -s -n=10000:
6.466s w/ adds
7.138s w/ shifts

R=rsc
CC=golang-dev
http://codereview.appspot.com/1021041

Comments (0)

Files changed (1)

test/bench/pidigits.go

 	}
 
 	// Compute (numer * 3 + accum) / denom
-	tmp1.Lsh(numer, 1)
+	tmp1.Add(numer, numer) // tmp1.Lsh(numer, 1)
 	tmp1.Add(tmp1, numer)
 	tmp1.Add(tmp1, accum)
 	tmp1.DivMod(tmp1, denom, tmp2)
 	y2.New(k*2 + 1)
 	bigk.New(k)
 
-	tmp1.Lsh(numer, 1)
+	tmp1.Add(numer, numer) // tmp1.Lsh(numer, 1)
 	accum.Add(accum, tmp1)
 	accum.Mul(accum, y2)
 	numer.Mul(numer, bigk)