mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-09 00:22:19 -04:00
exp: BenchmarkScrapeLoopAppend_RefSampleST
Signed-off-by: bwplotka <bwplotka@gmail.com>
This commit is contained in:
parent
f0f40b970d
commit
1e4eba65a0
1 changed files with 41 additions and 0 deletions
|
|
@ -44,6 +44,7 @@ import (
|
|||
"github.com/prometheus/common/expfmt"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/prometheus/common/promslog"
|
||||
"github.com/prometheus/procfs"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
|
|
@ -1852,6 +1853,46 @@ func BenchmarkScrapeLoopAppend_HistogramsWithExemplars(b *testing.B) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
export bench=appendRefSample && go test ./scrape/... \
|
||||
-run '^$' -bench '^BenchmarkScrapeLoopAppend_RefSampleST$' \
|
||||
-benchtime 2s -count 6 -cpu 2 -timeout 999m \
|
||||
| tee ${bench}.txt
|
||||
*/
|
||||
func BenchmarkScrapeLoopAppend_RefSampleST(b *testing.B) {
|
||||
parsableText := readTextParseTestMetrics(b) // "237FamsAllTypes"
|
||||
metricsProto := promTextToProto(b, parsableText)
|
||||
contentType := "application/vnd.google.protobuf"
|
||||
|
||||
s := teststorage.New(b, func(opt *tsdb.Options) { opt.EnableMetadataWALRecords = false })
|
||||
sl, _ := newTestScrapeLoop(b, withAppendable(s, true), func(sl *scrapeLoop) { sl.appendMetadataToWAL = false })
|
||||
|
||||
p, err := procfs.Self() // Works only on linux.
|
||||
require.NoError(b, err)
|
||||
|
||||
stat, err := p.Stat()
|
||||
require.NoError(b, err)
|
||||
|
||||
ts := time.Time{}
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for b.Loop() {
|
||||
app := sl.appender()
|
||||
ts = ts.Add(time.Second)
|
||||
_, _, _, err := app.append(metricsProto, contentType, ts)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
if err := app.Commit(); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
stat2, err := p.Stat()
|
||||
require.NoError(b, err)
|
||||
b.ReportMetric(stat2.CPUTime()-stat.CPUTime(), "procfscpu")
|
||||
}
|
||||
|
||||
func TestScrapeLoopScrapeAndReport(t *testing.T) {
|
||||
foreachAppendable(t, func(t *testing.T, appV2 bool) {
|
||||
testScrapeLoopScrapeAndReport(t, appV2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue