github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/op/check/check_benchmark_test.go (about) 1 package check 2 3 import ( 4 "testing" 5 ) 6 7 func Benchmark_Nil(b *testing.B) { 8 b.ResetTimer() 9 for i := 0; i < b.N; i++ { 10 _ = Nil[*int](nil) 11 } 12 b.StopTimer() 13 } 14 15 func Benchmark_Nil_StaticFunc(b *testing.B) { 16 Nil := func(i *string) bool { return i == nil } 17 18 b.ResetTimer() 19 for i := 0; i < b.N; i++ { 20 _ = Nil(nil) 21 } 22 b.StopTimer() 23 } 24 25 func Benchmark_Nil_StaticFuncInterface(b *testing.B) { 26 27 Nil := func(i interface{}) bool { return i == nil } 28 29 b.ResetTimer() 30 for i := 0; i < b.N; i++ { 31 _ = Nil(nil) 32 } 33 b.StopTimer() 34 }