MCPcopy Index your code
hub / github.com/apache/groovy / main

Method main

benchmark/bench/hash2.java:12–36  ·  view source on GitHub ↗
(String args[])

Source from the content-addressed store, hash-verified

10
11public class hash2 {
12 public static void main(String args[]) {
13 int n = Integer.parseInt(args[0]);
14 HashMap hash1 = new HashMap(10000);
15 HashMap hash2 = new HashMap(n);
16
17 for(int i = 0; i < 10000; i++)
18 hash1.put("foo_" + Integer.toString(i, 10), new Val(i));
19 for(int i = 0; i < n; i++) {
20 Iterator it = hash1.entrySet().iterator();
21 while(it.hasNext()) {
22 Map.Entry h1 = (Map.Entry)it.next();
23 String key = (String)h1.getKey();
24 int v1 = ((Val)h1.getValue()).val;
25 if (hash2.containsKey(key))
26 ((Val)hash2.get(key)).val += v1;
27 else
28 hash2.put(key, new Val(v1));
29 }
30 }
31
32 System.out.print(((Val)hash1.get("foo_1")).val + " " +
33 ((Val)hash1.get("foo_9999")).val + " " +
34 ((Val)hash2.get("foo_1")).val + " " +
35 ((Val)hash2.get("foo_9999")).val + "\n");
36 }
37}

Callers

nothing calls this directly

Calls 12

parseIntMethod · 0.80
putMethod · 0.65
toStringMethod · 0.65
iteratorMethod · 0.65
getKeyMethod · 0.65
getValueMethod · 0.65
containsKeyMethod · 0.65
getMethod · 0.65
entrySetMethod · 0.45
hasNextMethod · 0.45
nextMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected