(t testing.TB, c RefSamplesCase)
| 33 | ) |
| 34 | |
| 35 | func 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. |
| 86 | type HistSTCase string |
searching dependent graphs…