metrics-clojure / src / metrics / timers.clj

Diff from to


 (ns metrics.timers
   (use [metrics.utils :only (metric-name)])
   (import (com.yammer.metrics Metrics))
+  (import (com.yammer.metrics.core TimerMetric))
   (import (java.util.concurrent TimeUnit)))
+; Create ----------------------------------------------------------------------
 (defn timer [title]
   (Metrics/newTimer (metric-name title)
+; Read ------------------------------------------------------------------------
+(defn rates [^TimerMetric m]
+  {1 (.oneMinuteRate m)
+   5 (.fiveMinuteRate m)
+   15 (.fifteenMinuteRate m)})
+(defn rate-one [^TimerMetric m]
+  (.oneMinuteRate m))
+(defn rate-five [^TimerMetric m]
+  (.fiveMinuteRate m))
+(defn rate-fifteen [^TimerMetric m]
+  (.fifteenMinuteRate m))
+(defn rate-mean [^TimerMetric m]
+  (.meanRate m))
+(defn mean [^TimerMetric t]
+  (.mean t))
+(defn std-dev [^TimerMetric t]
+  (.stdDev t))
+(defn percentiles
+  ([^TimerMetric t]
+   (percentiles t [0.75 0.90 0.95 1.0]))
+  ([^TimerMetric t ps]
+   (zipmap ps
+           (.percentiles t (double-array ps)))))
+(defn number-recorded [^TimerMetric t]
+  (.count t))
+(defn largest [^TimerMetric t]
+  (.max t))
+(defn smallest [^TimerMetric t]
+  (.min t))
+(defn sample [^TimerMetric t]
+  (.values t))
+; Write -----------------------------------------------------------------------
 (defmacro time! [t & body]
   `(.time ~t
          (proxy [Callable] []
          (proxy [Callable] []
            (call [] (f)))))
+(defn clear! [^TimerMetric t]
+  (.clear t))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.