当前位置:网站首页>[原创]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
、
边栏推荐
- MySQL log articles, binlog log of MySQL log, detailed explanation of binlog log
- 7.16 Day22---MYSQL(Dao模式封装JDBC)
- JS基础--强制类型转换(易错点,自用)
- Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
- 动态规划总括
- CentOS7 - yum install mysql
- 3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
- 字节最爱问的智力题,你会几道?
- Resolved error: npm WARN config global `--global`, `--local` are deprecated
- Unity自动生成阻挡Collider的GameObject工具
猜你喜欢

Get the selected content of the radio box

Typora 使用保姆级教程 | 看这一篇就够了 | 历史版本已被禁用

Unity Visual Effect Graph入门与实践

少年成就黑客,需要这些技能

【论文阅读笔记】无监督行人重识别中的采样策略
![[Cocos 3.5.2]开启模型合批](/img/d9/9e8f71c9a26c8052b11291fe3ba7ac.png)
[Cocos 3.5.2]开启模型合批

OpenSSF 安全计划:SBOM 将驱动软件供应链安全

败给“MySQL”的第60天,我重振旗鼓,四面拿下蚂蚁金服offer

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

一个对象引用的思考
随机推荐
音视频相关基础知识与FFmpeg介绍
warning C4251: “std::vector<_Ty>”需要有 dll 接口由 class“Test”的客户端使用错误
Dynamic programming of the division of numbers
MySQL日期函数
7.18 Day23 - the markup language
7.16 Day22---MYSQL(Dao模式封装JDBC)
FFmpeg源码分析:avformat_open_input
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.2 Why does my code not work
EventBus源码分析
MySQL date functions
8.03 Day34---BaseMapper query statement usage
C1认证之web基础知识及习题——我的学习笔记
【问题解决】同一机器上Flask部署TensorRT报错记录
FPGA学习笔记——知识点总结
7.13 Day20----MYSQL
力扣:509. 斐波那契数
3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
解决安装nbextensions后使用Jupyter Notebook时出现template_paths相关错误的问题
SLSA 框架与软件供应链安全防护
(Kettle) pdi-ce-8.2 连接MySQL8.x数据库时驱动问题之终极探讨及解决方法分析