当前位置:网站首页>[原创]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
、
边栏推荐
猜你喜欢
Delphi-C端有趣的菜单操作界面设计
The cost of automated testing is high and the effect is poor, so what is the significance of automated testing?
Web Basics and Exercises for C1 Certification - My Study Notes
7.15 Day21---MySQL----索引
代码重构:面向单元测试
Get the selected content of the radio box
The symbol table
7.16 Day22---MYSQL(Dao模式封装JDBC)
如何低成本修bug?测试左移给你答案
Can 't connect to MySQL server on' localhost3306 '(10061) simple solutions
随机推荐
Get the selected content of the radio box
npm报错Beginning October 4, 2021, all connections to the npm registry - including for package installa
3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
Dynamic programming of the division of numbers
npm init [email protected] 构建项目报错SyntaxError: Unexpected token ‘.‘解决办法
[One step in place] Jenkins installation, deployment, startup (complete tutorial)
TensorRTx-YOLOv5工程解读(一)
How to view sql execution plan offline collection
8. Custom mapping resultMap
static在不同位置定义变量居然还有不同的含义?
Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
9、动态SQL
warning C4251: “std::vector<_Ty>”需要有 dll 接口由 class“Test”的客户端使用错误
OpenRefine开源数据清洗软件的GREL语言
字节最爱问的智力题,你会几道?
The symbol table
Unity开发类似Profile那样的数据分析工具
MySQL date functions
部署LVS-DR群集【实验】
心余力绌:企业面临的软件供应链安全困境