mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
fix(tests): add ac benchmark
This commit is contained in:
committed by
Łukasz Mierzwa
parent
45029bcdc9
commit
c9c9f079ae
@@ -1,6 +1,7 @@
|
||||
package filters_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
@@ -143,3 +144,26 @@ func TestBuildAutocomplete(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAutocomplete(b *testing.B) {
|
||||
const n = 10000
|
||||
alerts := make([]models.Alert, 0, n)
|
||||
for i := 0; i < n; i++ {
|
||||
alerts = append(alerts, models.Alert{
|
||||
State: models.AlertStateActive,
|
||||
Labels: models.Labels{
|
||||
{Name: "foo", Value: fmt.Sprintf("xxx%d", i)},
|
||||
{Name: "number", Value: fmt.Sprintf("%d", i)},
|
||||
},
|
||||
Receiver: fmt.Sprintf("receiver-%d", i%1000),
|
||||
Alertmanager: []models.AlertmanagerInstance{
|
||||
{Cluster: "cluster", Name: "am1"},
|
||||
{Cluster: "cluster", Name: "am2"},
|
||||
},
|
||||
})
|
||||
}
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
filters.BuildAutocomplete(alerts)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user