Compare add vs new.
Some historical data in PR #5172.
Docker-DCO-1.1-Signed-off-by: Paul Nasrat <pnasrat@gmail.com> (github: pnasrat)
| ... | ... |
@@ -219,6 +219,25 @@ func assertIndexGet(t *testing.T, index *TruncIndex, input, expectedResult strin |
| 219 | 219 |
} |
| 220 | 220 |
} |
| 221 | 221 |
|
| 222 |
+func BenchmarkTruncIndexAdd(b *testing.B) {
|
|
| 223 |
+ ids := []string{"banana", "bananaa", "bananab"}
|
|
| 224 |
+ b.ResetTimer() |
|
| 225 |
+ for i := 0; i < b.N; i++ {
|
|
| 226 |
+ index := NewTruncIndex([]string{})
|
|
| 227 |
+ for _, id := range ids {
|
|
| 228 |
+ index.Add(id) |
|
| 229 |
+ } |
|
| 230 |
+ } |
|
| 231 |
+} |
|
| 232 |
+ |
|
| 233 |
+func BenchmarkTruncIndexNew(b *testing.B) {
|
|
| 234 |
+ ids := []string{"banana", "bananaa", "bananab"}
|
|
| 235 |
+ b.ResetTimer() |
|
| 236 |
+ for i := 0; i < b.N; i++ {
|
|
| 237 |
+ NewTruncIndex(ids) |
|
| 238 |
+ } |
|
| 239 |
+} |
|
| 240 |
+ |
|
| 222 | 241 |
func assertKernelVersion(t *testing.T, a, b *KernelVersionInfo, result int) {
|
| 223 | 242 |
if r := CompareKernelVersion(a, b); r != result {
|
| 224 | 243 |
t.Fatalf("Unexpected kernel version comparison result. Found %d, expected %d", r, result)
|