This is interesting, but there could be many things in play here. Try re-running the tests outside of lein (via compilation to a uberjar and then running with java -jar) and also use criterium, as it will warn about many things that coul effect performance .
https://github.com/hugoduncan/criterium Timothy Baldridge On Wed, Mar 11, 2015 at 9:38 AM, Brent Millare <brent.mill...@gmail.com> wrote: > Doing some simple microbenchmarks, I found something unexpected: > > (time > (let [v (volatile! 1)] > (dotimes [x 100000000] > (vreset! v @v)))) > "Elapsed time: 1016.992146 msecs" > > (time > (let [v (java.util.concurrent.atomic.AtomicLong. 1)] > (dotimes [x 100000000] > (.set v (.get v))))) > "Elapsed time: 672.869727 msecs" > > (time > (let [v (java.util.concurrent.atomic.AtomicReference. {})] > (dotimes [x 100000000] > (.set v (.get v))))) > "Elapsed time: 678.143133 msecs" > > (time > (let [v (atom 1)] > (dotimes [x 100000000] > (reset! v @v)))) > "Elapsed time: 1100.689493 msecs" > > I expected volatile's to be faster. Maybe I'm not understanding the > correct use case for volatiles but java.util.concurrent.atomic.Atomic* > seems to be clearly the most performant. Given the downsides of using > volatiles, is their existence justified when safer and faster alternatives > exist? > > -- > 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/d/optout. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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/d/optout.