github.com/webmafia/fast@v0.10.0/clock_test.go (about) 1 package fast 2 3 import ( 4 "context" 5 "testing" 6 "time" 7 ) 8 9 func BenchmarkTimeNow(b *testing.B) { 10 for i := 0; i < b.N; i++ { 11 _ = time.Now() 12 } 13 } 14 15 func BenchmarkClockNow(b *testing.B) { 16 c := NewClock(context.Background()) 17 18 b.ResetTimer() 19 20 for i := 0; i < b.N; i++ { 21 _ = c.Now() 22 } 23 }