If *enable-profiling* is true, wraps body in profiling code.
Returns the result of body. Profile timings will be stored in
*profile-data* using name, which must be a keyword, as the key.
Timings are measured with System/nanoTime.
(defmacro prof
"If *enable-profiling* is true, wraps body in profiling code.
Returns the result of body. Profile timings will be stored in
*profile-data* using name, which must be a keyword, as the key.
Timings are measured with System/nanoTime."
[name & body]
(assert (keyword? name))
(if *enable-profiling*
`(if *profile-data*
(let [start-time# (System/nanoTime)
value# (do ~@body)
elapsed# (- (System/nanoTime) start-time#)]
(swap! *profile-data* assoc ~name
(conj (get @*profile-data* ~name) elapsed#))
value#)
~@body)
`(do ~@body)))
Comments top
No comments for prof. Log in to add a comment.