github.com/sethvargo/go-limiter@v1.0.0/internal/fasttime/fasttime.go (about)

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