MCPcopy Create free account
hub / github.com/cortexproject/cortex / BenchmarkCompress

Function BenchmarkCompress

pkg/util/grpcencoding/encoding_test.go:87–115  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

85}
86
87func BenchmarkCompress(b *testing.B) {
88 data := []byte(strings.Repeat("123456789", 1024))
89
90 testCases := []struct {
91 name string
92 }{
93 {
94 name: snappy.Name,
95 },
96 {
97 name: snappyblock.Name,
98 },
99 {
100 name: zstd.Name,
101 },
102 }
103
104 for _, tc := range testCases {
105 b.Run(tc.name, func(b *testing.B) {
106 c := encoding.GetCompressor(tc.name)
107 for b.Loop() {
108 w, _ := c.Compress(io.Discard)
109 _, _ = w.Write(data)
110 _ = w.Close()
111 }
112 b.ReportAllocs()
113 })
114 }
115}
116
117func BenchmarkDecompress(b *testing.B) {
118 data := []byte(strings.Repeat("123456789", 1024))

Callers

nothing calls this directly

Calls 5

LoopMethod · 0.80
RunMethod · 0.65
CloseMethod · 0.65
CompressMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected