aboutsummaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2021-01-04 13:34:29 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2021-03-07 23:02:35 +0000
commitb0df92703c89e42592659ae99cded0d5b68382b7 (patch)
treec0bee6040836350df5d876f61b42716b993475f8 /src/math
parent414fa8c35e7c2f65e2c767d6db2f25791e53b5c1 (diff)
downloadgo-b0df92703c89e42592659ae99cded0d5b68382b7.tar.gz
go-b0df92703c89e42592659ae99cded0d5b68382b7.zip
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>
Diffstat (limited to 'src/math')
-rw-r--r--src/math/big/arith_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/math/big/arith_test.go b/src/math/big/arith_test.go
index 2aca0effde..7b3427f834 100644
--- a/src/math/big/arith_test.go
+++ b/src/math/big/arith_test.go
@@ -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)
+ }
+ })
+ })
+ }
+}