I am an ultimate fan of java high performance framework or library. Java native collection framework always works with primitive wrapper class such as Integer, Float e.t.c. Boxing and unboxing of wrapper class to primitive data type always decrease the java execution performance. Most of us, always looking for such a library or framework to works with primitive data type in collections for increasing performance of Java application. Most of the time i uses javolution framework to get better performance, however, this holiday i have read about a few new java collections frameworks and decided to do some homework benchmarking to find out, how much they could better than Java native collection framework.
I have examine two new java collection framework, one of them are fastutil and another one are HPPC. For benchmarking i have used java JMH with mode Throughput. For benchmarking i took similar collection for java ArrayList, HashSet and HasMap from two above described frameworks.
Collections:
Integer for Java native collection and int for HPPC and fastutils.
Host machine configuration:
OS: OSX El Capitan
CPU: 4
RAM: 16
HDD: SDD
JMH Configuration:
Fork: 10
iteration: 10
warm iteration: 10
Benchmark of List:
Operations: add, retrieve by Iterator
Result of the benchmark is as follows:
it's obvious that FastUtil IntArrayList collection win with huge score. if you are wonder and decided that fastutil framework will always win the benchmark, you will be surprised. Lets examine another collections
Benchmark of Set:
Operations: put, retrieve by Iterator
Result of the benchmark is as follows:
Wonder!! me too, i have over checked the code. Java native HashSet wins over all other framework, very interesting the result of the fastutil score, it's only 89.
Benchmark of Map:
Operations: put, retrieve by Iterator
Result of the benchmark is as follows:
Similar score with Set, Java native Map is wining over other frameworks. Question is, why fastutil collection framework giving such a poor score? Answer of this question we will examine in next few blogs.
I have examine two new java collection framework, one of them are fastutil and another one are HPPC. For benchmarking i have used java JMH with mode Throughput. For benchmarking i took similar collection for java ArrayList, HashSet and HasMap from two above described frameworks.
Collections:
- ArrayList
- HashSet
- HashMap
Integer for Java native collection and int for HPPC and fastutils.
Host machine configuration:
OS: OSX El Capitan
CPU: 4
RAM: 16
HDD: SDD
JMH Configuration:
Fork: 10
iteration: 10
warm iteration: 10
Benchmark of List:
- Java native: ArrayList<Integer>
- FastUtil:it.unimi.dsi.fastutil.ints.IntArrayList
- HPPC:com.carrotsearch.hppc.IntArrayList
Operations: add, retrieve by Iterator
Result of the benchmark is as follows:
it's obvious that FastUtil IntArrayList collection win with huge score. if you are wonder and decided that fastutil framework will always win the benchmark, you will be surprised. Lets examine another collections
Benchmark of Set:
- Java native: HashSet<Integer>
- FastUtil:it.unimi.dsi.fastutil.ints.IntSet
- HPPC:com.carrotsearch.hppc.IntHashSet
Operations: put, retrieve by Iterator
Result of the benchmark is as follows:
Wonder!! me too, i have over checked the code. Java native HashSet wins over all other framework, very interesting the result of the fastutil score, it's only 89.
Benchmark of Map:
- Java native: HashMap<Integer>
- FastUtil:it.unimi.dsi.fastutil.ints.Int2IntArrayMap
- HPPC:com.carrotsearch.hppc.IntIntHashMap
Operations: put, retrieve by Iterator
Result of the benchmark is as follows:
Similar score with Set, Java native Map is wining over other frameworks. Question is, why fastutil collection framework giving such a poor score? Answer of this question we will examine in next few blogs.
Comments