mirror of https://github.com/golang/go.git
archive/zip: add flate writing benchmark
LGTM=adg R=adg CC=golang-codereviews https://golang.org/cl/60530049
This commit is contained in:
parent
6ebf59b953
commit
730f51ab58
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue