diff --git a/avl/avl_test.go b/avl/avl_test.go index aee2ac0..d5b6a52 100644 --- a/avl/avl_test.go +++ b/avl/avl_test.go @@ -507,11 +507,20 @@ func BenchmarkGodsRBGet(b *testing.B) { l := loadTestData() b.N = len(l) + for i := 0; i < b.N; i++ { + tree.Put(l[i], l[i]) + } b.ResetTimer() b.StartTimer() - for i := 0; i < b.N; i++ { - tree.Get(l[i]) + + execCount := 10 + b.N = len(l) * execCount + + for i := 0; i < execCount; i++ { + for _, v := range l { + tree.Get(v) + } } } @@ -520,11 +529,20 @@ func BenchmarkGodsAvlGet(b *testing.B) { l := loadTestData() b.N = len(l) + for i := 0; i < b.N; i++ { + tree.Put(l[i], l[i]) + } b.ResetTimer() b.StartTimer() - for i := 0; i < b.N; i++ { - tree.Get(l[i]) + + execCount := 10 + b.N = len(l) * execCount + + for i := 0; i < execCount; i++ { + for _, v := range l { + tree.Get(v) + } } }