mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Add benchmark for LabelSelectorAsSelector
This commit is contained in:
parent
29e4fdab4d
commit
19c2394915
@ -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) {
|
func TestLabelSelectorAsMap(t *testing.T) {
|
||||||
matchLabels := map[string]string{"foo": "bar"}
|
matchLabels := map[string]string{"foo": "bar"}
|
||||||
matchExpressions := func(operator LabelSelectorOperator, values []string) []LabelSelectorRequirement {
|
matchExpressions := func(operator LabelSelectorOperator, values []string) []LabelSelectorRequirement {
|
||||||
|
Loading…
Reference in New Issue
Block a user