1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // This benchmark tests gzip and gunzip performance.
18 jsongunz = bytes.Repeat(jsonbytes, 10)
24 c := gz.NewWriter(&buf)
31 c := gz.NewWriter(ioutil.Discard)
32 if _, err := c.Write(jsongunz); err != nil {
35 if err := c.Close(); err != nil {
41 r, err := gz.NewReader(bytes.NewBuffer(jsongz))
45 if _, err := io.Copy(ioutil.Discard, r); err != nil {
51 func BenchmarkGzip(b *testing.B) {
52 b.SetBytes(int64(len(jsongunz)))
53 for i := 0; i < b.N; i++ {
58 func BenchmarkGunzip(b *testing.B) {
59 b.SetBytes(int64(len(jsongunz)))
60 for i := 0; i < b.N; i++ {