Skip to content

Commit

Permalink
Merge pull request #518 from bsless/perf-utils
Browse files Browse the repository at this point in the history
Add profiling utilities
  • Loading branch information
ikitommi authored Aug 23, 2021
2 parents 1055b3c + 7210b37 commit 76d30bf
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions perf/malli/creation_perf_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@
(print "invoking" times# "times")
(time (prof/profile (dotimes [_# times#] ~@body))))))

(defmacro profile-for
[n & body]
`(let [res# (cc/quick-benchmark (do ~@body) {})
mean# (first (:mean res#))
k# (long (/ ~n mean#))]
(println (* 1e9 mean#))
(println
(with-out-str
(cc/quick-bench ~@body)))
(println "Profiling for" ~n "seconds" k# "times")
(time
(prof/profile
(dotimes [_# k#]
~@body)))))

(defmacro bench->
[data & expr]
`(doseq [[name# data#] ~data]
(let [mean# (first (:mean (cc/quick-benchmark (-> data# ~expr) {})))
[scale# unit#] (cc/scale-time mean#)]
(println name# (* mean# scale#) unit#))))

(comment

(bench->
[[:or-2-types [:or :int :string]]
[:int :int]]
m/schema))

(comment

;;
Expand Down

0 comments on commit 76d30bf

Please sign in to comment.