summaryrefslogtreecommitdiff
path: root/libgo/go/crypto/hmac/hmac_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/crypto/hmac/hmac_test.go')
-rw-r--r--libgo/go/crypto/hmac/hmac_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/libgo/go/crypto/hmac/hmac_test.go b/libgo/go/crypto/hmac/hmac_test.go
index e80b7e0baa..aac9aa96a8 100644
--- a/libgo/go/crypto/hmac/hmac_test.go
+++ b/libgo/go/crypto/hmac/hmac_test.go
@@ -568,3 +568,29 @@ func TestEqual(t *testing.T) {
t.Error("Equal accepted unequal slices")
}
}
+
+func BenchmarkHMACSHA256_1K(b *testing.B) {
+ key := make([]byte, 32)
+ buf := make([]byte, 1024)
+ h := New(sha256.New, key)
+ b.SetBytes(int64(len(buf)))
+ for i := 0; i < b.N; i++ {
+ h.Write(buf)
+ h.Reset()
+ mac := h.Sum(nil)
+ buf[0] = mac[0]
+ }
+}
+
+func BenchmarkHMACSHA256_32(b *testing.B) {
+ key := make([]byte, 32)
+ buf := make([]byte, 32)
+ h := New(sha256.New, key)
+ b.SetBytes(int64(len(buf)))
+ for i := 0; i < b.N; i++ {
+ h.Write(buf)
+ h.Reset()
+ mac := h.Sum(nil)
+ buf[0] = mac[0]
+ }
+}