mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
refactor: single function to visit mapping node content
Refactor mapping node content traversal so that all code paths execute through the same root function.
This commit is contained in:
@@ -2311,6 +2311,28 @@ func TestGetAnnotations(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGetAnnotations(b *testing.B) {
|
||||
counts := []int{0, 2, 5, 8}
|
||||
for _, count := range counts {
|
||||
appliedAnnotations := make(map[string]string, count)
|
||||
for i := 1; i <= count; i++ {
|
||||
key := fmt.Sprintf("annotation-key-%d", i)
|
||||
value := fmt.Sprintf("annotation-value-%d", i)
|
||||
appliedAnnotations[key] = value
|
||||
}
|
||||
rn := NewRNode(nil)
|
||||
if err := rn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
b.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
assert.NoError(b, rn.SetAnnotations(appliedAnnotations))
|
||||
b.Run(fmt.Sprintf("%02d", count), func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = rn.GetAnnotations()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFieldValueWithDot(t *testing.T) {
|
||||
const input = `
|
||||
kind: Pod
|
||||
|
||||
Reference in New Issue
Block a user