Hi all,

If you need to compare running times of different expressions, you could 
use 'timings' macro:
https://gist.github.com/fsodomka/5890711

It takes the number of runs and expressions to time. For example:
user=> (timings 1e7 (+ 1 2 3 4) (+ 1 (+ 2 (+ 3 4))))
[{:time 55.028223, :expr (+ 1 2 3 4)} {:time 55.738369, :expr (+ 1 (+ 2 (+ 
3 4)))}]

Function 'report' prints out comparison of timings. For it to work, 
function 'clojure.pprint/print-table' is needed (Clojure 1.3+).

Results of expressions must be equal (=), otherwise an exception is thrown:
user=> (timings 1e7 (+ 100 2 3 4) (+ 1 (+ 2 (+ 3 4))))
Exception Results of expressions are not equal  user/eval1153 
(NO_SOURCE_FILE:354)

I hope you find it useful and it helps your programs to run faster,
Frantisek

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to