
71

Scala Meetup WarmUp: 2.12.x慢了?
source link: https://zhuanlan.zhihu.com/p/44317356?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Scala Meetup WarmUp: 2.12.x慢了?
《Scala实用指南》译者,TeXmacs开发者
Scala 2.12.x 比 2.11.x 的编译速度快了不少,但是实测发现Scala 2.12.x变慢了。
sbt clean 'project benchmark' 'set scalaVersion := "2.11.12"' 'jmh:run -f 1 -i 20 -wi 20 -t 1 Richards'
[info] Benchmark Mode Cnt Score Error Units
[info] Richards.run thrpt 20 7464.953 ± 65.303 ops/s
sbt clean 'project benchmark' 'set scalaVersion := "2.12.6"' 'jmh:run -f 1 -i 20 -wi 20 -t 1 Richards'
[info] Benchmark Mode Cnt Score Error Units
[info] Richards.run thrpt 20 6623.674 ± 51.901 ops/s
在这个评测中,2.11.x的吞吐大约是2.12.x吞吐的1.1倍。
依据 https://github.com/scala/scala-dev/issues/81
我们需要在Scala 2.12.x 中使用这两个编译参数,提升所生成字节码的性能:
-opt:l:inline
-opt-inline-from
sbt clean 'project benchmark' 'set scalaVersion := "2.12.6"' 'set scalacOptions in ThisBuild ++= Seq("-opt:l:inline", "-opt-inline-from")' 'jmh:run -f 1 -i 20 -wi 20 -t 1 Richards'
[info] Benchmark Mode Cnt Score Error Units
[info] Richards.run thrpt 20 7456.257 ± 23.585 ops/s
评测代码见:sadhen/scala-benchmark-starter
更多细节大家可以参与我们的 Meetup 讨论哦!
</div
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK