mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 08:35:10 +00:00
Improve DeltaFIFO function 'ListKeys'
In function ListKeys, it better to use ‘queue’ instead of 'items' to get all the keys. Kubernetes-commit: f0ce8755287b1cad087b61abfcccd79c9f151828
This commit is contained in:
committed by
Kubernetes Publisher
parent
9b97591456
commit
b86695770f
20
tools/cache/delta_fifo_test.go
vendored
20
tools/cache/delta_fifo_test.go
vendored
@@ -694,3 +694,23 @@ func TestDeltaFIFO_PopShouldUnblockWhenClosed(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkDeltaFIFOListKeys(b *testing.B) {
|
||||
f := NewDeltaFIFOWithOptions(DeltaFIFOOptions{KeyFunction: testFifoObjectKeyFunc})
|
||||
const amount = 10000
|
||||
|
||||
for i := 0; i < amount; i++ {
|
||||
f.Add(mkFifoObj(string([]rune{'a', rune(i)}), i+1))
|
||||
}
|
||||
for u := uint64(0); u < amount; u++ {
|
||||
f.Add(mkFifoObj(string([]rune{'b', rune(u)}), u+1))
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_ = f.ListKeys()
|
||||
}
|
||||
})
|
||||
b.StopTimer()
|
||||
}
|
||||
|
Reference in New Issue
Block a user