39 | private static void hashmapPerf(final boolean syncd) { |
40 |
41 | // HashMap |
42 | map = new HashMap<>(); |
43 | if (syncd) { |
44 | map = Collections.synchronizedMap(map); |
45 | } |
46 | start = System.currentTimeMillis(); |
47 | for (int i = 0; i <> |
48 | map.put(bob + i, bob); |
49 | } |
50 | map.put(null, null); |
51 | end = System.currentTimeMillis(); |
52 | System.out.println("Inserting HashMap: " + (end - start) + " ms - Synchronized: " + syncd); |
53 |
54 | start = System.currentTimeMillis(); |
55 | for (int i = 0; i <> |
56 | map.get(bob + i); |
57 | } |
58 |
59 | end = System.currentTimeMillis(); |
60 | System.out.println("Reading HashMap: " + (end - start) + " ms - Synchronized: " + syncd); |
61 | |
62 | start = System.currentTimeMillis(); |
63 | for(Entry<> e : map.entrySet()){ |
64 | String val = e.getValue(); |
65 | } |
66 | end = System.currentTimeMillis(); |
67 | System.out.println("Reading HashMap by Entry: " + (end - start) +" - Synchronized: " + syncd); |
68 | } |
69 |
70 | /** |
71 | * Hashtable perf. |
72 | */ |
No comments:
Post a Comment