aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/sha512/sha512_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/sha512/sha512_test.go')
-rw-r--r--src/crypto/sha512/sha512_test.go32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/crypto/sha512/sha512_test.go b/src/crypto/sha512/sha512_test.go
index 99d1423527..921cdbb7bb 100644
--- a/src/crypto/sha512/sha512_test.go
+++ b/src/crypto/sha512/sha512_test.go
@@ -8,6 +8,7 @@ package sha512
import (
"bytes"
+ "crypto/internal/boring"
"crypto/rand"
"encoding"
"encoding/hex"
@@ -17,8 +18,6 @@ import (
"testing"
)
-import "crypto/internal/boring"
-
type sha512Test struct {
out string
in string
@@ -914,13 +913,30 @@ var bench = New()
var buf = make([]byte, 8192)
func benchmarkSize(b *testing.B, size int) {
- b.SetBytes(int64(size))
sum := make([]byte, bench.Size())
- for i := 0; i < b.N; i++ {
- bench.Reset()
- bench.Write(buf[:size])
- bench.Sum(sum[:0])
- }
+ b.Run("New", func(b *testing.B) {
+ b.ReportAllocs()
+ b.SetBytes(int64(size))
+ for i := 0; i < b.N; i++ {
+ bench.Reset()
+ bench.Write(buf[:size])
+ bench.Sum(sum[:0])
+ }
+ })
+ b.Run("Sum384", func(b *testing.B) {
+ b.ReportAllocs()
+ b.SetBytes(int64(size))
+ for i := 0; i < b.N; i++ {
+ Sum384(buf[:size])
+ }
+ })
+ b.Run("Sum512", func(b *testing.B) {
+ b.ReportAllocs()
+ b.SetBytes(int64(size))
+ for i := 0; i < b.N; i++ {
+ Sum512(buf[:size])
+ }
+ })
}
func BenchmarkHash8Bytes(b *testing.B) {