nanotime.go 490 B

12345678910111213141516
  1. package puddle
  2. import "time"
  3. // nanotime returns the time in nanoseconds since process start.
  4. //
  5. // This approach, described at
  6. // https://github.com/golang/go/issues/61765#issuecomment-1672090302,
  7. // is fast, monotonic, and portable, and avoids the previous
  8. // dependence on runtime.nanotime using the (unsafe) linkname hack.
  9. // In particular, time.Since does less work than time.Now.
  10. func nanotime() int64 {
  11. return time.Since(globalStart).Nanoseconds()
  12. }
  13. var globalStart = time.Now()