@cryptotaxi247 / kubo / commits / 61b473409

add a benchmark for our hash function

Jeromy committed Apr 28, 2015 at 01:30 UTC 61b47340914d8a8418b6f92a13c738d90933a983
1 file changed +30
util/util_test.go
+30
@@ -53,3 +53,33 @@ func TestXOR(t *testing.T) {
53 }
54 }
55 }
56 +
57 +func BenchmarkHash256K(b *testing.B) {
58 + buf := make([]byte, 256*1024)
59 + NewTimeSeededRand().Read(buf)
60 + b.SetBytes(int64(256 * 1024))
61 + b.ResetTimer()
62 + for i := 0; i < b.N; i++ {
63 + Hash(buf)
64 + }
65 +}
66 +
67 +func BenchmarkHash512K(b *testing.B) {
68 + buf := make([]byte, 512*1024)
69 + NewTimeSeededRand().Read(buf)
70 + b.SetBytes(int64(512 * 1024))
71 + b.ResetTimer()
72 + for i := 0; i < b.N; i++ {
73 + Hash(buf)
74 + }
75 +}
76 +
77 +func BenchmarkHash1M(b *testing.B) {
78 + buf := make([]byte, 1024*1024)
79 + NewTimeSeededRand().Read(buf)
80 + b.SetBytes(int64(1024 * 1024))
81 + b.ResetTimer()
82 + for i := 0; i < b.N; i++ {
83 + Hash(buf)
84 + }
85 +}