mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add benchmark tests for TruncIndex.
Compare add vs new. Some historical data in PR #5172. Docker-DCO-1.1-Signed-off-by: Paul Nasrat <pnasrat@gmail.com> (github: pnasrat)
This commit is contained in:
parent
4f169c2db5
commit
84a76f2796
1 changed files with 19 additions and 0 deletions
|
@ -219,6 +219,25 @@ func assertIndexGet(t *testing.T, index *TruncIndex, input, expectedResult strin
|
|||
}
|
||||
}
|
||||
|
||||
func BenchmarkTruncIndexAdd(b *testing.B) {
|
||||
ids := []string{"banana", "bananaa", "bananab"}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
index := NewTruncIndex([]string{})
|
||||
for _, id := range ids {
|
||||
index.Add(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkTruncIndexNew(b *testing.B) {
|
||||
ids := []string{"banana", "bananaa", "bananab"}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
NewTruncIndex(ids)
|
||||
}
|
||||
}
|
||||
|
||||
func assertKernelVersion(t *testing.T, a, b *KernelVersionInfo, result int) {
|
||||
if r := CompareKernelVersion(a, b); r != result {
|
||||
t.Fatalf("Unexpected kernel version comparison result. Found %d, expected %d", r, result)
|
||||
|
|
Loading…
Reference in a new issue