diff options
author | Robert Griesemer <gri@golang.org> | 2010-04-27 14:06:53 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2010-04-27 14:06:53 -0700 |
commit | 76223bbf67314253ff78e6339d1c45d733a19beb (patch) | |
tree | febecb3cc0f82f32edefa2655530aa875a7671e4 | |
parent | e6c01834fe5aafc0d826f58482e510fdcf125b32 (diff) | |
download | go-76223bbf67314253ff78e6339d1c45d733a19beb.tar.gz |
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
-rw-r--r-- | test/bench/pidigits.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/bench/pidigits.go b/test/bench/pidigits.go index a05515028..3e455dc83 100644 --- a/test/bench/pidigits.go +++ b/test/bench/pidigits.go @@ -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) |