public static void count(int count) { System.out.println(new Date()); List<Integer> ilist = new ArrayList<Integer>(); for (int i = 0; i < count; i++) { ilist.add(i); } System.out.println(new Date()); } public static void count2(int count) { System.out.println(new Date()); Map<Integer, Integer> m = new HashMap<Integer, Integer>(); for (int i = 0; i < count; i++) { m.put(i, i); } System.out.println(new Date()); } public static void main(String[] args) { count(9000000); // Wed Feb 04 17:47:58 CST 2015 // Wed Feb 04 17:48:06 CST 2015 // count2(9000000); // Wed Feb 04 17:48:24 CST 2015 // 3分多钟还没结束,就停止程序了。 // count2(3000000); // Wed Feb 04 17:54:16 CST 2015 // Wed Feb 04 17:54:17 CST 2015 }
经上所测试,在数据量大时,现测试大于300万时就效率好慢。
时间: 2024-10-16 10:00:16