scala 是否有任何好的 Clojure 基准测试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2186709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Are there any good Clojure benchmarks?
提问by Shane
Edit:The Clojure benchmarks are up on the Benchmarks Game.
编辑:Clojure 基准测试在 Benchmarks Game上有所提升。
I have made this question community wiki and invite others to keep it updated.
我已经制作了这个问题社区维基并邀请其他人保持更新。
Is anyone aware of benchmarks of Clojure's performance?
有没有人知道 Clojure 的性能基准?
I have done some of my own (although nothing too formal) and it didn't fair too well in comparison to other functional languages (tried Haskell and OCaml). But how does it look compared to Java or another language on the JVM (e.g. Scala)? And how does it compare to other Lisps?
我自己做了一些(虽然没有什么太正式的),但与其他函数式语言(尝试过 Haskell 和 OCaml)相比,它并不太好。但是与 Java 或 JVM 上的其他语言(例如 Scala)相比,它看起来如何?它与其他 Lisp 相比如何?
There was some discussionon the Computer Language Benchmarks Gameforum about adding Clojure on there, but nothing has been done yet.
在Computer Language Benchmarks Game论坛上有一些关于在那里添加 Clojure 的讨论,但还没有做任何事情。
Edit:I'm going to continue to add to this as I find more:
编辑:当我发现更多时,我将继续添加:
@igouy pointed out that the benchmark scripts for clojure are being createdby jafingerhut on github.
@igouy 指出 clojure 的基准脚本是由 github 上的 jafingerhut创建的。
Two very relevant threads from the Clojure discussion group:
来自 Clojure 讨论组的两个非常相关的主题:
- Clojure performance tests and clojure a little slower than Java
- Clojure speed
- Fibonacci function performance compare between clojure and scala
And separately, these blog posts:
另外,这些博客文章:
- Basic Clojure, Java and JVM Language performance
- Scala Vs Clojure?—?Let's get down to businessand Scala vs Clojure?—?Round 2: Concurrency!
- Python vs Clojure?—?Evolvingand Python vs Clojure?—?Reloaded
- Clojure vs. Ruby
- Clojure Discussion - When Performance Matters
- Clojure vs Ruby & Scala?—?Transient Newsgroups
- 基本的 Clojure、Java 和 JVM 语言性能
- Scala 与 Clojure?—?让我们进入正题,Scala 与 Clojure?—?第 2 轮:并发!
- Python vs Clojure?-?Evolvingand Python vs Clojure?-?Reloaded
- Clojure 与 Ruby
- Clojure 讨论 - 当性能很重要时
- Clojure vs Ruby & Scala?-?瞬态新闻组
And lastly, a related question on stackoverflow:
最后,关于stackoverflow的一个相关问题:
Most of these discussions lead me to think that Clojure's performance is very favorable in comparison to other languages running on the JVM, although there is no doubt that it can be very difficult to come to a broad conclusion when comparing languages because their performance can vary dramatically dependent on the task.
大多数讨论让我认为 Clojure 的性能与在 JVM 上运行的其他语言相比非常有利,尽管毫无疑问,在比较语言时很难得出广泛的结论,因为它们的性能可能会有很大差异取决于任务。
Edit:
编辑:
Lau Jensen just posted a great discussion about benchmarking with JVM languages on his blog: "Getting benchmarking right".
Lau Jensen 刚刚在他的博客上发表了一篇关于使用 JVM 语言进行基准测试的精彩讨论:“正确进行基准测试”。
采纳答案by igouy
See jafingerhut / clojure-benchmarks
参见 jafingerhut / clojure-benchmarks
iircthe current clojure implementation has not been focussed on performance, but the next version supposedly will.
iirc当前的 clojure 实现并没有关注性能,但据说下一个版本会。
回答by Arthur Ulfeldt
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".
这是几乎每个人在考虑 clojure 之前都会考虑的一个重要问题。即使对于不添加诸如分块序列之类的东西的成熟语言来说,这也是一个难题,这些东西从根本上改变了某些特定(尽管常见)任务的性能。我在这个线程中发现了一些好的想法。您找到的许多基准测试都与 java 和 clojure 的先前版本相关,因此任何人都不太可能找到“真正好的基准测试”。
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.
我在这里问你自己的一个很好的问题是 Java 是否足够快。这是 clojure 足够快的先决条件。如果您能让自己相信这个问题的答案是肯定的,那么在 Clojure 中继续并在 Java 中实现您的分析识别为瓶颈的部分是安全的。因为您有一种性能众所周知的故障回复语言 使用 Clojure 通常是安全的。
回答by Lau Jensen
For performance questions please refer to this blogpost:
有关性能问题,请参阅此博文:
http://meshy.org/2009/12/13/widefinder-2-with-clojure.html
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.
这显示了 WideFinder2 挑战的 Clojure 实现,它比 Java、Scala 和单线程 C 都快。与官方时间进行比较。
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.
关于 Daniels 所说的 Clojure 永远不会更快,我们看到根据上面的结果它显然是不正确的。可变性比 Clojure 默认的不变性更快,但 Clojure 允许局部瞬态(即临时可变数据),因此可以达到最佳速度。
Refer to clj-me.cgrand.net for many optimization techniques.
有关许多优化技术,请参阅 clj-me.cgrand.net。
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.
结论:Clojure 可以像您希望的那样快,同时仍然允许您维护一个简单、优雅和健壮的代码库,几乎是一个独特的组合。
回答by ewernli
You might also be interested in the concur.nextserie from Tim Bray. He discusses some performance issues.
您可能还对Tim Bray的concur.next系列感兴趣。他讨论了一些性能问题。
回答by Daniel C. Sobral
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.
Clojure 永远无法匹配在受益于它的算法中充分利用可变性的 Scala 程序。还有一个事实是,Clojure 是一种动态语言,目前 JVM 并没有很好地支持它。
On the other hand, Clojure excels at enabling parallel, asynchronous and distributed algorithms, and immutable algorithms generally speaking.
另一方面,Clojure 擅长启用并行、异步和分布式算法,以及一般来说不可变的算法。
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.
因此,如果您想要(主要)不变性和多核效率,Clojure 将使这些更容易实现。如果你的算法真的、真的需要大量使用可变性来提高效率,那么 Scala 会让这些变得更容易。
Anything in between, it likely won't matter either way.
介于两者之间的任何事情,无论哪种方式都可能无关紧要。

