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
This commit is contained in:
Loren J. Rittle 2004-02-06 08:12:38 +00:00
parent 07711f53ae
commit 093b46f04f
5 changed files with 117 additions and 72 deletions

View File

@ -31,7 +31,7 @@ SH_FLAG="-Wl,--rpath -Wl,$BUILD_DIR/../../gcc \
-Wl,--rpath -Wl,$BUILD_DIR/src/.libs" -Wl,--rpath -Wl,$BUILD_DIR/src/.libs"
ST_FLAG="-static" ST_FLAG="-static"
LINK=$SH_FLAG LINK=$SH_FLAG
CXX="$COMPILER $INCLUDES $FLAGS $LINK" CXX="$COMPILER $INCLUDES $FLAGS -DNOTHREAD $LINK"
CXX_THREAD="$COMPILER $INCLUDES $FLAGS $THREAD_FLAG $LINK" CXX_THREAD="$COMPILER $INCLUDES $FLAGS $THREAD_FLAG $LINK"

View File

@ -51,7 +51,7 @@ using namespace std;
typedef int test_type; typedef int test_type;
// The number of iterations to be performed. // 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 // 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) // (re)allocations to be performed (sizes 4, 8, 16, 32 and 64)
@ -71,30 +71,30 @@ template<typename TestType>
}; };
template<typename Container> template<typename Container>
int void
do_loop(Container& obj) do_loop()
{ {
Container obj;
int test_iterations = 0; int test_iterations = 0;
try value_type<test_type> test_value;
while (test_iterations < iterations)
{ {
value_type<test_type> test_value; for (int j = 0; j < insert_values; ++j)
while (test_iterations < iterations) obj.insert(obj.end(), ++test_value);
{ ++test_iterations;
for (int j = 0; j < insert_values; ++j)
obj.insert(obj.end(), ++test_value);
++test_iterations;
}
} }
catch(...) }
{
// No point allocating all available memory, repeatedly. template<typename Container>
} void*
return test_iterations; do_test(void* p = NULL)
{
do_loop<Container>();
} }
template<typename Container> template<typename Container>
void void
test_container(Container obj) test_container(Container obj, bool run_threaded = false)
{ {
using namespace __gnu_test; using namespace __gnu_test;
int status; int status;
@ -103,11 +103,36 @@ template<typename Container>
resource_counter resource; resource_counter resource;
clear_counters(time, resource); clear_counters(time, resource);
start_counters(time, resource); start_counters(time, resource);
int test_iterations = do_loop(obj);
if (! run_threaded)
{
do_loop<Container>();
}
else
{
#if defined (_GLIBCXX_GCC_GTHR_POSIX_H) && !defined (NOTHREAD)
pthread_t t1, t2, t3, t4;
pthread_create(&t1, 0, &do_test<Container>, 0);
pthread_create(&t2, 0, &do_test<Container>, 0);
pthread_create(&t3, 0, &do_test<Container>, 0);
pthread_create(&t4, 0, &do_test<Container>, 0);
pthread_join(t1, NULL);
pthread_join(t2, NULL);
pthread_join(t3, NULL);
pthread_join(t4, NULL);
#else
return;
#endif
}
stop_counters(time, resource); stop_counters(time, resource);
std::ostringstream comment; 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(), comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
0, 0, &status); 0, 0, &status);
report_header(__FILE__, comment.str()); report_header(__FILE__, comment.str());
@ -154,30 +179,75 @@ int main(void)
typedef less<test_type> compare_type; typedef less<test_type> compare_type;
#ifdef TEST_B9 #ifdef TEST_B9
iterations = 50000;
test_container(map<test_type, test_type, compare_type, m_alloc_type>()); test_container(map<test_type, test_type, compare_type, m_alloc_type>());
#endif #endif
#ifdef TEST_B10 #ifdef TEST_B10
iterations = 50000;
test_container(map<test_type, test_type, compare_type, n_alloc_type>()); test_container(map<test_type, test_type, compare_type, n_alloc_type>());
#endif #endif
#ifdef TEST_B11 #ifdef TEST_B11
iterations = 50000;
test_container(map<test_type, test_type, compare_type, so_alloc_type>()); test_container(map<test_type, test_type, compare_type, so_alloc_type>());
#endif #endif
#ifdef TEST_B12 #ifdef TEST_B12
iterations = 50000;
test_container(set<test_type, compare_type, m_alloc_type>()); test_container(set<test_type, compare_type, m_alloc_type>());
#endif #endif
#ifdef TEST_B13 #ifdef TEST_B13
iterations = 50000;
test_container(set<test_type, compare_type, n_alloc_type>()); test_container(set<test_type, compare_type, n_alloc_type>());
#endif #endif
#ifdef TEST_B14 #ifdef TEST_B14
iterations = 50000;
test_container(set<test_type, compare_type, so_alloc_type>()); test_container(set<test_type, compare_type, so_alloc_type>());
#endif #endif
#ifdef TEST_T0
test_container(vector<test_type, m_alloc_type>(), true);
#endif
#ifdef TEST_T1
test_container(vector<test_type, n_alloc_type>(), true);
#endif
#ifdef TEST_T2
test_container(vector<test_type, so_alloc_type>(), true);
#endif
#ifdef TEST_T3
test_container(list<test_type, m_alloc_type>(), true);
#endif
#ifdef TEST_T4
test_container(list<test_type, n_alloc_type>(), true);
#endif
#ifdef TEST_T5
test_container(list<test_type, so_alloc_type>(), true);
#endif
#ifdef TEST_T6
test_container(deque<test_type, m_alloc_type>(), true);
#endif
#ifdef TEST_T7
test_container(deque<test_type, n_alloc_type>(), true);
#endif
#ifdef TEST_T8
test_container(deque<test_type, so_alloc_type>(), true);
#endif
typedef less<test_type> compare_type;
#ifdef TEST_T9
test_container(map<test_type, test_type, compare_type, m_alloc_type>(), true);
#endif
#ifdef TEST_T10
test_container(map<test_type, test_type, compare_type, n_alloc_type>(), true);
#endif
#ifdef TEST_T11
test_container(map<test_type, test_type, compare_type, so_alloc_type>(), true);
#endif
#ifdef TEST_T12
test_container(set<test_type, compare_type, m_alloc_type>(), true);
#endif
#ifdef TEST_T13
test_container(set<test_type, compare_type, n_alloc_type>(), true);
#endif
#ifdef TEST_T14
test_container(set<test_type, compare_type, so_alloc_type>(), true);
#endif
return 0; return 0;
} }

