github.com/songzhibin97/gkit@v1.2.13/sys/nanotime/nacotime_test.go (about) 1 package nanotime 2 3 import ( 4 "testing" 5 "time" 6 ) 7 8 func BenchmarkTimeNow(b *testing.B) { 9 for i := 0; i < b.N; i++ { 10 cost := time.Now() 11 time.Since(cost).Seconds() 12 } 13 } 14 15 func BenchmarkRuntimeNanotime(b *testing.B) { 16 for i := 0; i < b.N; i++ { 17 cost := RuntimeNanotime() 18 _ = SinceSeconds(cost) 19 } 20 } 21 22 func TestProxy_Time(t *testing.T) { 23 n1 := time.Now() 24 n2 := RuntimeNanotime() 25 time.Sleep(time.Second) 26 t.Log(time.Since(n1).Seconds()) 27 t.Log(SinceSeconds(n2)) 28 }