mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-03 20:39:32 -05:00
storage: add BenchmarkFanoutAppenderV2
Signed-off-by: bwplotka <bwplotka@gmail.com>
This commit is contained in:
parent
88f6ee4c8e
commit
91b0f353b0
1 changed files with 36 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ package storage_test
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus/common/model"
|
||||
|
|
@ -563,3 +564,38 @@ func TestFanoutAppenderV2(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Recommended CLI invocation:
|
||||
/*
|
||||
export bench=fanoutAppender && go test ./storage/... \
|
||||
-run '^$' -bench '^BenchmarkFanoutAppenderV2' \
|
||||
-benchtime 2s -count 6 -cpu 2 -timeout 999m \
|
||||
| tee ${bench}.txt
|
||||
*/
|
||||
func BenchmarkFanoutAppenderV2(b *testing.B) {
|
||||
ex := exemplar.Exemplar{Value: 1}
|
||||
|
||||
var series []labels.Labels
|
||||
for i := range 1000 {
|
||||
series = append(series, labels.FromStrings(model.MetricNameLabel, "metric1", "i", strconv.Itoa(i)))
|
||||
}
|
||||
for _, tt := range fanoutAppenderTestCases(nil) {
|
||||
b.Run(tt.name, func(b *testing.B) {
|
||||
f := storage.NewFanout(nil, mockStorage{appV2: tt.primary}, mockStorage{appV2: tt.secondary})
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for b.Loop() {
|
||||
app := f.AppenderV2(b.Context())
|
||||
for _, s := range series {
|
||||
// Purposefully skip errors as we want to benchmark error cases too (majority of the fanout logic).
|
||||
_, _ = app.Append(0, s, 0, 0, 1, nil, nil, storage.AOptions{
|
||||
Exemplars: []exemplar.Exemplar{ex},
|
||||
})
|
||||
}
|
||||
require.NoError(b, app.Rollback())
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue