store/[org.clojure/clojure "1.8.0"] clj::clojure.core/time

Official Documentation

Add notes
Arities
==================================================
   [expr]

Docstring
==================================================
  Evaluates expr and prints the time it took.  Returns the value of
 expr.

Source

(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#))

Example 1

Edit
(time (Thread/sleep 1000))
;; > "Elapsed time: 1000.267483 msecs"
;; => nil

(with-out-str (time (Thread/sleep 1000)))
;; > "\"Elapsed time: 1010.12942 msecs\"\n"

Example 2

Edit
(time (Thread/sleep 100))
;; > "Elapsed time: 100.284772 msecs"
;; => nil

Example 3

Edit
;; Time how long it takes to write a string to a file 100 times
(defn time-test []
  (with-open [w (writer "test.txt" :append false)]
    (dotimes [_ 100]
      (.write w "I am being written to a file."))))

(time (time-test))
;; > "Elapsed time: 19.596371 msecs"
;; => nil

Example 4

Edit
;when working with lazy seqs
(time (doall (...)))

Uses on crossclj