Commit 22269632 by Felix Yen Committed by Benjamin Kosnik

allocator.cc: Add map, deque, set tests.


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.

Co-Authored-By: Benjamin Kosnik <bkoz@redhat.com>

From-SVN: r77225
parent a2a8cc44
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.
2004-02-03 Paolo Carlini <pcarlini@suse.de> 2004-02-03 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (insert(iterator)): Remove, * include/bits/basic_string.h (insert(iterator)): Remove,
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
#include <vector> #include <vector>
#include <list> #include <list>
#include <map>
#include <deque>
#include <set>
#include <typeinfo> #include <typeinfo>
#include <sstream> #include <sstream>
#include <ext/mt_allocator.h> #include <ext/mt_allocator.h>
...@@ -44,9 +47,6 @@ ...@@ -44,9 +47,6 @@
#include <testsuite_performance.h> #include <testsuite_performance.h>
using namespace std; using namespace std;
using __gnu_cxx::__mt_alloc;
using __gnu_cxx::new_allocator;
using __gnu_cxx::malloc_allocator;
typedef int test_type; typedef int test_type;
...@@ -61,18 +61,27 @@ int iterations = 100000; ...@@ -61,18 +61,27 @@ int iterations = 100000;
// should probably be investigated in more detail. // should probably be investigated in more detail.
int insert_values = 128; 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> template<typename Container>
int int
do_loop() do_loop(Container& obj)
{ {
int test_iterations = 0; int test_iterations = 0;
try try
{ {
Container obj; value_type<test_type> test_value;
while (test_iterations < iterations) while (test_iterations < iterations)
{ {
for (int j = 0; j < insert_values; ++j) for (int j = 0; j < insert_values; ++j)
obj.push_back(test_iterations); obj.insert(obj.end(), ++test_value);
++test_iterations; ++test_iterations;
} }
} }
...@@ -94,7 +103,7 @@ template<typename Container> ...@@ -94,7 +103,7 @@ 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<Container>(); int test_iterations = do_loop(obj);
stop_counters(time, resource); stop_counters(time, resource);
std::ostringstream comment; std::ostringstream comment;
...@@ -109,30 +118,59 @@ template<typename Container> ...@@ -109,30 +118,59 @@ template<typename Container>
// http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html // http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html
int main(void) 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 #ifdef TEST_B1
test_container(vector<test_type>()); test_container(vector<test_type, n_alloc_type>());
#endif #endif
#ifdef TEST_B2 #ifdef TEST_B2
test_container(vector<test_type, malloc_allocator<test_type> >()); test_container(vector<test_type, so_alloc_type>());
#endif #endif
#ifdef TEST_B3 #ifdef TEST_B3
test_container(vector<test_type, new_allocator<test_type> >()); test_container(list<test_type, m_alloc_type>());
#endif #endif
#ifdef TEST_B4 #ifdef TEST_B4
test_container(vector<test_type, __mt_alloc<test_type> >()); test_container(list<test_type, n_alloc_type>());
#endif #endif
#ifdef TEST_B5 #ifdef TEST_B5
test_container(list<test_type>()); test_container(list<test_type, so_alloc_type>());
#endif #endif
#ifdef TEST_B6 #ifdef TEST_B6
test_container(list<test_type, malloc_allocator<test_type> >()); test_container(deque<test_type, m_alloc_type>());
#endif #endif
#ifdef TEST_B7 #ifdef TEST_B7
test_container(list<test_type, new_allocator<test_type> >()); test_container(deque<test_type, n_alloc_type>());
#endif #endif
#ifdef TEST_B8 #ifdef TEST_B8
test_container(list<test_type, __mt_alloc<test_type> >()); 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 #endif
return 0; return 0;
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
#include <vector> #include <vector>
#include <list> #include <list>
#include <map>
#include <deque>
#include <set>
#include <typeinfo> #include <typeinfo>
#include <sstream> #include <sstream>
#include <pthread.h> #include <pthread.h>
...@@ -45,9 +48,6 @@ ...@@ -45,9 +48,6 @@
#include <testsuite_performance.h> #include <testsuite_performance.h>
using namespace std; using namespace std;
using __gnu_cxx::__mt_alloc;
using __gnu_cxx::new_allocator;
using __gnu_cxx::malloc_allocator;
typedef int test_type; typedef int test_type;
...@@ -62,6 +62,15 @@ int iterations = 25000; ...@@ -62,6 +62,15 @@ int iterations = 25000;
// should probably be investigated in more detail. // should probably be investigated in more detail.
int insert_values = 128; 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> template<typename Container>
void* void*
do_loop(void* p = NULL) do_loop(void* p = NULL)
...@@ -70,19 +79,21 @@ template<typename Container> ...@@ -70,19 +79,21 @@ template<typename Container>
try try
{ {
int test_iterations = 0; int test_iterations = 0;
value_type<test_type> test_value;
while (test_iterations < iterations) while (test_iterations < iterations)
{ {
for (int j = 0; j < insert_values; ++j) for (int j = 0; j < insert_values; ++j)
obj.insert(obj.begin(), test_iterations); obj.insert(obj.end(), ++test_value);
++test_iterations; ++test_iterations;
} }
// NB: Don't use clear() here, instead force deallocation. // NB: Don't use clear() here, instead force deallocation.
obj = Container(); obj = Container();
test_iterations = 0; test_iterations = 0;
test_value = value_type<test_type>();
while (test_iterations < iterations) while (test_iterations < iterations)
{ {
for (int j = 0; j < insert_values; ++j) for (int j = 0; j < insert_values; ++j)
obj.insert(obj.begin(), test_iterations); obj.insert(obj.end(), ++test_value);
++test_iterations; ++test_iterations;
} }
} }
...@@ -130,30 +141,59 @@ template<typename Container> ...@@ -130,30 +141,59 @@ template<typename Container>
// http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html // http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html
int main(void) 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 #ifdef TEST_T1
test_container(vector<test_type>()); test_container(vector<test_type, n_alloc_type>());
#endif #endif
#ifdef TEST_T2 #ifdef TEST_T2
test_container(vector<test_type, malloc_allocator<test_type> >()); test_container(vector<test_type, so_alloc_type>());
#endif #endif
#ifdef TEST_T3 #ifdef TEST_T3
test_container(vector<test_type, new_allocator<test_type> >()); test_container(list<test_type, m_alloc_type>());
#endif #endif
#ifdef TEST_T4 #ifdef TEST_T4
test_container(vector<test_type, __mt_alloc<test_type> >()); test_container(list<test_type, n_alloc_type>());
#endif #endif
#ifdef TEST_T5 #ifdef TEST_T5
test_container(list<test_type>()); test_container(list<test_type, so_alloc_type>());
#endif #endif
#ifdef TEST_T6 #ifdef TEST_T6
test_container(list<test_type, malloc_allocator<test_type> >()); test_container(deque<test_type, m_alloc_type>());
#endif #endif
#ifdef TEST_T7 #ifdef TEST_T7
test_container(list<test_type, new_allocator<test_type> >()); test_container(deque<test_type, n_alloc_type>());
#endif #endif
#ifdef TEST_T8 #ifdef TEST_T8
test_container(list<test_type, __mt_alloc<test_type> >()); 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 #endif
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment