Add benchmark for LabelSelectorAsSelector

This commit is contained in:
Aldo Culquicondor 2021-05-20 17:00:07 +00:00
parent 29e4fdab4d
commit 19c2394915

View File

@ -93,6 +93,26 @@ func TestLabelSelectorAsSelector(t *testing.T) {
}
}
func BenchmarkLabelSelectorAsSelector(b *testing.B) {
selector := &LabelSelector{
MatchLabels: map[string]string{
"foo": "foo",
"bar": "bar",
},
MatchExpressions: []LabelSelectorRequirement{{
Key: "baz",
Operator: LabelSelectorOpExists,
}},
}
b.StartTimer()
for i := 0; i < b.N; i++ {
_, err := LabelSelectorAsSelector(selector)
if err != nil {
b.Fatal(err)
}
}
}
func TestLabelSelectorAsMap(t *testing.T) {
matchLabels := map[string]string{"foo": "bar"}
matchExpressions := func(operator LabelSelectorOperator, values []string) []LabelSelectorRequirement {