1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 import java.util.Map;
18 import java.util.HashMap;
19 
20 public class Main {
21 
test_virtual(HashMap map)22   public static long test_virtual(HashMap map) {
23     Integer intobj = new Integer(0);
24     String s = "asdf";
25     long start = System.currentTimeMillis();
26     for (int i = 0; i < 10000; i++) {
27         map.put(intobj, s);
28     }
29     long end = System.currentTimeMillis();
30     return (end - start);
31   }
32 
test_interface(Map map)33   public static long test_interface(Map map) {
34     Integer intobj = new Integer(0);
35     String s = "asdf";
36     long start = System.currentTimeMillis();
37     for (int i = 0; i < 10000; i++) {
38         map.put(intobj, s);
39     }
40     long end = System.currentTimeMillis();
41     return (end - start);
42   }
43 
main(String[] args)44   public static void main(String[] args) {
45     HashMap hashmap = new HashMap();
46     long elapsed = test_virtual(hashmap);
47     System.out.println("test_virtual done");
48     hashmap.clear();
49 
50     elapsed = test_interface(hashmap);
51     System.out.println("test_interface done");
52   }
53 }
54