1
0
mirror of https://github.com/fumiama/blake2b-simd.git synced 2026-06-11 21:50:30 +08:00

Fix benchmarks to report proper values. (#7)

```
$ go test -run=NONE -bench .
PASS
BenchmarkHash64-4  	 1000000	      1036 ns/op	  61.77 MB/s
BenchmarkHash128-4 	 2000000	       801 ns/op	 159.67 MB/s
BenchmarkHash1K-4  	  500000	      2464 ns/op	 415.53 MB/s
BenchmarkHash8K-4  	  200000	     11212 ns/op	 730.60 MB/s
BenchmarkHash32K-4 	   30000	     40766 ns/op	 803.80 MB/s
BenchmarkHash128K-4	   10000	    163170 ns/op	 803.28 MB/s
ok  	github.com/minio/blake2b-simd	10.298s
```
This commit is contained in:
Harshavardhana
2016-07-03 12:58:02 -07:00
committed by Frank
parent 00562011ad
commit cf4f8e0c34
6 changed files with 63 additions and 79 deletions

View File

@@ -601,50 +601,41 @@ var goldenKeyed = []string{
var bench = New512()
var buf = make([]byte, 128*1024)
func benchmarkSize(b *testing.B, size int) {
b.SetBytes(int64(size))
for i := 0; i < b.N; i++ {
bench.Reset()
bench.Write(buf[:size])
bench.Sum(nil)
}
}
// Benchmark writes of 64 bytes.
func BenchmarkHash64(b *testing.B) {
b.SetBytes(64)
for i := 0; i < b.N; i++ {
Sum512(buf[:64])
}
benchmarkSize(b, 64)
}
// Benchmark writes of 128 bytes.
func BenchmarkHash128(b *testing.B) {
b.SetBytes(128)
for i := 0; i < b.N; i++ {
Sum512(buf[:128])
}
benchmarkSize(b, 128)
}
// Benchmark writes of 1KiB bytes.
func BenchmarkWrite1K(b *testing.B) {
b.SetBytes(1024)
for i := 0; i < b.N; i++ {
bench.Write(buf[:1024])
}
func BenchmarkHash1K(b *testing.B) {
benchmarkSize(b, 1024)
}
// Benchmark writes of 8KiB bytes.
func BenchmarkWrite8K(b *testing.B) {
b.SetBytes(int64(len(buf)))
for i := 0; i < b.N; i++ {
bench.Write(buf[:8192])
}
func BenchmarkHash8K(b *testing.B) {
benchmarkSize(b, 8*1024)
}
// Benchmark writes of 32KiB bytes.
func BenchmarkWrite32K(b *testing.B) {
b.SetBytes(int64(len(buf)))
for i := 0; i < b.N; i++ {
bench.Write(buf[:32*1024])
}
func BenchmarkHash32K(b *testing.B) {
benchmarkSize(b, 32*1024)
}
// Benchmark writes of 128KiB bytes.
func BenchmarkWrite128K(b *testing.B) {
b.SetBytes(int64(len(buf)))
for i := 0; i < b.N; i++ {
bench.Write(buf)
}
func BenchmarkHash128K(b *testing.B) {
benchmarkSize(b, 128*1024)
}