privatevoidtestHashMap(){ longstart= System.currentTimeMillis(); Map<Integer, Integer> m = newHashMap(); for (inti=0; i < 200000; i++){ m.put(i, i + 100); } Log.i("Map", "testHashMap 1 time used " + (System.currentTimeMillis() - start));
start = System.currentTimeMillis(); m = newHashMap(); for (inti=0; i < 200000; i++){ m.get(i); } Log.i("Map", "testHashMap 2 time used " + (System.currentTimeMillis() - start)); }
privatevoidtestArrayMap(){ longstart= System.currentTimeMillis(); Map<Integer, Integer> m = newArrayMap<>(); for (inti=0; i < 200000; i++){ m.put(i , i + 100); } Log.i("Map", "testArrayMap 1 time used " + (System.currentTimeMillis() - start));
start = System.currentTimeMillis(); m = newArrayMap<>(); for (inti=0; i < 200000; i++){ m.get(i); } Log.i("Map", "testArrayMap 2 time used " + (System.currentTimeMillis() - start)); }