aboutsummaryrefslogtreecommitdiff
path: root/src/math/big/arith_test.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2017-03-23 10:54:08 -0700
committerRobert Griesemer <gri@golang.org>2017-03-23 19:43:09 +0000
commit70ea0ec30fe37326d24249d9c9330be1ad655a90 (patch)
tree68c929ee71004d48e0c6d45f39e3c88d68581b81 /src/math/big/arith_test.go
parent536a2257fba6dd18c74506988bdf3d6a15e52831 (diff)
downloadgo-70ea0ec30fe37326d24249d9c9330be1ad655a90.tar.gz
go-70ea0ec30fe37326d24249d9c9330be1ad655a90.zip
math/big: replace local versions of bitLen, nlz with math/bits versions
Verified that BenchmarkBitLen time went down from 2.25 ns/op to 0.65 ns/op an a 2.3 GHz Intel Core i7, before removing that benchmark (now covered by math/bits benchmarks). Change-Id: I3890bb7d1889e95b9a94bd68f0bdf06f1885adeb Reviewed-on: https://go-review.googlesource.com/38464 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/math/big/arith_test.go')
-rw-r--r--src/math/big/arith_test.go29
1 files changed, 0 insertions, 29 deletions
diff --git a/src/math/big/arith_test.go b/src/math/big/arith_test.go
index f2b3083000..13b0436ab4 100644
--- a/src/math/big/arith_test.go
+++ b/src/math/big/arith_test.go
@@ -395,32 +395,3 @@ func BenchmarkAddMulVVW(b *testing.B) {
})
}
}
-
-func testWordBitLen(t *testing.T, fname string, f func(Word) int) {
- for i := 0; i <= _W; i++ {
- x := Word(1) << uint(i-1) // i == 0 => x == 0
- n := f(x)
- if n != i {
- t.Errorf("got %d; want %d for %s(%#x)", n, i, fname, x)
- }
- }
-}
-
-func TestWordBitLen(t *testing.T) {
- testWordBitLen(t, "bitLen", bitLen)
- testWordBitLen(t, "bitLen_g", bitLen_g)
-}
-
-// runs b.N iterations of bitLen called on a Word containing (1 << nbits)-1.
-func BenchmarkBitLen(b *testing.B) {
- // Individual bitLen tests. Numbers chosen to examine both sides
- // of powers-of-two boundaries.
- for _, nbits := range []uint{0, 1, 2, 3, 4, 5, 8, 9, 16, 17, 31} {
- testword := Word((uint64(1) << nbits) - 1)
- b.Run(fmt.Sprint(nbits), func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- bitLen(testword)
- }
- })
- }
-}