Are there any good Clojure benchmarks?

12,284

Solution 1

See jafingerhut / clojure-benchmarks

iirc the current clojure implementation has not been focussed on performance, but the next version supposedly will.

Solution 2

This is an important question that just about everyone thinks about before considering clojure. Its also a hard question even for mature languages that are not adding things, like chunked sequences, that radically change the performance of some specific (though common) tasks. I found some good thoughs in this thread. Many of the benchmarks you find will be related to previous versions of both java and clojure so its unlikely that anyone can find "really good benchmarks".

I great question to ask your self here is Is Java fast enough. This is a precondition to clojure being fast enough. If you can convince your self that the answer to this question is yes then it is safe to proceed in Clojure and implement the parts that your profiling identifies as bottle necks in Java. Because you have a failback language with well known performance It will generally be safe to go with Clojure.

Solution 3

For performance questions please refer to this blogpost:

http://meshy.org/2009/12/13/widefinder-2-with-clojure.html

This shows a Clojure implementation of the WideFinder2 challenge which is faster than both Java, Scala and single threaded C. Compare with official times.

Regarding Daniels remark that Clojure will never be faster, we see that its obviously incorrect based on the results above. Mutability is faster than immutability which is Clojures default, yet Clojure allows for local transients (ie. temporarily mutable data), so that one can achieve optimal speed.

Refer to clj-me.cgrand.net for many optimization techniques.

In conclusion: Clojure can be as fast as you would like it to be while still allowing you to maintain a simple elegant and robust codebase, almost a unique combination.

Solution 4

You might also be interested in the concur.next serie from Tim Bray. He discusses some performance issues.

Solution 5

Clojure will never be able to match a Scala program that takes full advantage of mutability in an algorithm that's benefitted by it. There's also the fact that Clojure is a dynamic language, which, presently, isn't very well supported by JVM.

On the other hand, Clojure excels at enabling parallel, asynchronous and distributed algorithms, and immutable algorithms generally speaking.

So, if you want (mostly) immutability and multicore efficiency, Clojure will make those much easier to achieve. If your algorithms really, really need to heavily use mutability for efficiency, then Scala will make those easier.

Anything in between, it likely won't matter either way.

Share:
12,284
Shane
Author by

Shane

Quantitative researcher focusing on statistics and machine learning methods in finance. Primarily use R, C++, Python, various databases (including OneTick and KDB), and LaTeX on a daily basis. Twitter: @statalgo Blog: http://www.statalgo.com (largely inactive) Former moderator on data analysis stack exchange site: http://stats.stackexchange.com/ Proposer of Quantitative Finance stack exchange site: http://area51.stackexchange.com/proposals/117/quantitative-finance?referrer=EZoOPpokWeo1

Updated on June 04, 2022

Comments