MCPcopy
hub / github.com/prometheus/prometheus / BenchmarkEncode_Samples

Function BenchmarkEncode_Samples

tsdb/record/bench_test.go:141–174  ·  view source on GitHub ↗

nolint:godot * go test ./tsdb/record/... \ -run '^$' -bench '^BenchmarkEncode_Samples' \ -benchtime 5s -count 6 -cpu 2 -timeout 999m \ | tee encode.txt benchstat -col /version encode.txt */

(b *testing.B)

Source from the content-addressed store, hash-verified

139benchstat -col /version encode.txt
140*/
141func BenchmarkEncode_Samples(b *testing.B) {
142 for _, ver := range versions {
143 for _, compr := range compressions {
144 for _, data := range dataCases {
145 b.Run(fmt.Sprintf("version=%s/compr=%v/data=%v", ver.name, compr, data), func(b *testing.B) {
146 var (
147 samples = testrecord.GenTestRefSamplesCase(b, data)
148 enc = record.Encoder{EnableSTStorage: ver.enableST}
149 buf []byte
150 cBuf []byte
151 )
152
153 cEnc, err := compression.NewEncoder()
154 require.NoError(b, err)
155
156 // Warm up.
157 buf = enc.Samples(samples, buf[:0])
158 cBuf, _, err = cEnc.Encode(compr, buf, cBuf[:0])
159 require.NoError(b, err)
160
161 b.ReportAllocs()
162 b.ResetTimer()
163 for b.Loop() {
164 buf = enc.Samples(samples, buf[:0])
165 b.ReportMetric(float64(len(buf)), "B/rec")
166
167 cBuf, _, _ = cEnc.Encode(compr, buf, cBuf[:0])
168 b.ReportMetric(float64(len(cBuf)), "B/compressed-rec")
169 }
170 })
171 }
172 }
173 }
174}
175
176//nolint:godot
177/*

Callers

nothing calls this directly

Calls 5

EncodeMethod · 0.95
GenTestRefSamplesCaseFunction · 0.92
NewEncoderFunction · 0.92
RunMethod · 0.65
SamplesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…