1// Copyright (C) 2016 Arista Networks, Inc. 2// Use of this source code is governed by the Apache License 2.0 3// that can be found in the COPYING file. 4 5// Package monotime provides a fast monotonic clock source. 6package monotime 7 8import ( 9 _ "unsafe" // required to use //go:linkname 10) 11 12//go:noescape 13//go:linkname nanotime runtime.nanotime 14func nanotime() int64 15 16// Now returns the current time in nanoseconds from a monotonic clock. 17// The time returned is based on some arbitrary platform-specific point in the 18// past. The time returned is guaranteed to increase monotonically at a 19// constant rate, unlike time.Now() from the Go standard library, which may 20// slow down, speed up, jump forward or backward, due to NTP activity or leap 21// seconds. 22func Now() Time { 23 return Time(nanotime()) 24} 25