Documentation ¶
Overview ¶
Package mono provides fast monotonic time. On most platforms, mono.Now is about 2x faster than time.Now. However, time.Now is really fast, and nicer to use.
For almost all purposes, you should use time.Now.
Package mono exists because we get the current time multiple times per network packet, at which point it makes a measurable difference.
Index ¶
- func Since(t Time) time.Duration
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) After(n Time) bool
- func (t Time) Before(n Time) bool
- func (t Time) IsZero() bool
- func (t *Time) LoadAtomic() Time
- func (t Time) MarshalJSON() ([]byte, error)
- func (t *Time) StoreAtomic(new Time)
- func (t Time) String() string
- func (t Time) Sub(n Time) time.Duration
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t Time) WallTime() time.Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Time ¶
type Time int64
Time is the number of nanoseconds elapsed since an unspecified reference start time.
func (Time) MarshalJSON ¶
MarshalJSON formats t for JSON as if it were a time.Time. We format Time this way for backwards-compatibility. Time does not survive a MarshalJSON/UnmarshalJSON round trip unchanged across different invocations of the Go process. This is best-effort only. Since t is a monotonic time, it can vary from the actual wall clock by arbitrary amounts. Even in the best of circumstances, it may vary by a few milliseconds.
func (*Time) StoreAtomic ¶
StoreAtomic does an atomic store *t = new.
func (Time) String ¶
String prints t, including an estimated equivalent wall clock. This is best-effort only, for rough debugging purposes only. Since t is a monotonic time, it can vary from the actual wall clock by arbitrary amounts. Even in the best of circumstances, it may vary by a few milliseconds.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON sets t according to data. Time does not survive a MarshalJSON/UnmarshalJSON round trip unchanged across different invocations of the Go process. This is best-effort only.