#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using __gnu_cxx::malloc_allocator; using __gnu_cxx::__mt_alloc; using __gnu_cxx::bitmap_allocator; using __gnu_cxx::mt_bitmap_allocator; typedef int test_type; using namespace __gnu_cxx; using namespace std; bool less_int (int x1, int x2) { return x1 #define COMPARE_F std::less() #endif template void *find_proc (void *_vptr) { map *_mptr = reinterpret_cast*>(_vptr); for (int i = 0; i < 1000000; ++i) { int Finder = rand() % 2000000; _mptr->find (Finder); } return _vptr; } template int do_test () { COMPARE_T _comp = COMPARE_F; map imap (_comp); int x = 2; pthread_t thr[3]; const int Iter = 1000000; while (x--) { for (int i = 0; i < 300000; ++i) imap.insert (make_pair (rand()%1000000, "_test_data")); for (int i = 0; i < 100000; ++i) imap.insert (make_pair (rand()%2000000, "_test_data")); pthread_create (&thr[0], NULL, find_proc, (void*)&imap); pthread_create (&thr[1], NULL, find_proc, (void*)&imap); pthread_create (&thr[2], NULL, find_proc, (void*)&imap); pthread_join (thr[0], 0); pthread_join (thr[1], 0); pthread_join (thr[2], 0); imap.clear (); } return Iter; } template void exec_tests () { using namespace __gnu_test; int status; COMPARE_T _comp = COMPARE_F; map obj (_comp); time_counter time; resource_counter resource; clear_counters(time, resource); start_counters(time, resource); int test_iterations = do_test(); stop_counters(time, resource); std::ostringstream comment; comment << "iterations: " << test_iterations < >(); exec_tests >(); exec_tests >(); bitmap_allocator::clear(); exec_tests >(); mt_bitmap_allocator::clear(); exec_tests<__mt_alloc >(); }