From abe224bf9e8cf9ffc510a94e1d0430903456a2fc Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Mon, 17 Jul 2023 20:31:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/utils/counters/counter_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/utils/counters/counter_test.go b/internal/utils/counters/counter_test.go index b742809..0be534a 100644 --- a/internal/utils/counters/counter_test.go +++ b/internal/utils/counters/counter_test.go @@ -74,6 +74,20 @@ func TestCounter_GC2(t *testing.T) { } } +func TestCounterMemory(t *testing.T) { + var stat = &runtime.MemStats{} + runtime.ReadMemStats(stat) + + var counter = counters.NewCounter() + for i := 0; i < 1e5; i++ { + counter.Increase(uint64(i), rands.Int(10, 300)) + } + + var stat1 = &runtime.MemStats{} + runtime.ReadMemStats(stat1) + t.Log((stat1.TotalAlloc-stat.TotalAlloc)/(1<<20), "MB") +} + func BenchmarkCounter_Increase(b *testing.B) { runtime.GOMAXPROCS(4)