archive/zip: add flate writing benchmark

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/60530049
This commit is contained in:
Brad Fitzpatrick 2014-02-09 13:56:47 -08:00
parent 6ebf59b953
commit 730f51ab58
1 changed files with 18 additions and 0 deletions

View File

@ -125,3 +125,21 @@ func testReadFile(t *testing.T, f *File, wt *WriteTest) {
t.Errorf("File contents %q, want %q", b, wt.Data)
}
}
func BenchmarkCompressedZipGarbage(b *testing.B) {
b.ReportAllocs()
var buf bytes.Buffer
bigBuf := bytes.Repeat([]byte("a"), 1<<20)
for i := 0; i < b.N; i++ {
buf.Reset()
zw := NewWriter(&buf)
for j := 0; j < 3; j++ {
w, _ := zw.CreateHeader(&FileHeader{
Name: "foo",
Method: Deflate,
})
w.Write(bigBuf)
}
zw.Close()
}
}