From 19030efe9ed9927f30918cff853097084fce5ba2 Mon Sep 17 00:00:00 2001 From: Arseny Balobanov Date: Thu, 5 May 2022 19:20:16 +0300 Subject: [PATCH] [vegz] Rename to gzep. --- {vegz => gzep}/README.md | 6 +++--- {vegz => gzep}/encode.go | 2 +- {vegz => gzep}/encode_test.go | 2 +- vegz/solution.go | 31 ------------------------------- 4 files changed, 5 insertions(+), 36 deletions(-) rename {vegz => gzep}/README.md (89%) rename {vegz => gzep}/encode.go (94%) rename {vegz => gzep}/encode_test.go (98%) delete mode 100644 vegz/solution.go diff --git a/vegz/README.md b/gzep/README.md similarity index 89% rename from vegz/README.md rename to gzep/README.md index 30ae47a..cec4851 100644 --- a/vegz/README.md +++ b/gzep/README.md @@ -1,4 +1,4 @@ -## vegz [runtime] +## gzep [runtime] В этой задаче нужно победить бенчмарк, переписав функцию сериализации в `gzip`. @@ -6,14 +6,14 @@ ``` goos: linux goarch: amd64 -pkg: gitlab.com/slon/shad-go/vegz +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 BenchmarkEncode BenchmarkEncode-8 2094512 620.0 ns/op 0 B/op 0 allocs/op PASS -ok gitlab.com/slon/shad-go/vegz 3.756s +ok gitlab.com/slon/shad-go/gzep 3.756s ``` ### С чего начать? diff --git a/vegz/encode.go b/gzep/encode.go similarity index 94% rename from vegz/encode.go rename to gzep/encode.go index 37b8cd0..53feff2 100644 --- a/vegz/encode.go +++ b/gzep/encode.go @@ -1,6 +1,6 @@ //go:build !solution -package vegz +package gzep import ( "compress/gzip" diff --git a/vegz/encode_test.go b/gzep/encode_test.go similarity index 98% rename from vegz/encode_test.go rename to gzep/encode_test.go index 6bd1e58..2abcf87 100644 --- a/vegz/encode_test.go +++ b/gzep/encode_test.go @@ -1,4 +1,4 @@ -package vegz +package gzep import ( "bytes" diff --git a/vegz/solution.go b/vegz/solution.go deleted file mode 100644 index 2f6eb2c..0000000 --- a/vegz/solution.go +++ /dev/null @@ -1,31 +0,0 @@ -//go:build solution - -package vegz - -import ( - "compress/gzip" - "io" - "sync" -) - -var writerPool = sync.Pool{ - New: func() interface{} { - return new(gzip.Writer) - }, -} - -func Encode(data []byte, w io.Writer) error { - ww := writerPool.Get().(*gzip.Writer) - defer func() { - _ = ww.Close() - writerPool.Put(ww) - }() - - ww.Reset(w) - - if _, err := ww.Write(data); err != nil { - return err - } - - return ww.Close() -}