MCPcopy Index your code
hub / github.com/prometheus/prometheus / BenchmarkEncode

Function BenchmarkEncode

util/compression/compression_test.go:149–167  ·  view source on GitHub ↗

* export bench=encode-v1 && go test ./util/compression/... \ -run '^$' -bench '^BenchmarkEncode' \ -benchtime 5s -count 6 -cpu 2 -timeout 999m \ | tee ${bench}.txt */

(b *testing.B)

Source from the content-addressed store, hash-verified

147 | tee ${bench}.txt
148*/
149func BenchmarkEncode(b *testing.B) {
150 for _, typ := range Types() {
151 b.Run(fmt.Sprintf("type=%v", typ), func(b *testing.B) {
152 var buf EncodeBuffer
153 compressible := []byte(compressible)
154
155 b.ReportAllocs()
156 b.ResetTimer()
157 for b.Loop() {
158 if buf == nil {
159 buf = NewSyncEncodeBuffer()
160 }
161 res, err := Encode(typ, compressible, buf)
162 require.NoError(b, err)
163 b.ReportMetric(float64(len(res)), "B")
164 }
165 })
166 }
167}
168
169/*
170 export bench=decode-v1 && go test ./util/compression/... \

Callers

nothing calls this directly

Calls 4

TypesFunction · 0.85
NewSyncEncodeBufferFunction · 0.85
EncodeFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…