This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] performance/allocator, allocator_thread additions
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org, fwy at alumni dot brown dot edu
- Date: Wed, 4 Feb 2004 00:20:36 -0600
- Subject: [v3] performance/allocator, allocator_thread additions
Add map, set, deque.
tested x86/linux
-benjamin
2004-02-03 Felix Yen <fwy@alumni.brown.edu>
Benjamin Kosnik <bkoz@redhat.com>
* testsuite/performance/20_util/allocator.cc: Add map,
deque, set tests.
* testsuite/performance/20_util/allocator_thread.cc: Same.
Index: testsuite/performance/20_util/allocator.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/performance/20_util/allocator.cc,v
retrieving revision 1.1
diff -c -p -r1.1 allocator.cc
*** testsuite/performance/20_util/allocator.cc 30 Jan 2004 17:04:37 -0000 1.1
--- testsuite/performance/20_util/allocator.cc 4 Feb 2004 06:19:00 -0000
***************
*** 35,40 ****
--- 35,43 ----
#include <vector>
#include <list>
+ #include <map>
+ #include <deque>
+ #include <set>
#include <typeinfo>
#include <sstream>
#include <ext/mt_allocator.h>
***************
*** 44,52 ****
#include <testsuite_performance.h>
using namespace std;
- using __gnu_cxx::__mt_alloc;
- using __gnu_cxx::new_allocator;
- using __gnu_cxx::malloc_allocator;
typedef int test_type;
--- 47,52 ----
*************** int iterations = 100000;
*** 61,78 ****
// should probably be investigated in more detail.
int insert_values = 128;
template<typename Container>
int
! do_loop()
{
int test_iterations = 0;
try
{
! Container obj;
while (test_iterations < iterations)
{
for (int j = 0; j < insert_values; ++j)
! obj.push_back(test_iterations);
++test_iterations;
}
}
--- 61,87 ----
// should probably be investigated in more detail.
int insert_values = 128;
+ template<typename TestType>
+ struct value_type : public pair<TestType, TestType>
+ {
+ value_type() : pair<TestType, TestType>(0, 0) { }
+
+ inline value_type operator++() { return ++this->first, *this; }
+ inline operator TestType() const { return this->first; }
+ };
+
template<typename Container>
int
! do_loop(Container& obj)
{
int test_iterations = 0;
try
{
! value_type<test_type> test_value;
while (test_iterations < iterations)
{
for (int j = 0; j < insert_values; ++j)
! obj.insert(obj.end(), ++test_value);
++test_iterations;
}
}
*************** template<typename Container>
*** 94,100 ****
resource_counter resource;
clear_counters(time, resource);
start_counters(time, resource);
! int test_iterations = do_loop<Container>();
stop_counters(time, resource);
std::ostringstream comment;
--- 103,109 ----
resource_counter resource;
clear_counters(time, resource);
start_counters(time, resource);
! int test_iterations = do_loop(obj);
stop_counters(time, resource);
std::ostringstream comment;
*************** template<typename Container>
*** 109,138 ****
// http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html
int main(void)
{
#ifdef TEST_B1
! test_container(vector<test_type>());
#endif
#ifdef TEST_B2
! test_container(vector<test_type, malloc_allocator<test_type> >());
#endif
#ifdef TEST_B3
! test_container(vector<test_type, new_allocator<test_type> >());
#endif
#ifdef TEST_B4
! test_container(vector<test_type, __mt_alloc<test_type> >());
#endif
-
#ifdef TEST_B5
! test_container(list<test_type>());
#endif
#ifdef TEST_B6
! test_container(list<test_type, malloc_allocator<test_type> >());
#endif
#ifdef TEST_B7
! test_container(list<test_type, new_allocator<test_type> >());
#endif
#ifdef TEST_B8
! test_container(list<test_type, __mt_alloc<test_type> >());
#endif
return 0;
--- 118,176 ----
// http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html
int main(void)
{
+ typedef __gnu_cxx::malloc_allocator<test_type> m_alloc_type;
+ typedef __gnu_cxx::new_allocator<test_type> n_alloc_type;
+ typedef __gnu_cxx::__mt_alloc<test_type> so_alloc_type;
+
+ #ifdef TEST_B0
+ test_container(vector<test_type, m_alloc_type>());
+ #endif
#ifdef TEST_B1
! test_container(vector<test_type, n_alloc_type>());
#endif
#ifdef TEST_B2
! test_container(vector<test_type, so_alloc_type>());
#endif
+
#ifdef TEST_B3
! test_container(list<test_type, m_alloc_type>());
#endif
#ifdef TEST_B4
! test_container(list<test_type, n_alloc_type>());
#endif
#ifdef TEST_B5
! test_container(list<test_type, so_alloc_type>());
#endif
+
#ifdef TEST_B6
! test_container(deque<test_type, m_alloc_type>());
#endif
#ifdef TEST_B7
! test_container(deque<test_type, n_alloc_type>());
#endif
#ifdef TEST_B8
! test_container(deque<test_type, so_alloc_type>());
! #endif
!
! typedef less<test_type> compare_type;
! #ifdef TEST_B9
! test_container(map<test_type, test_type, compare_type, m_alloc_type>());
! #endif
! #ifdef TEST_B10
! test_container(map<test_type, test_type, compare_type, n_alloc_type>());
! #endif
! #ifdef TEST_B11
! test_container(map<test_type, test_type, compare_type, so_alloc_type>());
! #endif
!
! #ifdef TEST_B12
! test_container(set<test_type, compare_type, m_alloc_type>());
! #endif
! #ifdef TEST_B13
! test_container(set<test_type, compare_type, n_alloc_type>());
! #endif
! #ifdef TEST_B14
! test_container(set<test_type, compare_type, so_alloc_type>());
#endif
return 0;
Index: testsuite/performance/20_util/allocator_thread.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/performance/20_util/allocator_thread.cc,v
retrieving revision 1.2
diff -c -p -r1.2 allocator_thread.cc
*** testsuite/performance/20_util/allocator_thread.cc 30 Jan 2004 18:14:42 -0000 1.2
--- testsuite/performance/20_util/allocator_thread.cc 4 Feb 2004 06:19:00 -0000
***************
*** 35,40 ****
--- 35,43 ----
#include <vector>
#include <list>
+ #include <map>
+ #include <deque>
+ #include <set>
#include <typeinfo>
#include <sstream>
#include <pthread.h>
***************
*** 45,53 ****
#include <testsuite_performance.h>
using namespace std;
- using __gnu_cxx::__mt_alloc;
- using __gnu_cxx::new_allocator;
- using __gnu_cxx::malloc_allocator;
typedef int test_type;
--- 48,53 ----
*************** int iterations = 25000;
*** 62,67 ****
--- 62,76 ----
// should probably be investigated in more detail.
int insert_values = 128;
+ template<typename TestType>
+ struct value_type : public pair<TestType, TestType>
+ {
+ value_type() : pair<TestType, TestType>(0, 0) { }
+
+ inline value_type operator++() { return ++this->first, *this; }
+ inline operator TestType() const { return this->first; }
+ };
+
template<typename Container>
void*
do_loop(void* p = NULL)
*************** template<typename Container>
*** 70,88 ****
try
{
int test_iterations = 0;
while (test_iterations < iterations)
{
for (int j = 0; j < insert_values; ++j)
! obj.insert(obj.begin(), test_iterations);
++test_iterations;
}
// NB: Don't use clear() here, instead force deallocation.
obj = Container();
test_iterations = 0;
while (test_iterations < iterations)
{
for (int j = 0; j < insert_values; ++j)
! obj.insert(obj.begin(), test_iterations);
++test_iterations;
}
}
--- 79,99 ----
try
{
int test_iterations = 0;
+ value_type<test_type> test_value;
while (test_iterations < iterations)
{
for (int j = 0; j < insert_values; ++j)
! obj.insert(obj.end(), ++test_value);
++test_iterations;
}
// NB: Don't use clear() here, instead force deallocation.
obj = Container();
test_iterations = 0;
+ test_value = value_type<test_type>();
while (test_iterations < iterations)
{
for (int j = 0; j < insert_values; ++j)
! obj.insert(obj.end(), ++test_value);
++test_iterations;
}
}
*************** template<typename Container>
*** 130,159 ****
// http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html
int main(void)
{
#ifdef TEST_T1
! test_container(vector<test_type>());
#endif
#ifdef TEST_T2
! test_container(vector<test_type, malloc_allocator<test_type> >());
#endif
#ifdef TEST_T3
! test_container(vector<test_type, new_allocator<test_type> >());
#endif
#ifdef TEST_T4
! test_container(vector<test_type, __mt_alloc<test_type> >());
#endif
-
#ifdef TEST_T5
! test_container(list<test_type>());
#endif
#ifdef TEST_T6
! test_container(list<test_type, malloc_allocator<test_type> >());
#endif
#ifdef TEST_T7
! test_container(list<test_type, new_allocator<test_type> >());
#endif
#ifdef TEST_T8
! test_container(list<test_type, __mt_alloc<test_type> >());
#endif
return 0;
--- 141,199 ----
// http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html
int main(void)
{
+ typedef __gnu_cxx::malloc_allocator<test_type> m_alloc_type;
+ typedef __gnu_cxx::new_allocator<test_type> n_alloc_type;
+ typedef __gnu_cxx::__mt_alloc<test_type> so_alloc_type;
+
+ #ifdef TEST_T0
+ test_container(vector<test_type, m_alloc_type>());
+ #endif
#ifdef TEST_T1
! test_container(vector<test_type, n_alloc_type>());
#endif
#ifdef TEST_T2
! test_container(vector<test_type, so_alloc_type>());
#endif
+
#ifdef TEST_T3
! test_container(list<test_type, m_alloc_type>());
#endif
#ifdef TEST_T4
! test_container(list<test_type, n_alloc_type>());
#endif
#ifdef TEST_T5
! test_container(list<test_type, so_alloc_type>());
#endif
+
#ifdef TEST_T6
! test_container(deque<test_type, m_alloc_type>());
#endif
#ifdef TEST_T7
! test_container(deque<test_type, n_alloc_type>());
#endif
#ifdef TEST_T8
! test_container(deque<test_type, so_alloc_type>());
! #endif
!
! typedef less<test_type> compare_type;
! #ifdef TEST_T9
! test_container(map<test_type, test_type, compare_type, m_alloc_type>());
! #endif
! #ifdef TEST_T10
! test_container(map<test_type, test_type, compare_type, n_alloc_type>());
! #endif
! #ifdef TEST_T11
! test_container(map<test_type, test_type, compare_type, so_alloc_type>());
! #endif
!
! #ifdef TEST_T12
! test_container(set<test_type, compare_type, m_alloc_type>());
! #endif
! #ifdef TEST_T13
! test_container(set<test_type, compare_type, n_alloc_type>());
! #endif
! #ifdef TEST_T14
! test_container(set<test_type, compare_type, so_alloc_type>());
#endif
return 0;