• (time expr)
Evaluates expr and prints the time it took. Returns the value of
expr.

2 Examples top

  • user> (time (Thread/sleep 100))
    "Elapsed time: 100.284772 msecs"
    nil
  • ;when working with lazy seqs
    (time (doall (...)))
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:3422 top

(defmacro time
  "Evaluates expr and prints the time it took.  Returns the value of
 expr."
  {:added "1.0"}
  [expr]
  `(let [start# (. System (nanoTime))
         ret# ~expr]
     (prn (str "Elapsed time: " (/ (double (- (. System (nanoTime)) start#)) 1000000.0) " msecs"))
     ret#))
Vars in clojure.core/time:
Used in 0 other vars

Comments top

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