Skip to content

clojure.core/time

View this page on ClojureDocs

Type: macro Added: Clojure 1.0 Examples: 5 Runnable: 3
([expr])

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

Examples

by gstamp on
by boxie on . May have evaluation errors.
by Omer on . May have evaluation errors.
by micrub on
by sFritsch09 on

Note by mars0i

Because the Java JIT compiler compiles code differently after the code has been running for a bit of time, if you want to use time for benchmarking, you should at least "warm up" your code by running it several times, using the later time outputs as the ones that count. A better strategy is to use a benchmarking library such as Criterium, which will do the warmup for you, and much more.


Content from the matching ClojureDocs page, with authors credited on each contribution.