github.com/ulule/limiter/v3@v3.11.3-0.20230613131926-4cb9c1da4633/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" // import unsafe because we use go:linkname directive. 8 ) 9 10 // Forked from https://github.com/sethvargo/go-limiter 11 12 //go:noescape 13 //go:linkname now time.now 14 func now() (sec int64, nsec int32, mono int64) 15 16 // Now returns a monotonic clock value. The actual value will differ across 17 // systems, but that's okay because we generally only care about the deltas. 18 func Now() uint64 { 19 sec, nsec, _ := now() 20 return uint64(sec)*1e9 + uint64(nsec) 21 }