From 8a0ef47a64d4fb360170c75730484087bf93cb0d Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 10 Apr 2022 21:21:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9F=BA=E5=87=86=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/utils/sets/set_fixed_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/utils/sets/set_fixed_test.go b/internal/utils/sets/set_fixed_test.go index b3f7d2a..0f2de17 100644 --- a/internal/utils/sets/set_fixed_test.go +++ b/internal/utils/sets/set_fixed_test.go @@ -5,6 +5,7 @@ package setutils_test import ( setutils "github.com/TeaOSLab/EdgeNode/internal/utils/sets" "github.com/iwind/TeaGo/assert" + "github.com/iwind/TeaGo/rands" "testing" ) @@ -45,13 +46,17 @@ func TestFixedSet_Reset(t *testing.T) { } func BenchmarkFixedSet_Has(b *testing.B) { - var count = 100_000 + var count = 1_000_000 var set = setutils.NewFixedSet(count) for i := 0; i < count; i++ { set.Push(i) } - for i := 0; i < b.N; i++ { - set.Has(i) - } + b.ResetTimer() + + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + set.Has(rands.Int(0, 100_000)) + } + }) }