github.com/songzhibin97/go-baseutils@v0.0.2-0.20240302024150-487d8ce9c082/sys/nanotime/nacotime.go (about) 1 package nanotime 2 3 import ( 4 "time" 5 _ "unsafe" 6 ) 7 8 //go:linkname RuntimeNanotime runtime.nanotime 9 func RuntimeNanotime() int64 10 11 func SinceSeconds(t int64) float64 { 12 return Since(t, time.Second) 13 } 14 15 func Since(t int64, unit time.Duration) float64 { 16 return float64(RuntimeNanotime()-t) / float64(unit) 17 }