From 4b9df00fc8f4bd26a7e92567077b6a76b4c80dec Mon Sep 17 00:00:00 2001 From: Arseny Balobanov Date: Sat, 7 May 2022 15:11:26 +0300 Subject: [PATCH] [gzep] Fix compression level. --- gzep/README.md | 6 +++--- gzep/encode_test.go | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gzep/README.md b/gzep/README.md index 489ac7c..c6ab3bb 100644 --- a/gzep/README.md +++ b/gzep/README.md @@ -9,11 +9,11 @@ goarch: amd64 pkg: gitlab.com/slon/shad-go/gzep cpu: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz BenchmarkEncodeSimple -BenchmarkEncodeSimple-8 8307 124841 ns/op 813872 B/op 17 allocs/op +BenchmarkEncodeSimple-8 7047 176628 ns/op 813872 B/op 17 allocs/op BenchmarkEncode -BenchmarkEncode-8 2094512 620.0 ns/op 0 B/op 0 allocs/op +BenchmarkEncode-8 41706 32616 ns/op 19 B/op 0 allocs/op PASS -ok gitlab.com/slon/shad-go/gzep 3.756s +ok gitlab.com/slon/shad-go/gzep 3.625s ``` ### С чего начать? diff --git a/gzep/encode_test.go b/gzep/encode_test.go index 0b98dde..211ad04 100644 --- a/gzep/encode_test.go +++ b/gzep/encode_test.go @@ -67,6 +67,13 @@ func TestEncode_Stress(t *testing.T) { wg.Wait() } +func TestEncode_Compression(t *testing.T) { + buf := new(bytes.Buffer) + err := gzep.Encode(bytes.Repeat([]byte{0x1f}, 1000), buf) + require.NoError(t, err) + require.Less(t, buf.Len(), 1000) +} + func decode(r io.Reader) ([]byte, error) { rr, err := gzip.NewReader(r) if err != nil {