Skip to content

Commit

Permalink
Merge pull request #135 from mgaare/timer-3-arity
Browse files Browse the repository at this point in the history
Use timer-with-reservoir for the 3-arity deftimer
  • Loading branch information
michaelklishin authored Jul 17, 2018
2 parents db04e5e + 0e2c71a commit 4c14ad6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion metrics-clojure-core/src/metrics/timers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
`(def ~s (timer ~reg '~title))))
([^MetricRegistry reg ^Reservoir reservoir title]
(let [[s title] (desugared-title title)]
`(def ~s (timer ~reg ~reservoir '~title)))))
`(def ~s (timer-with-reservoir ~reg ~reservoir '~title)))))

(defn rate-one
[^Timer m]
Expand Down
4 changes: 4 additions & 0 deletions metrics-clojure-core/test/metrics/test/timers_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@

(let [reg (mc/new-registry)]
(mt/deftimer reg ["test" "timers" "deftimered"])
(mt/deftimer reg (mc/uniform-reservior) deftimered-3-arity)

(deftest test-deftimer
(is (= (mt/rate-mean deftimered) 0.0))
(is (= (mt/time! deftimered (sleep-100)) 100))
(is (> (mt/rate-mean deftimered) 0.0))
(is (= (mt/rate-mean deftimered-3-arity) 0.0))
(is (= (mt/time! deftimered-3-arity (sleep-100))))
(is (> (mt/rate-mean deftimered) 0.0))))


Expand Down

0 comments on commit 4c14ad6

Please sign in to comment.