clock: Use time.Since for monotonic timer

Fixes #875
This commit is contained in:
Hajime Hoshi 2019-05-24 03:16:41 +09:00
parent 9c1b760016
commit bbcee77b02

View File

@ -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))
}