agent: add BenchmarkCreateSeries
Based on the one in tsdb/head_test.go. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
e64d7d8928
commit
bad3f23f23
|
@ -84,7 +84,7 @@ func TestDB_InvalidSeries(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTestAgentDB(t *testing.T, reg prometheus.Registerer, opts *Options) *DB {
|
func createTestAgentDB(t testing.TB, reg prometheus.Registerer, opts *Options) *DB {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
dbDir := t.TempDir()
|
dbDir := t.TempDir()
|
||||||
|
@ -878,3 +878,21 @@ func TestDBAllowOOOSamples(t *testing.T) {
|
||||||
require.Equal(t, float64(80), m.Metric[1].Counter.GetValue(), "agent wal mismatch of total appended histograms")
|
require.Equal(t, float64(80), m.Metric[1].Counter.GetValue(), "agent wal mismatch of total appended histograms")
|
||||||
require.NoError(t, db.Close())
|
require.NoError(t, db.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkCreateSeries(b *testing.B) {
|
||||||
|
s := createTestAgentDB(b, nil, DefaultOptions())
|
||||||
|
defer s.Close()
|
||||||
|
|
||||||
|
app := s.Appender(context.Background()).(*appender)
|
||||||
|
lbls := make([]labels.Labels, b.N)
|
||||||
|
|
||||||
|
for i, l := range labelsForTest("benchmark", b.N) {
|
||||||
|
lbls[i] = labels.New(l...)
|
||||||
|
}
|
||||||
|
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for _, l := range lbls {
|
||||||
|
app.getOrCreate(l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue