1
0
mirror of https://github.com/docker/cli.git synced 2026-01-13 18:22:35 +03: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)
Upstream-commit: 84a76f27962d4f4b3871abe925ca17024bdeea73
Component: engine
This commit is contained in:
Paul Nasrat
2014-04-13 22:34:22 -04:00
parent 74f0d78beb
commit 936bcbbb79

View File

@@ -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)