From 1dbe4629aa296140118a4cbec328b111db6c981f Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Tue, 21 Nov 2023 18:16:18 +0800 Subject: [PATCH] chore: add new benchmark tests (#309) --- ants_benchmark_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ants_benchmark_test.go b/ants_benchmark_test.go index 83cd920..f39b0e6 100644 --- a/ants_benchmark_test.go +++ b/ants_benchmark_test.go @@ -200,3 +200,27 @@ func BenchmarkAntsMultiPoolThroughput(b *testing.B) { } } } + +func BenchmarkParallelAntsPoolThroughput(b *testing.B) { + p, _ := NewPool(PoolCap, WithExpiryDuration(DefaultExpiredTime)) + defer p.Release() + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + _ = p.Submit(demoFunc) + } + }) +} + +func BenchmarkParallelAntsMultiPoolThroughput(b *testing.B) { + p, _ := NewMultiPool(10, PoolCap/10, RoundRobin, WithExpiryDuration(DefaultExpiredTime)) + defer p.ReleaseTimeout(DefaultExpiredTime) //nolint:errcheck + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + _ = p.Submit(demoFunc) + } + }) +}