Why is the Clojure Hello World program so slow compared to Java and Python?

后端 未结 4 1170
借酒劲吻你
借酒劲吻你 2021-02-20 08:49

Update

As suggested by many people, it looks like this was because of the fact that clojure code was first compiled and then executed. AOT compilation s

4条回答
  •  粉色の甜心
    2021-02-20 09:06

    To add to dnolen's answer, when doing Python vs Clojure timing contents, you might want to package your "basic unit of work" as a function and then use the time macro (in Clojure) or the timeit.timeit function (in Python; or, better yet, use the timing facilities of IPython) at the REPL. The results should be roughly comparable. (Note that Clojure code needs to be "warmed up" by running it a few times to achieve full performance.)

    There are also some benchmarking suites for Clojure, for example Criterium; you might want to consider using one of them.

提交回复
热议问题