[Pkg-privacy-commits] [golang-siphash-dev] 02/23: Add benchmarks.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:55:52 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository golang-siphash-dev.

commit ef8dca3ecf23ccfd2f8872cb852320406b27159a
Author: Dmitry Chestnykh <dmitry at codingrobots.com>
Date:   Wed Jun 20 22:23:55 2012 +0200

    Add benchmarks.
---
 siphash_test.go | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/siphash_test.go b/siphash_test.go
index 8ae7ddf..a8fc086 100644
--- a/siphash_test.go
+++ b/siphash_test.go
@@ -12,3 +12,70 @@ func TestNew(t *testing.T) {
 		t.Errorf("expected %x, got %x", result, sum)
 	}
 }
+
+var key = []byte{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}
+var bench = New(key)
+var buf = make([]byte, 8<<10)
+
+func BenchmarkHash8(b *testing.B) {
+	b.SetBytes(8)
+	for i := 0; i < b.N; i++ {
+		bench.Reset()
+		bench.Write(buf[:8])
+		bench.Sum64()
+	}
+}
+
+func BenchmarkHash16(b *testing.B) {
+	b.SetBytes(16)
+	for i := 0; i < b.N; i++ {
+		bench.Reset()
+		bench.Write(buf[:16])
+		bench.Sum64()
+	}
+}
+
+func BenchmarkHash40(b *testing.B) {
+	b.SetBytes(24)
+	for i := 0; i < b.N; i++ {
+		bench.Reset()
+		bench.Write(buf[:16])
+		bench.Sum64()
+	}
+}
+
+func BenchmarkHash64(b *testing.B) {
+	b.SetBytes(64)
+	for i := 0; i < b.N; i++ {
+		bench.Reset()
+		bench.Write(buf[:64])
+		bench.Sum64()
+	}
+}
+
+func BenchmarkHash128(b *testing.B) {
+	b.SetBytes(128)
+	for i := 0; i < b.N; i++ {
+		bench.Reset()
+		bench.Write(buf[:64])
+		bench.Sum64()
+	}
+}
+
+func BenchmarkHash1K(b *testing.B) {
+	b.SetBytes(1024)
+	for i := 0; i < b.N; i++ {
+		bench.Reset()
+		bench.Write(buf[:1024])
+		bench.Sum64()
+	}
+}
+
+func BenchmarkHash8K(b *testing.B) {
+	b.SetBytes(int64(len(buf)))
+	for i := 0; i < b.N; i++ {
+		bench.Reset()
+		bench.Write(buf)
+		bench.Sum64()
+	}
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/golang-siphash-dev.git



More information about the Pkg-privacy-commits mailing list