- 935 名前:デフォルトの名無しさん [2007/12/26(水) 21:46:08 ]
- 質問なんですが、標準のnewって本当にそんなに遅いのでしょうか?
下のようにpoolを作ってnewの実行時間と比較してみたのですが差が出ません #include <boost/pool/pool.hpp> #include <boost/pool/object_pool.hpp> #include <iostream> #include <time.h> using namespace std; struct Abc{ int x; int y;}; int main(){ clock_t start1,end1,start2,end2 ; boost::object_pool<Abc> p; start1 = clock() ; for( int i = 0 ; i < 0xffffff ; ++i ) { Abc* x = p.construct(); } end1 = clock() ; printf("%.10f\n",(end1-start1)/CLOCKS_PER_SEC ) ; start2 = clock() ; for( int i = 0 ; i < 0xffffff ; ++i ) { Abc* x = new Abc(); } end2 = clock() ; printf("%.10f\n",(end2-start2)/CLOCKS_PER_SEC ) ; return 0;}
|

|