Commit 730f51ab authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

archive/zip: add flate writing benchmark

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/60530049
parent 6ebf59b9
......@@ -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()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment