• (prof name & body)
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.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/profile.clj:45 top

(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)))
Vars in clojure.contrib.profile/prof: assert defmacro keyword? name - apply assoc concat conj deref get let list seq swap! vector
Used in 0 other vars

Comments top

No comments for prof. Log in to add a comment.