From: Loren J. Rittle Date: Fri, 6 Feb 2004 08:12:38 +0000 (+0000) Subject: check_performance (CXX): Add -DNOTHREAD. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=093b46f04f98d723c5930c5bec7f3206e552dff4;p=platform%2Fupstream%2Fgcc.git check_performance (CXX): Add -DNOTHREAD. * scripts/check_performance (CXX): Add -DNOTHREAD. * testsuite/performance/20_util/allocator/insert.cc: Integrate threaded tests from insert_insert.cc. Tweak iterations, remove special cases. * testsuite/performance/20_util/allocator/insert_insert.cc: Make all tests single-threaded. Tweak iterations. * testsuite/performance/20_util/allocator/map_thread.cc: Tweak iterations. * testsuite/performance/20_util/allocator/producer_consumer.cc: Likewise. From-SVN: r77388 --- diff --git a/libstdc++-v3/scripts/check_performance b/libstdc++-v3/scripts/check_performance index 998f45d..090dae8 100755 --- a/libstdc++-v3/scripts/check_performance +++ b/libstdc++-v3/scripts/check_performance @@ -31,7 +31,7 @@ SH_FLAG="-Wl,--rpath -Wl,$BUILD_DIR/../../gcc \ -Wl,--rpath -Wl,$BUILD_DIR/src/.libs" ST_FLAG="-static" LINK=$SH_FLAG -CXX="$COMPILER $INCLUDES $FLAGS $LINK" +CXX="$COMPILER $INCLUDES $FLAGS -DNOTHREAD $LINK" CXX_THREAD="$COMPILER $INCLUDES $FLAGS $THREAD_FLAG $LINK" diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/insert.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/insert.cc index 15677d7..9c7975c 100644 --- a/libstdc++-v3/testsuite/performance/20_util/allocator/insert.cc +++ b/libstdc++-v3/testsuite/performance/20_util/allocator/insert.cc @@ -51,7 +51,7 @@ using namespace std; typedef int test_type; // The number of iterations to be performed. -int iterations = 100000; +int iterations = 10000; // The number of values to insert in the container, 32 will cause 5 // (re)allocations to be performed (sizes 4, 8, 16, 32 and 64) @@ -71,30 +71,30 @@ template }; template - int - do_loop(Container& obj) + void + do_loop() { + Container obj; int test_iterations = 0; - try - { - value_type test_value; - while (test_iterations < iterations) - { - for (int j = 0; j < insert_values; ++j) - obj.insert(obj.end(), ++test_value); - ++test_iterations; - } - } - catch(...) + value_type test_value; + while (test_iterations < iterations) { - // No point allocating all available memory, repeatedly. + for (int j = 0; j < insert_values; ++j) + obj.insert(obj.end(), ++test_value); + ++test_iterations; } - return test_iterations; + } + +template + void* + do_test(void* p = NULL) + { + do_loop(); } template void - test_container(Container obj) + test_container(Container obj, bool run_threaded = false) { using namespace __gnu_test; int status; @@ -103,11 +103,36 @@ template resource_counter resource; clear_counters(time, resource); start_counters(time, resource); - int test_iterations = do_loop(obj); + + if (! run_threaded) + { + do_loop(); + } + else + { +#if defined (_GLIBCXX_GCC_GTHR_POSIX_H) && !defined (NOTHREAD) + pthread_t t1, t2, t3, t4; + pthread_create(&t1, 0, &do_test, 0); + pthread_create(&t2, 0, &do_test, 0); + pthread_create(&t3, 0, &do_test, 0); + pthread_create(&t4, 0, &do_test, 0); + + pthread_join(t1, NULL); + pthread_join(t2, NULL); + pthread_join(t3, NULL); + pthread_join(t4, NULL); +#else + return; +#endif + } + stop_counters(time, resource); std::ostringstream comment; - comment << "iterations: " << test_iterations << '\t'; + if (run_threaded) + comment << "4-way threaded iterations: " << iterations*4 << '\t'; + else + comment << "iterations: " << iterations << '\t'; comment << "type: " << abi::__cxa_demangle(typeid(obj).name(), 0, 0, &status); report_header(__FILE__, comment.str()); @@ -154,30 +179,75 @@ int main(void) typedef less compare_type; #ifdef TEST_B9 - iterations = 50000; test_container(map()); #endif #ifdef TEST_B10 - iterations = 50000; test_container(map()); #endif #ifdef TEST_B11 - iterations = 50000; test_container(map()); #endif #ifdef TEST_B12 - iterations = 50000; test_container(set()); #endif #ifdef TEST_B13 - iterations = 50000; test_container(set()); #endif #ifdef TEST_B14 - iterations = 50000; test_container(set()); #endif +#ifdef TEST_T0 + test_container(vector(), true); +#endif +#ifdef TEST_T1 + test_container(vector(), true); +#endif +#ifdef TEST_T2 + test_container(vector(), true); +#endif + +#ifdef TEST_T3 + test_container(list(), true); +#endif +#ifdef TEST_T4 + test_container(list(), true); +#endif +#ifdef TEST_T5 + test_container(list(), true); +#endif + +#ifdef TEST_T6 + test_container(deque(), true); +#endif +#ifdef TEST_T7 + test_container(deque(), true); +#endif +#ifdef TEST_T8 + test_container(deque(), true); +#endif + + typedef less compare_type; +#ifdef TEST_T9 + test_container(map(), true); +#endif +#ifdef TEST_T10 + test_container(map(), true); +#endif +#ifdef TEST_T11 + test_container(map(), true); +#endif + +#ifdef TEST_T12 + test_container(set(), true); +#endif +#ifdef TEST_T13 + test_container(set(), true); +#endif +#ifdef TEST_T14 + test_container(set(), true); +#endif + return 0; } diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/insert_insert.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/insert_insert.cc index c5df36a..e0773f0 100644 --- a/libstdc++-v3/testsuite/performance/20_util/allocator/insert_insert.cc +++ b/libstdc++-v3/testsuite/performance/20_util/allocator/insert_insert.cc @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -52,7 +51,7 @@ using namespace std; typedef int test_type; // The number of iterations to be performed. -int iterations = 25000; +int iterations = 10000; // The number of values to insert in the container, 32 will cause 5 // (re)allocations to be performed (sizes 4, 8, 16, 32 and 64) @@ -87,21 +86,6 @@ template } template - void* - do_test(void* p = NULL) - { - try - { - do_loop(); - do_loop(); - } - catch(...) - { - // No point allocating all available memory, repeatedly. - } - } - -template void test_container(Container obj) { @@ -110,25 +94,16 @@ template time_counter time; resource_counter resource; - clear_counters(time, resource); start_counters(time, resource); - - pthread_t t1, t2, t3, t4; - pthread_create(&t1, 0, &do_test, 0); - pthread_create(&t2, 0, &do_test, 0); - pthread_create(&t3, 0, &do_test, 0); - pthread_create(&t4, 0, &do_test, 0); - - pthread_join(t1, NULL); - pthread_join(t2, NULL); - pthread_join(t3, NULL); - pthread_join(t4, NULL); + + do_loop(); + do_loop(); stop_counters(time, resource); std::ostringstream comment; - comment << "iterations: " << iterations << '\t'; + comment << "repeated iterations: " << iterations*2 << '\t'; comment << "type: " << abi::__cxa_demangle(typeid(obj).name(), 0, 0, &status); report_header(__FILE__, comment.str()); @@ -143,54 +118,54 @@ int main(void) typedef __gnu_cxx::new_allocator n_alloc_type; typedef __gnu_cxx::__mt_alloc so_alloc_type; -#ifdef TEST_T0 +#ifdef TEST_S0 test_container(vector()); #endif -#ifdef TEST_T1 +#ifdef TEST_S1 test_container(vector()); #endif -#ifdef TEST_T2 +#ifdef TEST_S2 test_container(vector()); #endif -#ifdef TEST_T3 +#ifdef TEST_S3 test_container(list()); #endif -#ifdef TEST_T4 +#ifdef TEST_S4 test_container(list()); #endif -#ifdef TEST_T5 +#ifdef TEST_S5 test_container(list()); #endif -#ifdef TEST_T6 +#ifdef TEST_S6 test_container(deque()); #endif -#ifdef TEST_T7 +#ifdef TEST_S7 test_container(deque()); #endif -#ifdef TEST_T8 +#ifdef TEST_S8 test_container(deque()); #endif typedef less compare_type; -#ifdef TEST_T9 +#ifdef TEST_S9 test_container(map()); #endif -#ifdef TEST_T10 +#ifdef TEST_S10 test_container(map()); #endif -#ifdef TEST_T11 +#ifdef TEST_S11 test_container(map()); #endif -#ifdef TEST_T12 +#ifdef TEST_S12 test_container(set()); #endif -#ifdef TEST_T13 +#ifdef TEST_S13 test_container(set()); #endif -#ifdef TEST_T14 +#ifdef TEST_S14 test_container(set()); #endif diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc index f6b4d45..abceafa 100644 --- a/libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc +++ b/libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc @@ -49,7 +49,7 @@ using __gnu_cxx::new_allocator; using __gnu_cxx::malloc_allocator; // The number of iterations to be performed. -int iterations = 25000; +int iterations = 10000; template void* diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc index c8d2f1d..951242e 100644 --- a/libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc +++ b/libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc @@ -58,7 +58,7 @@ typedef new_allocator new_alloc_type; typedef __mt_alloc so_alloc_type; // The number of iterations to be performed. -int iterations = 25000; +int iterations = 10000; // TODO - restore Stefan's comment? i don't understand it. -- fwy int insert_values = 128;