Linux Slab分配器(一)--概述
C++庫研究筆記——記憶體池實現
做了一些測試:發現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