github.com/songzhibin97/gkit@v1.2.13/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  }