[TESTS] Scraping: Reset appender in BenchmarkScrapeLoopAppend

Otherwise performance is dominated by adding to a slice that gets longer
and longer as the benchmark progresses.

I chose to Rollback rather than Commit because that should do less work.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
Bryan Boreham 2026-01-17 16:37:18 +00:00
parent c4b0da94db
commit 2dec6da3d1

View file

@ -1384,6 +1384,8 @@ func BenchmarkScrapeLoopAppend(b *testing.B) {
if err != nil {
b.Fatal(err)
}
app.Rollback() // Reset the appender so it doesn't grow indefinitely.
app = sl.appender()
}
})
}