Slightly improve performance for chunker

benchcmp output:

benchmark                      old ns/op     new ns/op     delta
BenchmarkChunkerWithSHA256     151752169     148072829     -2.42%
BenchmarkChunkerWithMD5        97166433      93357090      -3.92%
BenchmarkChunker               77265146      73642723      -4.69%

benchmark                      old MB/s     new MB/s     speedup
BenchmarkChunkerWithSHA256     69.10        70.81        1.02x
BenchmarkChunkerWithMD5        107.92       112.32       1.04x
BenchmarkChunker               135.71       142.39       1.05x

benchmark                      old allocs     new allocs     delta
BenchmarkChunkerWithSHA256     15             13             -13.33%
BenchmarkChunkerWithMD5        14             12             -14.29%
BenchmarkChunker               8              6              -25.00%

benchmark                      old bytes     new bytes     delta
BenchmarkChunkerWithSHA256     262924        26821         -89.80%
BenchmarkChunkerWithMD5        262774        13554         -94.84%
BenchmarkChunker               262678        13458         -94.88%
This commit is contained in:
Alexander Neumann committed 2015-02-13 20:03:40 +01:00
1 parent 0f36b19a4c
commit 59cfc4bd03
2 files changed
+12 -4

No files matched your search

+2 -1
View File
@@ -256,13 +256,14 @@ func benchmarkChunker(b *testing.B, hash hash.Hash) {
b.ResetTimer()
b.SetBytes(int64(size))
ch := chunker.New(rd, *testBufSize, hash)
var chunks int
for i := 0; i < b.N; i++ {
chunks = 0
rd.Seek(0, 0)
ch := chunker.New(rd, *testBufSize, hash)
ch.Reset(rd)
for {
_, err := ch.Next()