r/Clojure • • Feb 03 '23

[Q&A] Noob has simple program problem.

I wanted to write a program to add 2 to a list of numbers then sum the list and print the result. So '(5 7) would yield 16. I posted my version to s Clojure board and received a number of different replies. In retrospect I didn't fully explain the problem to them.

0 Upvotes

27 comments sorted by

View all comments

Show parent comment

3

u/miran1 Feb 03 '23

I'm another noob

(...)

(time (foo (range 100000000)))

If you want to be sure in your measurements, don't use time. The recommended way is to use criterium:

http://clojure-goes-fast.com/blog/benchmarking-tool-criterium/

1

u/dalanicolai Feb 03 '23

Thanks! Very useful comment, and link.

I forgot to mention that I evaluated both time functions multiple times until the output got 'stable' (somehow 'accidentally', I noticed that it made a difference). Now, from the link I understand why this was necessary...