1 package org.simantics.db.tests.performance.java;
3 import gnu.trove.map.hash.TIntByteHashMap;
5 import java.util.TreeMap;
7 import org.simantics.db.testing.base.TestCommonPerf;
10 public class MapTest extends TestCommonPerf {
12 public void a(TIntByteHashMap map, int i) {
14 byte value = map.get(test);
20 public void b(TreeMap<Integer, Byte> map2, int i) {
21 Byte value = map2.get(i);
27 public void test() throws Exception {
29 TIntByteHashMap map = new TIntByteHashMap();
31 long start = System.nanoTime();
32 for(int i=0;i<12000000;i++) {
34 byte value = map.get(test);
39 long duration = System.nanoTime() - start;
40 System.err.println("took " + 1e-9*duration);
42 TIntByteHashMap map2 = new TIntByteHashMap();
43 long start2 = System.nanoTime();
44 for(int i=0;i<10000000;i++) a(map2, i);
45 long duration2 = System.nanoTime() - start2;
46 System.err.println("took " + 1e-9*duration2);
48 TreeMap<Integer, Byte> map3 = new TreeMap<Integer, Byte>();
49 long start3 = System.nanoTime();
50 for(int i=0;i<10000000;i++) {
51 Byte value = map3.get(i);
56 long duration3 = System.nanoTime() - start3;
57 System.err.println("took " + 1e-9*duration3);
59 TreeMap<Integer, Byte> map4 = new TreeMap<Integer, Byte>();
60 long start4 = System.nanoTime();
61 for(int i=0;i<10000000;i++) b(map4, i);
62 long duration4 = System.nanoTime() - start4;
63 System.err.println("took " + 1e-9*duration4);