mirror of
https://github.com/prometheus/prometheus
synced 2025-01-14 02:43:35 +00:00
[Test] TSDB: let BenchmarkAddExemplar reuse slots
Test with different amounts of capacity and exemplars, so that sometimes new exemplars are evicting older exemplars. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
6683895620
commit
929fbf860e
@ -415,27 +415,29 @@ func BenchmarkAddExemplar(b *testing.B) {
|
||||
// before adding.
|
||||
exLabels := labels.FromStrings("trace_id", "89620921")
|
||||
|
||||
for _, n := range []int{10000, 100000, 1000000} {
|
||||
b.Run(strconv.Itoa(n), func(b *testing.B) {
|
||||
for j := 0; j < b.N; j++ {
|
||||
b.StopTimer()
|
||||
exs, err := NewCircularExemplarStorage(int64(n), eMetrics)
|
||||
require.NoError(b, err)
|
||||
es := exs.(*CircularExemplarStorage)
|
||||
var l labels.Labels
|
||||
b.StartTimer()
|
||||
for _, capacity := range []int{1000, 10000, 100000} {
|
||||
for _, n := range []int{10000, 100000, 1000000} {
|
||||
b.Run(fmt.Sprintf("%d/%d", n, capacity), func(b *testing.B) {
|
||||
for j := 0; j < b.N; j++ {
|
||||
b.StopTimer()
|
||||
exs, err := NewCircularExemplarStorage(int64(capacity), eMetrics)
|
||||
require.NoError(b, err)
|
||||
es := exs.(*CircularExemplarStorage)
|
||||
var l labels.Labels
|
||||
b.StartTimer()
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
if i%100 == 0 {
|
||||
l = labels.FromStrings("service", strconv.Itoa(i))
|
||||
}
|
||||
err = es.AddExemplar(l, exemplar.Exemplar{Value: float64(i), Ts: int64(i), Labels: exLabels})
|
||||
if err != nil {
|
||||
require.NoError(b, err)
|
||||
for i := 0; i < n; i++ {
|
||||
if i%100 == 0 {
|
||||
l = labels.FromStrings("service", strconv.Itoa(i))
|
||||
}
|
||||
err = es.AddExemplar(l, exemplar.Exemplar{Value: float64(i), Ts: int64(i), Labels: exLabels})
|
||||
if err != nil {
|
||||
require.NoError(b, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user