mirror of
https://github.com/golang/go
synced 2024-11-21 13:44:45 -07:00
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 https://golang.org/cl/1021041
This commit is contained in:
parent
e42ebea96c
commit
2f480b10e2
@ -63,7 +63,7 @@ func extract_digit() int64 {
|
||||
}
|
||||
|
||||
// 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)
|
||||
@ -84,7 +84,7 @@ func next_term(k int64) {
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user