| 76 | } |
| 77 | |
| 78 | func testHistogram(count, numSpans, numBuckets int) *histogram.Histogram { |
| 79 | bucketsPerSide := numBuckets / 2 |
| 80 | spanLength := uint32(bucketsPerSide / numSpans) |
| 81 | h := &histogram.Histogram{ |
| 82 | CounterResetHint: histogram.GaugeType, |
| 83 | Count: uint64(count), |
| 84 | ZeroCount: uint64(count), |
| 85 | ZeroThreshold: 1e-128, |
| 86 | Sum: 18.4 * float64(count+1), |
| 87 | Schema: 2, |
| 88 | NegativeSpans: make([]histogram.Span, numSpans), |
| 89 | PositiveSpans: make([]histogram.Span, numSpans), |
| 90 | NegativeBuckets: make([]int64, bucketsPerSide), |
| 91 | PositiveBuckets: make([]int64, bucketsPerSide), |
| 92 | } |
| 93 | for j := range numSpans { |
| 94 | s := histogram.Span{Offset: 1, Length: spanLength} |
| 95 | h.NegativeSpans[j] = s |
| 96 | h.PositiveSpans[j] = s |
| 97 | } |
| 98 | |
| 99 | for j := range bucketsPerSide { |
| 100 | h.NegativeBuckets[j] = 1 |
| 101 | h.PositiveBuckets[j] = 1 |
| 102 | } |
| 103 | return h |
| 104 | } |