当前位置:网站首页>[原创]STL容器map和unordered_map性能,创建,插入,随机访问速度对比!
[原创]STL容器map和unordered_map性能,创建,插入,随机访问速度对比!
2022-08-04 05:25:00 【夜雨清狂】
测试map和unordered_map,采用1亿次随机访问,分别在数据量10~1000万不同情况测试,生成时间和随机访问时间;
平台:win10,vs2019,c++14,编译,启动优化
结论:
1、unordered_map在任何情况下都要比map的随机访问速度更快,5倍以上;
2、unordered_map在100万数据量以下要比map的随机插入速度快,如果单个保存的数据结构较大,这一速度会进一步降低;
3、unordered_map会比map占用更多的内存;
元素个数 | 访问次数 | map生成时间 | u_map生成时间 | map随机访问时间 | u_map随机访问时间
------- | -----
10 | 100000000 | 2.1e-06 | 6.5e-06 | 1.94613 |0.689562
100 | 100000000 | 2.25e-05 | 1.3e-05 | 3.36376 | 0.675164
1000 | 100000000 | 0.0001401 | 0.0001746 | 5.75473 | 1.0072
10000 | 100000000 | 0.0011706 | 0.0008734 | 9.50507 | 2.12198
100000 | 100000000 | 0.0124686 | 0.0086218 | 19.9218 | 1.99078
1000000 | 100000000 | 0.135445 | 0.223635 | 97.73 | 12.5941
10000000 | 100000000 | 1.5676 | 4.7092 | 201.582 | 14.4982
、
边栏推荐
- OpenRefine中的正则表达式
- 符号表
- 动态规划总括
- [Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
- Unity开发类似Profile那样的数据分析工具
- el-Select selector bottom fixed
- How to view sql execution plan offline collection
- Summary of MySQL database interview questions (2022 latest version)
- The cost of automated testing is high and the effect is poor, so what is the significance of automated testing?
- 7.16 Day22---MYSQL(Dao模式封装JDBC)
猜你喜欢

谷粒商城-基础篇(项目简介&项目搭建)

Unity表格配置编辑工具

3面头条,花7天整理了面试题和学习笔记,已正式入职半个月

npm报错Beginning October 4, 2021, all connections to the npm registry - including for package installa

想低成本保障软件安全?5大安全任务值得考虑
![[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection](/img/1a/b3bdf9b62c82b0fc4d913045981d94.png)
[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection

7.16 Day22---MYSQL(Dao模式封装JDBC)

MySQL日志篇,MySQL日志之binlog日志,binlog日志详解

DP4398:国产兼容替代CS4398立体声24位/192kHz音频解码芯片
![Embedded system driver primary [4] - under the basis of character device driver _ concurrency control](/img/96/5224d2de152eb738703cd201fb8407.png)
Embedded system driver primary [4] - under the basis of character device driver _ concurrency control
随机推荐
[Cocos] cc.sys.browserType可能的属性
Handling List
FLV格式详解
MySQL database (basic)
7.18 Day23 - the markup language
static在不同位置定义变量居然还有不同的含义?
4.3 Annotation-based declarative transactions and XML-based declarative transactions
如何低成本修bug?测试左移给你答案
Cannot read properties of null (reading ‘insertBefore‘)
Towards Real-Time Multi-Object Tracking (JDE)
梳理CamStyle、PTGAN、SPGAN、StarGAN
Unity动画生成工具
(Kettle) pdi-ce-8.2 连接MySQL8.x数据库时驱动问题之终极探讨及解决方法分析
How to view sql execution plan offline collection
力扣:63. 不同路径 II
去重的几种方式
Dynamic programming of the division of numbers
OpenGLES 学习之帧缓存
注意!软件供应链安全挑战持续升级
MySQL log articles, binlog log of MySQL log, detailed explanation of binlog log