MCPcopy
hub / github.com/prometheus/prometheus / GenTestRefSamplesCase

Function GenTestRefSamplesCase

util/testrecord/record.go:35–83  ·  view source on GitHub ↗
(t testing.TB, c RefSamplesCase)

Source from the content-addressed store, hash-verified

33)
34
35func GenTestRefSamplesCase(t testing.TB, c RefSamplesCase) []record.RefSample {
36 t.Helper()
37
38 ret := make([]record.RefSample, 1e3)
39 switch c {
40 // Samples are across series, so likely all have the same timestamp.
41 case Realistic1000Samples:
42 for i := range ret {
43 ret[i].Ref = chunks.HeadSeriesRef(i)
44 ret[i].T = int64(12423423)
45 ret[i].V = highVarianceFloat(i)
46 }
47 // Likely the start times will all be the same with deltas.
48 case Realistic1000WithConstSTSamples:
49 for i := range ret {
50 ret[i].Ref = chunks.HeadSeriesRef(i)
51 ret[i].ST = int64(12423423)
52 ret[i].T = int64(12423423 + 15)
53 ret[i].V = highVarianceFloat(i)
54 }
55 // Maybe series have different start times though
56 case Realistic1000WithVariableSTSamples:
57 for i := range ret {
58 ret[i].Ref = chunks.HeadSeriesRef(i)
59 ret[i].ST = int64((12423423 / 9) * (i % 10))
60 ret[i].T = int64(12423423)
61 ret[i].V = highVarianceFloat(i)
62 }
63 case WorstCase1000:
64 for i := range ret {
65 ret[i].Ref = chunks.HeadSeriesRef(i)
66 ret[i].T = highVarianceInt(i)
67 ret[i].V = highVarianceFloat(i)
68 }
69 case WorstCase1000WithSTSamples:
70 for i := range ret {
71 ret[i].Ref = chunks.HeadSeriesRef(i)
72
73 // Worst case is when the values are significantly different
74 // to each other which breaks delta encoding.
75 ret[i].ST = highVarianceInt(i+1) / 1024 // Make sure ST is not comparable to T
76 ret[i].T = highVarianceInt(i)
77 ret[i].V = highVarianceFloat(i)
78 }
79 default:
80 t.Fatal("unknown case", c)
81 }
82 return ret
83}
84
85// HistSTCase selects the start-time pattern for histogram test data generators.
86type HistSTCase string

Callers 3

TestEncodeDecodeFunction · 0.92
BenchmarkEncode_SamplesFunction · 0.92
BenchmarkDecode_SamplesFunction · 0.92

Calls 3

HeadSeriesRefTypeAlias · 0.92
highVarianceFloatFunction · 0.85
highVarianceIntFunction · 0.85

Tested by 3

TestEncodeDecodeFunction · 0.74
BenchmarkEncode_SamplesFunction · 0.74
BenchmarkDecode_SamplesFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…