github.com/mvg-fi/go-limiter@v0.1.1/internal/fasttime/fasttime.go (about)

     1  //go:build !windows
     2  // +build !windows
     3  
     4  // Package fasttime gets wallclock time, but super fast.
     5  package fasttime
     6  
     7  import (
     8  	_ "unsafe"
     9  )
    10  
    11  //go:noescape
    12  //go:linkname now time.now
    13  func now() (sec int64, nsec int32, mono int64)
    14  
    15  // Now returns a monotonic clock value. The actual value will differ across
    16  // systems, but that's okay because we generally only care about the deltas.
    17  func Now() uint64 {
    18  	sec, nsec, _ := now()
    19  	return uint64(sec)*1e9 + uint64(nsec)
    20  }