Performance graphs for javolution.util package (Javolution Collections versus Standard Collections Classes) are shown in Annex of the presentation:

Collection Classes for Real-Time and High-Performance Applications (pdf)


The benchmark results below use the new Javolution TimeContext, it shows the average execution time followed by the minimum time in parenthesis.

The benchmark can be executed with the command:

java -server -Xms512M -Xmx512M -jar javolution.jar perf

or simply: ant run.

Windows XP - Intel Pentium Dual Core - 2.9 GHz - 512M of RAM:

C:\javolution-5.2>java -version
java version "1.6.0_01-ea"
Java(TM) SE Runtime Environment (build 1.6.0_01-ea-b01)
Java HotSpot(TM) Client VM (build 1.6.0_01-ea-b01, mixed mode)

C:\javolution-5.2>ant run
      ...
run:
     [java] [info] Javolution - Java(TM) Solution for Real-Time and Embedded Systems
     [java] [info] Version 5.2.4 (J2SE 1.6+) September 20 2007 (http://javolution.org)
     [java] [info]
     [java] [info] Load Configurable Parameters from System.getProperties()...
     [java] [info]
     [java] [info] -------------------------------------------------
     [java] [info] -- Test Suite for package javolution.context.* --
     [java] [info] -------------------------------------------------
     [java] [test] ConcurrentContext - Quick Sort (size: 10000, concurrency: 0): 7.84 ms (minimum 4.83 ms)
     [java] [test] ConcurrentContext - Quick Sort (size: 10000, concurrency: 1): 4.74 ms (minimum 4.42 ms)
     [java] [info]
     [java] [test] HeapContext (default) - Create 1000 small objects: 19.6 ns (minimum 13.6 ns)
     [java] [test] StackContext            Create 1000 small objects: 20.4 ns (minimum 16.2 ns)
     [java] [info]
     [java] [test] HeapContext (default)            - new char[4096]: 4.51 us (minimum 2.36 us)
     [java] [test] Recycled - ArrayFactory.CHARS_FACTORY.array(4096): 435 ns (minimum 388 ns)
     [java] [info]
     [java] [info] ----------------------------------------------
     [java] [info] -- Test Suite for javolution.util.* classes --
     [java] [info] ----------------------------------------------
     [java] [info] Collections/Maps of 256 elements (configurable "javolution.UtilTestSuite#SIZE")
     [java] [info]
     [java] [info]  - Add elements to collection -
     [java] [test] New javolution.util.FastTable.add(element)                  : 17.3 ns (minimum 14.8 ns)
     [java] [test] New java.util.ArrayList.add(element)                        : 21.0 ns (minimum 18.0 ns)
     [java] [test] New javolution.util.FastList.add(element)                   : 41.7 ns (minimum 36.0 ns)
     [java] [test] New java.util.LinkedList.add(element)                       : 34.5 ns (minimum 24.4 ns)
     [java] [test] New javolution.util.FastSet.add(element)                    : 119 ns (minimum 94.5 ns)
     [java] [test] New java.util.HashSet.add(element)                          : 174 ns (minimum 154 ns)
     [java] [test] Recycled javolution.util.FastTable.add(element)             : 13.8 ns (minimum 13.0 ns)
     [java] [test] Recycled java.util.ArrayList.add(element)                   : 13.0 ns (minimum 12.4 ns)
     [java] [test] Recycled javolution.util.FastList.add(element)              : 19.8 ns (minimum 18.6 ns)
     [java] [test] Recycled java.util.LinkedList.add(element)                  : 36.2 ns (minimum 26.0 ns)
     [java] [test] Recycled javolution.util.FastSet.add(element)               : 69.8 ns (minimum 65.7 ns)
     [java] [test] Recycled java.util.HashSet.add(element)                     : 141 ns (minimum 130 ns)
     [java] [info]
     [java] [info]  - Iterate over collections -
     [java] [test] Iterates over javolution.util.FastTable                     : 6.44 ns (minimum 5.34 ns)
     [java] [test] Iterates over java.util.ArrayList                           : 10.3 ns (minimum 8.41 ns)
     [java] [test] Iterates over javolution.util.FastList                      : 14.7 ns (minimum 13.0 ns)
     [java] [test] Iterates over java.util.LinkedList                          : 23.1 ns (minimum 20.9 ns)
     [java] [test] Iterates over javolution.util.FastSet                       : 21.3 ns (minimum 19.4 ns)
     [java] [test] Iterates over java.util.HashSet                             : 29.0 ns (minimum 25.9 ns)
     [java] [info]
     [java] [info]  - Put new key/value pairs to map instance -
     [java] [test] New javolution.util.FastMap.put(key, value)                 : 76.0 ns (minimum 65.3 ns)
     [java] [test] New java.util.HashMap.put(key, value)                       : 133 ns (minimum 118 ns)
     [java] [test] New java.util.LinkedHashMap.put(key, value)                 : 184 ns (minimum 161 ns)
     [java] [test] New javolution.UtilTestSuite$SharedFastMap.put(key, value)  : 130 ns (minimum 117 ns)
     [java] [test] New java.util.concurrent.ConcurrentHashMap.put(key, value)  : 367 ns (minimum 323 ns)
     [java] [test] Recycled javolution.util.FastMap.put(key, value)            : 36.3 ns (minimum 32.0 ns)
     [java] [test] Recycled java.util.HashMap.put(key, value)                  : 107 ns (minimum 95.1 ns)
     [java] [test] Recycled java.util.LinkedHashMap.put(key, value)            : 162 ns (minimum 150 ns)
     [java] [info]
     [java] [info]  - Retrieves map value from key -
     [java] [test] javolution.util.FastMap.get(key):                           : 16.1 ns (minimum 14.9 ns)
     [java] [test] java.util.HashMap.get(key):                                 : 14.6 ns (minimum 13.3 ns)
     [java] [test] java.util.LinkedHashMap.get(key):                           : 52.1 ns (minimum 48.3 ns)
     [java] [test] javolution.UtilTestSuite$SharedFastMap.get(key):            : 56.9 ns (minimum 54.3 ns)
     [java] [test] java.util.concurrent.ConcurrentHashMap.get(key):            : 59.2 ns (minimum 55.5 ns)
     [java] [info]
     [java] [info]  - Removes keys from map -
     [java] [test] javolution.util.FastMap.remove(key):                        : 88.2 ns (minimum 75.1 ns)
     [java] [test] java.util.HashMap.remove(key):                              : 102 ns (minimum 91.9 ns)
     [java] [test] java.util.LinkedHashMap.remove(key):                        : 124 ns (minimum 114 ns)
     [java] [test] javolution.UtilTestSuite$SharedFastMap.remove(key):         : 83.6 ns (minimum 75.2 ns)
     [java] [test] java.util.concurrent.ConcurrentHashMap.remove(key):         : 235 ns (minimum 220 ns)
     [java] [info]
     [java] [info]  - Iterates over map entries -
     [java] [test] Iterates over javolution.util.FastMap                       : 6.82 ns (minimum 5.53 ns)
     [java] [test] Iterates over java.util.HashMap                             : 15.5 ns (minimum 13.9 ns)
     [java] [test] Iterates over java.util.LinkedHashMap                       : 15.9 ns (minimum 13.7 ns)
     [java] [test] Iterates over javolution.UtilTestSuite$SharedFastMap        : 21.1 ns (minimum 19.5 ns)
     [java] [test] Iterates over java.util.concurrent.ConcurrentHashMap        : 42.6 ns (minimum 30.0 ns)
     [java] [info]
     [java] [info]  - Direct collection/map iterations (no iterator) -
     [java] [test] javolution.util.FastTable.get(i)                            : 3.20 ns (minimum 2.99 ns)
     [java] [test] java.util.ArrayList.get(i)                                  : 2.21 ns (minimum 1.98 ns)
     [java] [test] javolution.util.FastList.Node.getNext()                     : 3.56 ns (minimum 3.26 ns)
     [java] [test] javolution.util.FastMap.Entry.getNext()                     : 3.66 ns (minimum 3.32 ns)
     [java] [info]
     [java] [info] More tests coming soon...
     

FAQ:

  1. Although it looks nice, I see that some of your collection classes are not always faster than their Java 6 counterparts.

    Some classes are faster, others are slower (for example ArrayList.get(int) is faster with the -server option, slower without it).

    Overall, there is no significative difference in average execution time. The main advantage of Javolution collections is that they are time-deterministic (the maximum execution time is very close to the minimum execution time) and they are RTSJ-Safe.

    They have some additional characteristics such as thread-safe without synchronization, support for custom key/value comparators, direct record iterations (faster than iterators), recyclable, reduced impact on GC (fragmentation or large arrays allocations), support for custom entry implementation (FastMap) or custom node implementation (FastList), etc.