MCPcopy
hub / github.com/prometheus/prometheus / BenchmarkCompactionFromHead

Function BenchmarkCompactionFromHead

tsdb/compact_test.go:1247–1275  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

1245}
1246
1247func BenchmarkCompactionFromHead(b *testing.B) {
1248 dir := b.TempDir()
1249 totalSeries := 100000
1250 for labelNames := 1; labelNames < totalSeries; labelNames *= 10 {
1251 labelValues := totalSeries / labelNames
1252 b.Run(fmt.Sprintf("labelnames=%d,labelvalues=%d", labelNames, labelValues), func(b *testing.B) {
1253 chunkDir := b.TempDir()
1254 opts := DefaultHeadOptions()
1255 opts.ChunkRange = 1000
1256 opts.ChunkDirRoot = chunkDir
1257 h, err := NewHead(nil, nil, nil, nil, opts, nil)
1258 require.NoError(b, err)
1259 for ln := 0; ln < labelNames; ln++ {
1260 app := h.Appender(context.Background())
1261 for lv := range labelValues {
1262 app.Append(0, labels.FromStrings(strconv.Itoa(ln), fmt.Sprintf("%d%s%d", lv, postingsBenchSuffix, ln)), 0, 0)
1263 }
1264 require.NoError(b, app.Commit())
1265 }
1266
1267 b.ResetTimer()
1268 b.ReportAllocs()
1269 for i := 0; b.Loop(); i++ {
1270 createBlockFromHead(b, filepath.Join(dir, fmt.Sprintf("%d-%d", i, labelNames)), h)
1271 }
1272 h.Close()
1273 })
1274 }
1275}
1276
1277func BenchmarkCompactionFromOOOHead(b *testing.B) {
1278 dir := b.TempDir()

Callers

nothing calls this directly

Calls 9

AppenderMethod · 0.95
CloseMethod · 0.95
FromStringsFunction · 0.92
DefaultHeadOptionsFunction · 0.85
NewHeadFunction · 0.85
createBlockFromHeadFunction · 0.85
RunMethod · 0.65
AppendMethod · 0.65
CommitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…