当前位置:编程学习 > C/C++ >>

C++库研究笔记——Linux下是否需要使用memory pool?

 
做了一些测试:发现linux使用内存池与否没有明显差别,仅仅有2倍。 Linux内存处理机制已经很好,一般情况下,确实没有必要在用内存池??? 不知道大家持什么样的观点。
 
 
速度测试:
In [use pool]:0.00560116768 seconds
In [ no pool]:0.00855708122 seconds
 
 
In [use pool]:0.00404405594 seconds
In [ no pool]:0.00921702385 seconds
 
 
In [use pool]:0.0060069561 seconds
In [ no pool]:0.0129909515 seconds
 
 
In [use pool]:0.00984287262 seconds
In [ no pool]:0.0179138184 seconds
 
 
In [use pool]:0.00937509537 seconds
In [ no pool]:0.0222010612 seconds
 
 
In [use pool]:0.0128059387 seconds
In [ no pool]:0.0269629955 seconds
 
 
In [use pool]:0.0170590878 seconds
In [ no pool]:0.0312800407 seconds
 
 
In [use pool]:0.0199379921 seconds
In [ no pool]:0.0355689526 seconds
 
 
In [use pool]:0.0220119953 seconds
In [ no pool]:0.0396490097 seconds
 
 
In [use pool]:0.0250389576 seconds
In [ no pool]:0.0438430309 seconds
 
 
02:36:16:~/../pool_test$ vim MainFile.cpp 
 
 
g++ MemPool.o TestClass.o MainFile.cpp -o main -O3
 
 
Press ENTER or type command to continue
02:37:21:~/../pool_test$ ./main 
In [use pool]:0.000194072723 seconds
In [ no pool]:0.000468015671 seconds
 
 
In [use pool]:0.000373125076 seconds
In [ no pool]:0.000900030136 seconds
 
 
In [use pool]:0.000594139099 seconds
In [ no pool]:0.00134897232 seconds
 
 
In [use pool]:0.000751018524 seconds
In [ no pool]:0.00190091133 seconds
 
 
In [use pool]:0.000940084457 seconds
In [ no pool]:0.0022559166 seconds
 
 
In [use pool]:0.00139307976 seconds
In [ no pool]:0.00420188904 seconds
 
 
In [use pool]:0.00148892403 seconds
In [ no pool]:0.00316882133 seconds
 
 
In [use pool]:0.00165891647 seconds
In [ no pool]:0.00361800194 seconds
 
 
In [use pool]:0.00178599358 seconds
In [ no pool]:0.00484013557 seconds
 
In [use pool]:0.0184268951 seconds
In [ no pool]:0.0416920185 seconds
 
 
In [use pool]:0.0186669827 seconds
In [ no pool]:0.043035984 seconds
 
 
In [use pool]:0.0192191601 seconds
In [ no pool]:0.0422170162 seconds
 
 
In [use pool]:0.0193469524 seconds
In [ no pool]:0.0423469543 seconds
 
 
In [use pool]:0.0193350315 seconds
In [ no pool]:0.0422008038 seconds
 
 
In [use pool]:0.0196199417 seconds
In [ no pool]:0.0431320667 seconds
 
 
In [use pool]:0.0197191238 seconds
In [ no pool]:0.0441551208 seconds
 
 
In [use pool]:0.0201468468 seconds
In [ no pool]:0.0435791016 seconds
 
补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,