各类 C++ hashmap 性能测试总结


各类 C++ hashmap 性能测试总结
关于 C++ hashmap,有非常多的各种实现。如 boost 和 google 的hashmap实现。C++ 11版本也提供了自己的 hashmap实现。
本文对比了各类实现的性能。主要是插入数据和查找数据两类。
hashmap的key 和 value 均使用 int. 也就是 map<int, int>的形式。
经过对比,插入 1000万次和查找1万次,各种实现的性能如下图。
如上图所示。插入需要的时间大致在 1~4秒之间。查询所需要的时间比较少。(红圈部分为插入 1000万条记录需要的时间,绿圈部分是查找1万次需要的时间)
对比各类实现的性能,boost::unordered_map 在综合性能上比较好。
google::dense_hash_map在内存占用上非常出色。查找速度极快。插入速度比boost::unordered_map慢。
至于 Visual Studio 2010 自带的std::map和std::hash_map的实现,只能用惨不忍睹来形容。
【备注】
测试环境:
CPU: Duo T6600
Memory: 4GB
软件版本:
Visual Studio 2010
boost 1.48.0
google sparsehash 1.11
 
阅读(950) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~
评论热议
原文地址:https://www.cnblogs.com/black/p/5171643.html