mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-28 04:02:21 -04:00
kill hist bench cleanup for now
Signed-off-by: bwplotka <bwplotka@gmail.com>
This commit is contained in:
parent
968b85e1cc
commit
3e53daa9d4
1 changed files with 4 additions and 104 deletions
|
|
@ -7,17 +7,15 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/prometheus/prometheus/model/histogram"
|
||||
)
|
||||
|
||||
/*
|
||||
export bench=chunkenc && go test \
|
||||
-run '^$' -bench '^BenchmarkChunkEnc' \
|
||||
-run '^$' -bench '^BenchmarkChunk' \
|
||||
-benchtime 5s -count 6 -cpu 2 -timeout 999m \
|
||||
| tee ${bench}.txt
|
||||
*/
|
||||
func BenchmarkChunkEnc(b *testing.B) {
|
||||
func BenchmarkChunk(b *testing.B) {
|
||||
r := rand.New(rand.NewSource(1))
|
||||
|
||||
for _, data := range []struct {
|
||||
|
|
@ -47,13 +45,13 @@ func BenchmarkChunkEnc(b *testing.B) {
|
|||
} {
|
||||
b.Run("data="+data.name, func(b *testing.B) {
|
||||
b.Run("format=XOR", func(b *testing.B) {
|
||||
benchmarkChunkEnc(b, data.deltas, func() Chunk { return NewXORChunk() })
|
||||
benchmarkChunk(b, data.deltas, func() Chunk { return NewXORChunk() })
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func benchmarkChunkEnc(b *testing.B, deltas func() (int64, float64), newChunk func() Chunk) {
|
||||
func benchmarkChunk(b *testing.B, deltas func() (int64, float64), newChunk func() Chunk) {
|
||||
var (
|
||||
t = int64(1234123324)
|
||||
v = 1243535.123
|
||||
|
|
@ -128,101 +126,3 @@ func benchmarkChunkEnc(b *testing.B, deltas func() (int64, float64), newChunk fu
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
export bench=histchunkenc && go test \
|
||||
-run '^$' -bench '^BenchmarkHistogramChunkEnc' \
|
||||
-benchtime 5s -count 6 -cpu 2 -timeout 999m \
|
||||
| tee ${bench}.txt
|
||||
*/
|
||||
func BenchmarkHistogramChunkEnc(b *testing.B) {
|
||||
// Create a histogram with a bunch of spans and buckets.
|
||||
const (
|
||||
numSpans = 1000
|
||||
spanLength = 10
|
||||
)
|
||||
h := &histogram.Histogram{
|
||||
Schema: 0,
|
||||
Count: 100,
|
||||
Sum: 1000,
|
||||
ZeroThreshold: 0.001,
|
||||
ZeroCount: 5,
|
||||
}
|
||||
for range numSpans {
|
||||
h.PositiveSpans = append(h.PositiveSpans, histogram.Span{Offset: 5, Length: spanLength})
|
||||
h.NegativeSpans = append(h.NegativeSpans, histogram.Span{Offset: 5, Length: spanLength})
|
||||
for j := range spanLength {
|
||||
h.PositiveBuckets = append(h.PositiveBuckets, int64(j))
|
||||
h.NegativeBuckets = append(h.NegativeBuckets, int64(j))
|
||||
}
|
||||
}
|
||||
|
||||
// Measure encoding efficiency.
|
||||
b.Run("op=Append", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
for b.Loop() {
|
||||
c := Chunk(NewHistogramChunk())
|
||||
|
||||
a, err := c.Appender()
|
||||
if err != nil {
|
||||
b.Fatalf("get appender: %s", err)
|
||||
}
|
||||
var stop bool
|
||||
for i := int64(0); !stop; i++ {
|
||||
_, stop, _, err = a.AppendHistogram(nil, i, h, true)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
b.ReportMetric(float64(len(c.Bytes())), "B/chunk")
|
||||
}
|
||||
})
|
||||
|
||||
// Create a chunk for decoding and compact benchmarks.
|
||||
c := Chunk(NewHistogramChunk())
|
||||
a, err := c.Appender()
|
||||
if err != nil {
|
||||
b.Fatalf("get appender: %s", err)
|
||||
}
|
||||
var stop bool
|
||||
for i := int64(0); !stop; i++ {
|
||||
_, stop, _, err = a.AppendHistogram(nil, i, h, true)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Measure decoding efficiency.
|
||||
b.Run("op=Iterate", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
var (
|
||||
sink *histogram.Histogram
|
||||
it Iterator
|
||||
)
|
||||
for i := 0; b.Loop(); {
|
||||
b.ReportMetric(float64(len(c.Bytes())), "B/chunk")
|
||||
|
||||
it := c.Iterator(it)
|
||||
for it.Next() == ValFloat {
|
||||
_, got := it.AtHistogram(h)
|
||||
sink = got
|
||||
i++
|
||||
}
|
||||
if err := it.Err(); err != nil && !errors.Is(err, io.EOF) {
|
||||
require.NoError(b, err)
|
||||
}
|
||||
_ = sink
|
||||
}
|
||||
})
|
||||
|
||||
// Measure size before and after compaction and it's efficiency.
|
||||
b.Run("op=Compact", func(b *testing.B) {
|
||||
for b.Loop() {
|
||||
b.ReportMetric(float64(len(c.Bytes())), "B/chunk")
|
||||
c.Compact()
|
||||
b.ReportMetric(float64(len(c.Bytes())), "B/compacted_chunk")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue