summaryrefslogtreecommitdiffhomepage
path: root/tstime/monocoarse_std.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-07-19 16:02:49 -0700
committerJosh Bleecher Snyder <josh@tailscale.com>2021-07-19 16:02:49 -0700
commit197edcedeccb326eb371350b4e6ec26ff77a019a (patch)
treefd1be18414a4de0444afae47d19827a1e8971e6d /tstime/monocoarse_std.go
parent2a8ca8a5926903382743aebc75c19e6a1dee80ee (diff)
downloadtailscale-josh/fast-time.tar.xz
tailscale-josh/fast-time.zip
Diffstat (limited to 'tstime/monocoarse_std.go')
-rw-r--r--tstime/monocoarse_std.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/tstime/monocoarse_std.go b/tstime/monocoarse_std.go
index 8a289dcee..24630e167 100644
--- a/tstime/monocoarse_std.go
+++ b/tstime/monocoarse_std.go
@@ -14,3 +14,12 @@ var referenceTime = time.Now()
func MonotonicCoarse() int64 {
return int64(time.Since(referenceTime).Seconds())
}
+
+// Monotonic returns the number of monotonic seconds elapsed
+// since an unspecified starting point, at low precision.
+// It is only meaningful when compared to the
+// result of previous MonotonicCoarse calls.
+// On some platforms, MonotonicCoarse is much faster than time.Now.
+func Monotonic() int64 {
+ return int64(time.Since(referenceTime).Seconds())
+}