Ralph
Ralph

Reputation: 32264

Micro-benchmark comparing Scala mutable, immutable collections with java.util.concurrent.* collections

Are there any published micro-benchmarks that compare the Scala mutable and immutable collections with each other and the collections in java.util.concurrent, in multi-threaded environments? I am particularly interested in cases where readers far outnumber writers, like caching HashMaps in server-side code.

Micro-benchmarks of the Clojure collections would also be acceptable, as their algorithms are similar to those used in the Scala 2.8 persistent collections.

I'll write my own if there are none already done, but writing good micro-benchmarks is not trivial.

Upvotes: 5

Views: 1206

Answers (3)

Mike Slinn
Mike Slinn

Reputation: 8405

Li Haoyi's Benchmarking Scala Collections is a detailed and comprehensive study that addresses your query. It is way too long to quote here.

Upvotes: 1

axel22
axel22

Reputation: 32335

There are some results comparing Java hash maps, Scala hash maps, Java concurrent hash maps, Java concurrent skip lists, Java parallel arrays and Scala parallel collections here (at the end of the technical report):

http://infoscience.epfl.ch/record/165523/files/techrep.pdf

There is a more detailed comparison of concurrent skip lists and Java concurrent hash maps here (also at the end of the main part of the report, before the appendix):

http://infoscience.epfl.ch/record/166908/files/ctries-techreport.pdf

These micro benchmarks are focused on testing the performance of one single operation. If you plan to write your own benchmarks, this will probably be useful:

http://buytaert.net/files/oopsla07-georges.pdf

Upvotes: 2

Chochos
Chochos

Reputation: 5159

Why don't you try using java.util.concurrent.ConcurrentHashMap then? that way you don't have to synchronize, and your million reads will be much faster (as well as the one write).

Upvotes: 0

Related Questions