Commits

Eric Roshan Eisner  committed 959e3b1 Draft

benchmarks: update to match new stdlib style

  • Participants
  • Parent commits e7e3280

Comments (0)

Files changed (1)

File sha3_test.go

 }
 
 var bench = New256()
-var message = make([]byte, 8<<10)
+var buf = make([]byte, 8192)
 
-func benchmark(b *testing.B, size int64) {
-	b.SetBytes(size)
+func benchmarkSize(b *testing.B, size int) {
+	b.SetBytes(int64(size))
+	sum := make([]byte, bench.Size())
 	for i := 0; i < b.N; i++ {
-		bench.Write(message[:size])
+		bench.Reset()
+		bench.Write(buf[:size])
+		bench.Sum(sum[:0])
 	}
 }
 
-func BenchmarkHash1K(b *testing.B) { benchmark(b, 1<<10) }
-func BenchmarkHash8K(b *testing.B) { benchmark(b, 8<<10) }
+func BenchmarkHash8Bytes(b *testing.B) {
+	benchmarkSize(b, 8)
+}
 
-func BenchmarkShortHash(b *testing.B) {
-	sum := make([]byte, bench.Size())
-	for i := 0; i < b.N; i++ {
-		bench.Reset()
-		bench.Write(message[:10])
-		bench.Sum(sum[:0])
-	}
+func BenchmarkHash1K(b *testing.B) {
+	benchmarkSize(b, 1024)
 }
+
+func BenchmarkHash8K(b *testing.B) {
+	benchmarkSize(b, 8192)
+}