【rich function】benchmark once function

master
sunwei 4 years ago committed by Kevin Wan
parent 1104363988
commit 945d59a980

@ -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<b.N;i++{
add()
}
assert.Equal(b, 1, v)
}
Loading…
Cancel
Save