From bbcee77b028aa3fbd9c54fe129efcbd61bbb6365 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 24 May 2019 03:16:41 +0900 Subject: [PATCH] clock: Use time.Since for monotonic timer Fixes #875 --- internal/clock/now.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/clock/now.go b/internal/clock/now.go index de7615852..6978f60ee 100644 --- a/internal/clock/now.go +++ b/internal/clock/now.go @@ -21,8 +21,10 @@ import ( "time" ) +var initTime = time.Now() + func now() int64 { - // time.Now() is monotonic: + // time.Since() returns monotonic timer difference (#875): // https://golang.org/pkg/time/#hdr-Monotonic_Clocks - return time.Now().UnixNano() + return int64(time.Since(initTime)) }