quickbenck over rest-routes

This commit is contained in:
Tommi Reiman 2017-11-05 19:33:36 +02:00
parent 4163c7c367
commit 16116d3e58

View file

@ -73,19 +73,11 @@
total 10000 total 10000
dropped (int (* total 0.45))] dropped (int (* total 0.45))]
(mapv (mapv
#(let [times (->> (range total) (fn [path]
(mapv (let [time (int (* (first (:sample-mean (cc/quick-benchmark (dotimes [_ 1000] (f path)) {}))) 1e6))]
(fn [_] (println path "=>" time "ns")
(let [now (System/nanoTime) [path time]))
result (f %) urls)))
total (- (System/nanoTime) now)]
(assert result)
total)))
(sort)
(drop dropped)
(drop-last dropped))
avg (int (/ (reduce + times) (count times)))]
[% avg]) urls)))
(defn bench [routes no-paths?] (defn bench [routes no-paths?]
(let [routes (mapv (fn [[path name]] (let [routes (mapv (fn [[path name]]