Traverse OwnerReference maps more efficiently

This commit is contained in:
Ted Yu
2019-10-19 17:56:11 -07:00
parent 534051acec
commit 0d704f1ce2
2 changed files with 22 additions and 18 deletions

View File

@@ -409,6 +409,16 @@ func TestProcessEvent(t *testing.T) {
}
}
func BenchmarkReferencesDiffs(t *testing.B) {
t.ReportAllocs()
t.ResetTimer()
for n := 0; n < t.N; n++ {
old := []metav1.OwnerReference{{UID: "1"}, {UID: "2"}}
new := []metav1.OwnerReference{{UID: "2"}, {UID: "3"}}
referencesDiffs(old, new)
}
}
// TestDependentsRace relies on golang's data race detector to check if there is
// data race among in the dependents field.
func TestDependentsRace(t *testing.T) {