FeatureBaseDB / tools

Tools for development and ops
BSD 3-Clause "New" or "Revised" License
20 stars 14 forks source link

Use monotonic time for benchmark timing #48

Closed alanbernstein closed 7 years ago

alanbernstein commented 7 years ago

time.Now() returns real time, which can jump occasionally. https://github.com/gavv/monotime, for example, provides a monotonic Now() function, which is preferable for timing measurements.

jaffee commented 7 years ago

This is a very long thread, and I'm still reading, but I believe this issue may be solved (or solved soon) within Go's time package: https://github.com/golang/go/issues/12914

jaffee commented 7 years ago

Seems like it is in 1.9 - basically, time.Now() will internally include both wall time and monotonic information, and will use whichever is more appropriate for a given situation - so doing time.Sub or time.Since will use the monotonic time, and we won't need to update our code at all.

jaffee commented 7 years ago

I'm gonna go ahead and close this - feel free to re-open if there are still concerns.