1
0
mirror of https://github.com/golang/go synced 2024-11-26 11:58:07 -07:00

math/big: add shrVU and shlVU benchmarks

Change-Id: Id67d6ac856bd9271de99c3381bde910aa0c166e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/296011
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2021-01-04 13:34:29 -08:00
parent 414fa8c35e
commit b0df92703c

View File

@ -671,3 +671,27 @@ func BenchmarkDivWVW(b *testing.B) {
}) })
} }
} }
func BenchmarkNonZeroShifts(b *testing.B) {
for _, n := range benchSizes {
if isRaceBuilder && n > 1e3 {
continue
}
x := rndV(n)
s := uint(rand.Int63n(_W-2)) + 1 // avoid 0 and over-large shifts
z := make([]Word, n)
b.Run(fmt.Sprint(n), func(b *testing.B) {
b.SetBytes(int64(n * _W))
b.Run("shrVU", func(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = shrVU(z, x, s)
}
})
b.Run("shlVU", func(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = shlVU(z, x, s)
}
})
})
}
}