View File

@ -40,7 +40,6 @@
#include <set> #include <set>
#include <typeinfo> #include <typeinfo>
#include <sstream> #include <sstream>
#include <pthread.h>
#include <ext/mt_allocator.h> #include <ext/mt_allocator.h>
#include <ext/new_allocator.h> #include <ext/new_allocator.h>
#include <ext/malloc_allocator.h> #include <ext/malloc_allocator.h>
@ -52,7 +51,7 @@ using namespace std;
typedef int test_type; typedef int test_type;
// The number of iterations to be performed. // 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 // 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) // (re)allocations to be performed (sizes 4, 8, 16, 32 and 64)
@ -86,21 +85,6 @@ template<typename Container>
} }
} }
template<typename Container>
void*
do_test(void* p = NULL)
{
try
{
do_loop<Container>();
do_loop<Container>();
}
catch(...)
{
// No point allocating all available memory, repeatedly.
}
}
template<typename Container> template<typename Container>
void void
test_container(Container obj) test_container(Container obj)
@ -110,25 +94,16 @@ template<typename Container>
time_counter time; time_counter time;
resource_counter resource; resource_counter resource;
clear_counters(time, resource); clear_counters(time, resource);
start_counters(time, resource); start_counters(time, resource);
pthread_t t1, t2, t3, t4;
pthread_create(&t1, 0, &do_test<Container>, 0);
pthread_create(&t2, 0, &do_test<Container>, 0);
pthread_create(&t3, 0, &do_test<Container>, 0);
pthread_create(&t4, 0, &do_test<Container>, 0);
pthread_join(t1, NULL); do_loop<Container>();
pthread_join(t2, NULL); do_loop<Container>();
pthread_join(t3, NULL);
pthread_join(t4, NULL);
stop_counters(time, resource); stop_counters(time, resource);
std::ostringstream comment; std::ostringstream comment;
comment << "iterations: " << iterations << '\t'; comment << "repeated iterations: " << iterations*2 << '\t';
comment << "type: " << abi::__cxa_demangle(typeid(obj).name(), comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
0, 0, &status); 0, 0, &status);
report_header(__FILE__, comment.str()); report_header(__FILE__, comment.str());
@ -143,54 +118,54 @@ int main(void)
typedef __gnu_cxx::new_allocator<test_type> n_alloc_type; typedef __gnu_cxx::new_allocator<test_type> n_alloc_type;
typedef __gnu_cxx::__mt_alloc<test_type> so_alloc_type; typedef __gnu_cxx::__mt_alloc<test_type> so_alloc_type;
#ifdef TEST_T0 #ifdef TEST_S0
test_container(vector<test_type, m_alloc_type>()); test_container(vector<test_type, m_alloc_type>());
#endif #endif
#ifdef TEST_T1 #ifdef TEST_S1
test_container(vector<test_type, n_alloc_type>()); test_container(vector<test_type, n_alloc_type>());
#endif #endif
#ifdef TEST_T2 #ifdef TEST_S2
test_container(vector<test_type, so_alloc_type>()); test_container(vector<test_type, so_alloc_type>());
#endif #endif
#ifdef TEST_T3 #ifdef TEST_S3
test_container(list<test_type, m_alloc_type>()); test_container(list<test_type, m_alloc_type>());
#endif #endif
#ifdef TEST_T4 #ifdef TEST_S4
test_container(list<test_type, n_alloc_type>()); test_container(list<test_type, n_alloc_type>());
#endif #endif
#ifdef TEST_T5 #ifdef TEST_S5
test_container(list<test_type, so_alloc_type>()); test_container(list<test_type, so_alloc_type>());
#endif #endif
#ifdef TEST_T6 #ifdef TEST_S6
test_container(deque<test_type, m_alloc_type>()); test_container(deque<test_type, m_alloc_type>());
#endif #endif
#ifdef TEST_T7 #ifdef TEST_S7
test_container(deque<test_type, n_alloc_type>()); test_container(deque<test_type, n_alloc_type>());
#endif #endif
#ifdef TEST_T8 #ifdef TEST_S8
test_container(deque<test_type, so_alloc_type>()); test_container(deque<test_type, so_alloc_type>());
#endif #endif
typedef less<test_type> compare_type; typedef less<test_type> compare_type;
#ifdef TEST_T9 #ifdef TEST_S9
test_container(map<test_type, test_type, compare_type, m_alloc_type>()); test_container(map<test_type, test_type, compare_type, m_alloc_type>());
#endif #endif
#ifdef TEST_T10 #ifdef TEST_S10
test_container(map<test_type, test_type, compare_type, n_alloc_type>()); test_container(map<test_type, test_type, compare_type, n_alloc_type>());
#endif #endif
#ifdef TEST_T11 #ifdef TEST_S11
test_container(map<test_type, test_type, compare_type, so_alloc_type>()); test_container(map<test_type, test_type, compare_type, so_alloc_type>());
#endif #endif
#ifdef TEST_T12 #ifdef TEST_S12
test_container(set<test_type, compare_type, m_alloc_type>()); test_container(set<test_type, compare_type, m_alloc_type>());
#endif #endif
#ifdef TEST_T13 #ifdef TEST_S13
test_container(set<test_type, compare_type, n_alloc_type>()); test_container(set<test_type, compare_type, n_alloc_type>());
#endif #endif
#ifdef TEST_T14 #ifdef TEST_S14
test_container(set<test_type, compare_type, so_alloc_type>()); test_container(set<test_type, compare_type, so_alloc_type>());
#endif #endif

View File

@ -49,7 +49,7 @@ using __gnu_cxx::new_allocator;
using __gnu_cxx::malloc_allocator; using __gnu_cxx::malloc_allocator;
// The number of iterations to be performed. // The number of iterations to be performed.
int iterations = 25000; int iterations = 10000;
template<typename Container> template<typename Container>
void* void*

View File

@ -58,7 +58,7 @@ typedef new_allocator<test_type> new_alloc_type;
typedef __mt_alloc<test_type> so_alloc_type; typedef __mt_alloc<test_type> so_alloc_type;
// The number of iterations to be performed. // The number of iterations to be performed.
int iterations = 25000; int iterations = 10000;
// TODO - restore Stefan's comment? i don't understand it. -- fwy // TODO - restore Stefan's comment? i don't understand it. -- fwy
int insert_values = 128; int insert_values = 128;