From eb954ffb47f7ab1509b0ccf76d519e84b14e401c Mon Sep 17 00:00:00 2001 From: eson <474420502@qq.com> Date: Sat, 6 Apr 2019 04:08:27 +0800 Subject: [PATCH] =?UTF-8?q?TODO:=20=E4=BF=AE=E6=94=B9=E5=88=B0=E6=89=80?= =?UTF-8?q?=E6=9C=89=E7=9A=84=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E9=87=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- avl/avl_test.go | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) 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) + } } }