//#define CLASS_LEVEL_THREADING //#define OBJECT_LEVEL_THREADING #include "SmallObj.h" #include "timer.h" #include using namespace std; class ThisIsASmallObject { int i; double d; //std::string s; }; template struct Base : public ThisIsASmallObject, public T {}; template<> struct Base : public ThisIsASmallObject {}; typedef Base A; typedef Base > B; typedef Base > C; /* class A { int i; int* p;}; class B : public Loki::SmallObject<> { int i; int* p;}; class C : public Loki::SmallValueObject<> { int i; int* p;}; */ template int run_new_delete(int loop, Timer& t, char* s) { t.start(); /****************************************************************/ for (int i=0; i int run_new_delete(T** array, int N, int loop, Timer& t, char* s) { t.start(); /****************************************************************/ for (int i=0; i int run_new(T** array, int loop, Timer& t, char* s) { t.start(); /****************************************************************/ for (int i=0; i int run_delete(T** array, int loop, Timer& t, char* s) { t.start(); /****************************************************************/ for (int i=0; i int run_new_delete_array(int N, int loop, Timer& t, char* s) { t.start(); /****************************************************************/ for (int i=0; i(loop,t,"new & delete A : "); run_new_delete(loop,t,"new & delete B : "); run_new_delete(loop,t,"new & delete C : "); cout << endl << endl; //////////////////////////////////////////////////////////////////////////////// int N = 100000; int loop2 = loop/N*10; A** a = new A*[N]; B** b = new B*[N]; C** c = new C*[N]; for(int i=0; i(N,loop,t,"new & delete [] A : "); run_new_delete_array(N,loop,t,"new & delete [] B : "); run_new_delete_array(N,loop,t,"new & delete [] C : "); cout << endl << endl; //////////////////////////////////////////////////////////////////////////////// cout << endl; system("PAUSE"); return 0; }