TIntList l = new TIntArrayList();
TLongLongMap m = new TLongLongHashMap();
public static long troveEach() { final long [] rvalue = {0}; // troveMap - TLongLongHashMap // TLongProcedure , // false // troveMap.forEachValue(new TLongProcedure() { @Override public boolean execute(long value) { rvalue[0] += value; return true; } }); return rvalue[0]; }
$ java -version java version "1.7.0_21" Java(TM) SE Runtime Environment (build 1.7.0_21-b11) Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode) $ java -server -XX:+AggressiveOpts -Xms2048m \ -Xmx2048m -jar microbenchmarks.jar ".*Trove.*" -prof gc -i 3 -r 5s
Benchmark Mode Thr Cnt Sec Mean Mean Error Units // Insert In List <Integer> IntListJdkInsert thrpt 1 3 5 104.950 6.756 ops / sec // Brute-force List <Integer> IntListJdkTraverse thrpt 1 3 5 774.100 71.809 ops / sec // Insert in TIntArrayList IntListTroveInsert thrpt 1 3 5 424.556 28.239 ops / sec // Brute force TIntArrayList IntListTroveTraverse thrpt 1 3 5 3548.806 7.712 ops / sec // Paste into HashMap <Long, Long> LongHashMapJdkInsert thrpt 1 3 5 24.683 1.994 ops / sec // search for all items in HashMap <Long, Long> by turns LongHashMapJdkSearch thrpt 1 3 5 67.789 1.119 ops / sec // full search of HashMap <Long, Long> values LongHashMapJdkTraverse thrpt 1 3 5 99.761 0.882 ops / sec // Paste to TLongLongMap LongHashMapTroveInsert thrpt 1 3 5 28.750 0.165 ops / sec // search all items in TLongLongMap by turns LongHashMapTroveSearch thrpt 1 3 5 145.933 0.416 ops / sec // exhaustive search of TLongLongMap values using forEach LongHashMapTroveTraverse thrpt 1 3 5 318.528 0.980 ops / sec
jd List<Integer>: Iteration 1 (5s in 1 thread): 103,950 ops/sec GC | wall time = 5,002 secs, GC time = 0,331 secs, GC% = 6,62%, GC count = +24 Trove TIntArrayList: Iteration 1 (5s in 1 thread): 428,400 ops/sec GC | wall time = 5,002 secs, GC time = 0,019 secs, GC% = 0,38%, GC count = +32
public class TIntArrayList implements TIntList, Externalizable { static final long serialVersionUID = 1L; /** the data of the list */ protected int[] _data;
Benchmark Mode Thr Cnt Sec Mean Mean Error Units IntListJdkInsert thrpt 1 3 5 239478.011 871.469 ops / sec IntListJdkTraverse thrpt 1 3 5 1326701.717 1649.389 ops / sec IntListTroveInsert thrpt 1 3 5 315562.594 2483.415 ops / sec IntListTroveTraverse thrpt 1 3 5 3630599.806 10822.903 ops / sec LongHashMapJdkInsert thrpt 1 3 5 45315.689 47.630 ops / sec LongHashMapJdkSearch thrpt 1 3 5 114759.789 424.996 ops / sec LongHashMapJdkTraverse thrpt 1 3 5 210012.550 139.001 ops / sec LongHashMapTroveInsert thrpt 1 3 5 33078.583 119.127 ops / sec LongHashMapTroveSearch thrpt 1 3 5 148311.567 267.613 ops / sec LongHashMapTroveTraverse thrpt 1 3 5 351955.550 901.902 ops / sec
Source: https://habr.com/ru/post/187234/
All Articles