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

Function TestTimeseriesFromPool

pkg/cortexpb/timeseries_test.go:50–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestTimeseriesFromPool(t *testing.T) {
51 t.Run("new instance is provided when not available to reuse", func(t *testing.T) {
52 first := TimeseriesFromPool()
53 second := TimeseriesFromPool()
54
55 assert.NotSame(t, first, second)
56 })
57
58 t.Run("instance is cleaned before reusing", func(t *testing.T) {
59 ts := TimeseriesFromPool()
60 ts.Labels = []LabelAdapter{{Name: "foo", Value: "bar"}}
61 ts.Samples = []Sample{{Value: 1, TimestampMs: 2}}
62 ReuseTimeseries(ts)
63
64 reused := TimeseriesFromPool()
65 assert.Len(t, reused.Labels, 0)
66 assert.Len(t, reused.Samples, 0)
67 })
68}
69
70func BenchmarkMarshallWriteRequest(b *testing.B) {
71 ts := PreallocTimeseriesSliceFromPool()

Callers

nothing calls this directly

Calls 4

TimeseriesFromPoolFunction · 0.85
ReuseTimeseriesFunction · 0.85
RunMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected