首页 > 其他 > 详细

测试Map,和list的插入效率

时间:2015-02-04 18:58:35      阅读:255      评论:0      收藏:0      [点我收藏+]
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万时就效率好慢。







测试Map,和list的插入效率

原文:http://my.oschina.net/kelvinline/blog/375404

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!