当前位置:网站首页>[原创]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
、
边栏推荐
猜你喜欢
随机推荐
The symbol table
Canal mysql data synchronization
MySQL日志篇,MySQL日志之binlog日志,binlog日志详解
符号表
Cannot read properties of null (reading ‘insertBefore‘)
Towards Real-Time Multi-Object Tracking (JDE)
TensorRT例程解读之语义分割demo
嵌入式系统驱动初级【3】——字符设备驱动基础中_IO模型
力扣:96.不同的二叉搜索树
7.15 Day21---MySQL----Index
7.16 Day22---MYSQL(Dao模式封装JDBC)
部署LVS-DR群集【实验】
想好了吗?
canal实现mysql数据同步
MySql data recovery method personal summary
腾讯136道高级岗面试题:多线程+算法+Redis+JVM
day13--postman interface test
Several ways to heavy
编程大杂烩(三)
OpenCV获取和设置图像的平均亮度









