Remove chunker.Reset() and chunker pool

This commit is contained in:
Florian Weingarten
2015-05-04 15:07:21 -04:00
parent c57c4f0b8f
commit 282c4379db
5 changed files with 32 additions and 93 deletions

View File

@@ -2,6 +2,7 @@ package restic_test
import (
"bytes"
"crypto/sha256"
"flag"
"io"
"testing"
@@ -25,9 +26,8 @@ type Rdr interface {
}
func benchmarkChunkEncrypt(b testing.TB, buf, buf2 []byte, rd Rdr, key *crypto.Key) {
ch := restic.GetChunker("BenchmarkChunkEncrypt")
rd.Seek(0, 0)
ch.Reset(rd, testPol)
ch := chunker.New(rd, testPol, sha256.New())
for {
chunk, err := ch.Next()
@@ -47,8 +47,6 @@ func benchmarkChunkEncrypt(b testing.TB, buf, buf2 []byte, rd Rdr, key *crypto.K
_, err = crypto.Encrypt(key, buf2, buf)
OK(b, err)
}
restic.FreeChunker("BenchmarkChunkEncrypt", ch)
}
func BenchmarkChunkEncrypt(b *testing.B) {
@@ -73,9 +71,7 @@ func BenchmarkChunkEncrypt(b *testing.B) {
}
func benchmarkChunkEncryptP(b *testing.PB, buf []byte, rd Rdr, key *crypto.Key) {
ch := restic.GetChunker("BenchmarkChunkEncryptP")
rd.Seek(0, 0)
ch.Reset(rd, testPol)
ch := chunker.New(rd, testPol, sha256.New())
for {
chunk, err := ch.Next()
@@ -88,8 +84,6 @@ func benchmarkChunkEncryptP(b *testing.PB, buf []byte, rd Rdr, key *crypto.Key)
io.ReadFull(chunk.Reader(rd), buf)
crypto.Encrypt(key, buf, buf)
}
restic.FreeChunker("BenchmarkChunkEncryptP", ch)
}
func BenchmarkChunkEncryptParallel(b *testing.B) {