clj-commons/metrics-clojure

Timers documentation says milliseconds, but code returns nanoseconds

ryfow opened this issue · 3 comments

ryfow commented

The Reading section of the timers documentation Says that the functions return values in milliseconds, but they appear to actually return values in nanoseconds.

What is correct? I'll submit a pull request on the code or documentation, but I need to know how it's supposed to work first.

user=> (require '[metrics.timers :as timers])
nil
user=> (timers/time! (timers/timer "foo") (Thread/sleep 10))
nil
user=> (timers/percentiles (timers/timer "foo"))
{0.75 1.0436789E7, 0.95 1.0436789E7, 0.99 1.0436789E7, 0.999 1.0436789E7, 1.0 1.0436789E7}
user=> (->> (timers/percentiles (timers/timer "foo")) (map (fn [[k v]] [k (/ v 1000000)])))
([0.75 10.436789] [0.95 10.436789] [0.99 10.436789] [0.999 10.436789] [1.0 10.436789])

user=> (timers/smallest (timers/timer "foo"))
10436789
user=> (timers/mean (timers/timer "foo"))
1.0436789E7
user=> (/ (timers/mean (timers/timer "foo")) 1000000)
10.436789

Dropwizard Metrics seems to be using nanoseconds and this library doesn't mess with returned values.

ryfow commented

Thanks!