mirror of
https://github.com/prometheus/prometheus.git
synced 2026-01-17 22:51:03 +01:00
harder test of st path
Signed-off-by: Owen Williams <owen.williams@grafana.com>
This commit is contained in:
parent
e44fcad3a9
commit
588d1ec006
@ -27,7 +27,7 @@ import (
|
||||
func TestEncodeDecode(t *testing.T) {
|
||||
for _, tcase := range []testrecord.RefSamplesCase{
|
||||
testrecord.Realistic1000Samples,
|
||||
testrecord.Realistic1000WithSTDeltaSamples,
|
||||
testrecord.Realistic1000WithVariableSTSamples,
|
||||
testrecord.Realistic1000WithConstSTSamples,
|
||||
testrecord.WorstCase1000,
|
||||
testrecord.WorstCase1000WithSTSamples,
|
||||
@ -85,7 +85,7 @@ var (
|
||||
compressions = []compression.Type{compression.None, compression.Snappy, compression.Zstd}
|
||||
dataCases = []testrecord.RefSamplesCase{
|
||||
testrecord.Realistic1000Samples,
|
||||
testrecord.Realistic1000WithSTDeltaSamples,
|
||||
testrecord.Realistic1000WithVariableSTSamples,
|
||||
testrecord.Realistic1000WithConstSTSamples,
|
||||
testrecord.WorstCase1000,
|
||||
testrecord.WorstCase1000WithSTSamples,
|
||||
@ -134,7 +134,7 @@ func BenchmarkEncode_Samples(b *testing.B) {
|
||||
|
||||
// func TestEncode(t *testing.T) {
|
||||
// var (
|
||||
// samples = testrecord.GenTestRefSamplesCase(t,testrecord.Realistic1000WithSTDeltaSamples)
|
||||
// samples = testrecord.GenTestRefSamplesCase(t, testrecord.Realistic1000WithVariableSTSamples)
|
||||
// enc = record.Encoder{STPerSample: UseV2}
|
||||
// buf []byte
|
||||
// cBuf []byte
|
||||
|
||||
@ -396,7 +396,8 @@ func (*Decoder) samplesV2(dec *encoding.Decbuf, samples []RefSample) ([]RefSampl
|
||||
case sameST:
|
||||
ST = prev.ST
|
||||
default:
|
||||
ST = firstT + dec.Varint64()
|
||||
v := dec.Varint64()
|
||||
ST = firstT - v
|
||||
}
|
||||
|
||||
val = dec.Be64()
|
||||
@ -833,7 +834,7 @@ func (*Encoder) samplesV2(samples []RefSample, b []byte) []byte {
|
||||
buf.PutByte(0)
|
||||
} else {
|
||||
buf.PutByte(explicitST)
|
||||
buf.PutVarint64(first.ST - first.T)
|
||||
buf.PutVarint64(first.T - first.ST)
|
||||
}
|
||||
buf.PutBE64(math.Float64bits(first.V))
|
||||
|
||||
@ -854,7 +855,7 @@ func (*Encoder) samplesV2(samples []RefSample, b []byte) []byte {
|
||||
buf.PutByte(sameST)
|
||||
default:
|
||||
buf.PutByte(explicitST)
|
||||
buf.PutVarint64(s.ST - first.T)
|
||||
buf.PutVarint64(first.T - s.ST)
|
||||
}
|
||||
buf.PutBE64(math.Float64bits(s.V))
|
||||
}
|
||||
|
||||
@ -24,11 +24,11 @@ import (
|
||||
type RefSamplesCase string
|
||||
|
||||
const (
|
||||
Realistic1000Samples RefSamplesCase = "real1000"
|
||||
Realistic1000WithSTDeltaSamples RefSamplesCase = "real1000-dst"
|
||||
Realistic1000WithConstSTSamples RefSamplesCase = "real1000-cst"
|
||||
WorstCase1000 RefSamplesCase = "worst1000"
|
||||
WorstCase1000WithSTSamples RefSamplesCase = "worst1000-st"
|
||||
Realistic1000Samples RefSamplesCase = "real1000"
|
||||
Realistic1000WithVariableSTSamples RefSamplesCase = "real1000-vst"
|
||||
Realistic1000WithConstSTSamples RefSamplesCase = "real1000-cst"
|
||||
WorstCase1000 RefSamplesCase = "worst1000"
|
||||
WorstCase1000WithSTSamples RefSamplesCase = "worst1000-st"
|
||||
)
|
||||
|
||||
func GenTestRefSamplesCase(t testing.TB, c RefSamplesCase) []record.RefSample {
|
||||
@ -44,7 +44,7 @@ func GenTestRefSamplesCase(t testing.TB, c RefSamplesCase) []record.RefSample {
|
||||
ret[i].V = highVarianceFloat(i)
|
||||
}
|
||||
// Likely the start times will all be the same with deltas.
|
||||
case Realistic1000WithSTDeltaSamples:
|
||||
case Realistic1000WithConstSTSamples:
|
||||
for i := range ret {
|
||||
ret[i].Ref = chunks.HeadSeriesRef(i)
|
||||
ret[i].ST = int64(12423423)
|
||||
@ -52,11 +52,11 @@ func GenTestRefSamplesCase(t testing.TB, c RefSamplesCase) []record.RefSample {
|
||||
ret[i].V = highVarianceFloat(i)
|
||||
}
|
||||
// Maybe series have different start times though
|
||||
case Realistic1000WithConstSTSamples:
|
||||
case Realistic1000WithVariableSTSamples:
|
||||
for i := range ret {
|
||||
ret[i].Ref = chunks.HeadSeriesRef(i)
|
||||
ret[i].ST = int64(12423423 + (i / 100))
|
||||
ret[i].T = int64(12423423 + 2000)
|
||||
ret[i].ST = int64((12423423 / 9) * (i % 10))
|
||||
ret[i].T = int64(12423423)
|
||||
ret[i].V = highVarianceFloat(i)
|
||||
}
|
||||
case WorstCase1000:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user