Introduction

Here are benchmarking results for «Map Performance: Java vs Scala» blog post.

The performance tests are performed via JMH. The configuration of a hardware is Intel® Core™ i7-1165G7 @ 2.80GHz × 8 (4 core + 4 HT) with 16 GB RAM.

Charts

avg - average, p0 - percentile 0 (min), p50 - percentile 50 (median), p95 - percentile 95, p99 - percentile 99, p100 - percentile 100 (max)

Map Lookup Performance

Benchmarks for java.util.HashMap vs Map.asJava vs immutable.Map vs mutable.Map.

openjdk-17: 2.12 vs 2.13

Comparing performance of Map between scala 2.12 and 2.13, using openjdk-17.

All JDKs

Comparing performance of Map for different versions of JDK: openjdk-8 vs openjdk-11 vs openjdk-17. Use switcher above to change scala version.

Set Lookup Performance

Same benchmark but for Set. Notice that HashSet internally uses HashMap, so the performance, supposedly, should be the same.

openjdk-17: 2.12 vs 2.13

Comparing performance of Set between scala 2.12 and 2.13, using openjdk-17.

All JDKs

Comparing performance of Set for different versions of JDK: openjdk-8 vs openjdk-11 vs openjdk-17. Use switcher above to change scala version.

Full JMH logs:openjdk-8 (scala 2.12), openjdk-11 (scala 2.12), openjdk-17 (scala 2.12), openjdk-8 (scala 2.13), openjdk-11 (scala 2.13), openjdk-17 (scala 2.13).