github.com/duomi520/utils@v0.0.0-20240430123446-e03a4cddd6ec/link_test.go (about) 1 package utils 2 3 import ( 4 "math/rand" 5 "testing" 6 "time" 7 ) 8 9 func BenchmarkMathRand(b *testing.B) { 10 for i := 0; i < b.N; i++ { 11 _ = rand.Int() 12 } 13 } 14 15 func BenchmarkRuntimeRand(b *testing.B) { 16 for i := 0; i < b.N; i++ { 17 _ = FastRand() 18 } 19 } 20 21 func BenchmarkTimeNow(b *testing.B) { 22 for i := 0; i < b.N; i++ { 23 _ = time.Now() 24 } 25 } 26 27 func BenchmarkRuntimeNanotime(b *testing.B) { 28 for i := 0; i < b.N; i++ { 29 _ = Nanotime() 30 } 31 }