From 945d59a980317326953327828b63fa14e923c9ce Mon Sep 17 00:00:00 2001 From: sunwei <18801147024@163.com> Date: Sun, 9 Aug 2020 02:46:22 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90rich=20function=E3=80=91benchmark=20on?= =?UTF-8?q?ce=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/syncx/once_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/syncx/once_test.go b/core/syncx/once_test.go index b89d701a..15f8f869 100644 --- a/core/syncx/once_test.go +++ b/core/syncx/once_test.go @@ -18,3 +18,15 @@ func TestOnce(t *testing.T) { assert.Equal(t, 1, v) } + +func BenchmarkOnce(b *testing.B) { + var v int + add := Once(func() { + v++ + }) + b.ResetTimer() + for i:=0;i