From e0fb1c5c37a5728cc2deb3a98df0c2bf3f1cd109 Mon Sep 17 00:00:00 2001 From: Dhruv Matani Date: Mon, 12 Apr 2004 16:11:21 +0000 Subject: [PATCH] list_sort_search.cc: Minor formatting fixes. 2004-04-12 Dhruv Matani * testsuite/performance/20_util/allocator/list_sort_search.cc: Minor formatting fixes. * testsuite/performance/20_util/allocator/map_mt_find.cc: Likewise. From-SVN: r80624 --- libstdc++-v3/ChangeLog | 7 ++ .../20_util/allocator/list_sort_search.cc | 116 +++++++++--------- .../performance/20_util/allocator/map_mt_find.cc | 132 ++++++++++----------- 3 files changed, 129 insertions(+), 126 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9e545ce..67bff0f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2004-04-12 Dhruv Matani + + * testsuite/performance/20_util/allocator/list_sort_search.cc: + Minor formatting fixes. + * testsuite/performance/20_util/allocator/map_mt_find.cc: + Likewise. + 2004-04-12 Paolo Carlini * config/locale/gnu/numeric_members.cc diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/list_sort_search.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/list_sort_search.cc index 317a615..09d1821 100644 --- a/libstdc++-v3/testsuite/performance/20_util/allocator/list_sort_search.cc +++ b/libstdc++-v3/testsuite/performance/20_util/allocator/list_sort_search.cc @@ -27,6 +27,10 @@ // 2004-03-11 Dhruv Matani +#include +#include +#include +#include #include #include #include @@ -38,76 +42,72 @@ using namespace std; using __gnu_cxx::malloc_allocator; +using __gnu_cxx::new_allocator; using __gnu_cxx::__mt_alloc; using __gnu_cxx::bitmap_allocator; using __gnu_cxx::__pool_alloc; typedef int test_type; -using namespace __gnu_cxx; - -#include -#include -#include -#include -using namespace std; - template -int Test_Allocator () -{ - typedef list My_List; - My_List il1; - - int const Iter = 150000; - - int ctr = 3; - while (ctr--) - { - for (int i = 0; i < Iter; ++i) - il1.push_back (rand()%500001); - - //Search for random values that may or may not belong to the list. - for (int i = 0; i < 50; ++i) - std::find (il1.begin(), il1.end(), rand()%100001); + int + Test_Allocator() + { + typedef list My_List; + My_List il1; + int const Iter = 150000; + + int ctr = 3; + while (ctr--) + { + for (int i = 0; i < Iter; ++i) + il1.push_back(rand()%500001); + + //Search for random values that may or may not belong to the list. + for (int i = 0; i < 50; ++i) + std::find(il1.begin(), il1.end(), rand() % 100001); - il1.sort (); + il1.sort(); - //Search for random values that may or may not belong to the list. - for (int i = 0; i < 50; ++i) - { - typename My_List::iterator _liter = std::find (il1.begin(), il1.end(), rand()%100001); - if (_liter != il1.end()) - il1.erase (_liter); - } + //Search for random values that may or may not belong to the list. + for (int i = 0; i < 50; ++i) + { + typename My_List::iterator _liter = std::find(il1.begin(), + il1.end(), + rand() % 100001); + if (_liter != il1.end()) + il1.erase(_liter); + } - il1.clear (); - } - return Iter; -} + il1.clear(); + } + return Iter; + } template -void do_test () -{ - using namespace __gnu_test; - int status; - Alloc obj; - - time_counter time; - resource_counter resource; - clear_counters(time, resource); - start_counters(time, resource); - int test_iterations = Test_Allocator(); - stop_counters(time, resource); + void + do_test() + { + using namespace __gnu_test; + int status; + Alloc obj; + + time_counter time; + resource_counter resource; + clear_counters(time, resource); + start_counters(time, resource); + int test_iterations = Test_Allocator(); + stop_counters(time, resource); - std::ostringstream comment; - comment << "iterations: " << test_iterations < >(); @@ -125,5 +125,3 @@ int main () do_test<__pool_alloc >(); #endif } - - diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/map_mt_find.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/map_mt_find.cc index 2ee20f2..415f322 100644 --- a/libstdc++-v3/testsuite/performance/20_util/allocator/map_mt_find.cc +++ b/libstdc++-v3/testsuite/performance/20_util/allocator/map_mt_find.cc @@ -32,7 +32,6 @@ #include #include #include - #include #include #include @@ -44,17 +43,14 @@ using namespace std; using __gnu_cxx::malloc_allocator; +using __gnu_cxx::new_allocator; using __gnu_cxx::__mt_alloc; using __gnu_cxx::bitmap_allocator; using __gnu_cxx::__pool_alloc; typedef int test_type; -using namespace __gnu_cxx; -using namespace std; - -bool less_int (int x1, int x2) { return x1 -void *find_proc (void *_vptr) -{ - map *_mptr = - reinterpret_cast*>(_vptr); - - for (int i = 0; i < 700000; ++i) - { - int Finder = rand() % 2000000; - _mptr->find (Finder); - } - return _vptr; -} + void* + find_proc(void *_vptr) + { + map *_mptr = + reinterpret_cast*>(_vptr); + + for (int i = 0; i < 700000; ++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; -} + 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); + 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 <