Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54166 - sandbox/monotonic/libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-21 20:35:41


Author: cschladetsch
Date: 2009-06-21 20:35:39 EDT (Sun, 21 Jun 2009)
New Revision: 54166
URL: http://svn.boost.org/trac/boost/changeset/54166

Log:
added LARGE tests

Text files modified:
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 247 +++++++++++++++++++--------------------
   1 files changed, 121 insertions(+), 126 deletions(-)

Modified: sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp 2009-06-21 20:35:39 EDT (Sun, 21 Jun 2009)
@@ -29,92 +29,80 @@
 using namespace std;
 using namespace boost;
 
-struct test_vector_accumulate
+struct test_vector_create
 {
         template <class Alloc>
         int test(Alloc alloc, size_t length) const
         {
                 std::vector<int, typename Rebind<Alloc, int>::type> vector(length*rand()/RAND_MAX);
- return accumulate(vector.begin(), vector.end(), 0);
+ return vector.size();
         }
 };
 
-struct test_vector_random_sort
+struct test_vector_dupe
 {
         template <class Alloc>
- int test(Alloc alloc, size_t length) const
+ int test(Alloc alloc, size_t count) const
         {
- std::vector<int, typename Rebind<Alloc, int>::type> vector(length*rand()/RAND_MAX);
- generate_n(back_inserter(vector), length, rand);
+ typedef std::vector<int, typename Rebind<Alloc, int>::type> Vector;
+ Vector vector(count*rand()/RAND_MAX);
+ Vector dupe = vector;
+ return dupe.size();
+ }
+};
+
+template <class Ty>
+struct test_vector_sort
+{
+ template <class Alloc>
+ int test(Alloc, size_t count) const
+ {
+ std::vector<Ty, typename Rebind<Alloc, Ty>::type> vector(count);
+ for (size_t n = 0; n < count; ++n)
+ vector[n] = count - n;
                 sort(vector.begin(), vector.end());
                 return 0;
         }
 };
 
-struct test_vector_accumulate_unaligned
+struct test_vector_accumulate
 {
         template <class Alloc>
         int test(Alloc alloc, size_t length) const
         {
- std::vector<Unaligned, typename Rebind<Alloc, Unaligned>::type> vector(length);
- int total = 0;
- BOOST_FOREACH(Unaligned const &val, vector)
- {
- total += val.c[2];
- }
- return total;
+ std::vector<int, typename Rebind<Alloc, int>::type> vector(length*rand()/RAND_MAX);
+ return accumulate(vector.begin(), vector.end(), 0);
         }
 };
 
-struct test_map_list
+struct test_vector_accumulate_unaligned
 {
         template <class Alloc>
         int test(Alloc alloc, size_t length) const
         {
- std::map<int
- , std::list<Unaligned, typename Rebind<Alloc, Unaligned>::type>
- , std::less<int>
- , typename Rebind<Alloc, int>::type
- > map;
- size_t mod = length/10;
- for (size_t n = 0; n < length; ++n)
+ std::vector<Unaligned, typename Rebind<Alloc, Unaligned>::type> vector(length);
+ int total = 0;
+ BOOST_FOREACH(Unaligned const &val, vector)
                 {
- int random = rand() % mod;
- map[random].push_back(n);
+ total += val.c[2];
                 }
- return 0;
+ return total;
         }
 };
 
-template <class Map>
-int test_map_vector_impl(size_t length)
-{
- Map map;
- size_t mod = length/10;
- if (mod == 0)
- mod = 5;
- for (size_t n = 0; n < length; ++n)
- {
- int random = rand() % mod;
- map[random].push_back(n);
- }
- return 0;
-}
-
 template <class Ty>
-struct test_map_vector
+struct test_list_create
 {
         template <class Alloc>
- int test(Alloc, size_t length) const
+ int test(Alloc alloc, size_t count) const
         {
- return test_map_vector_impl<std::map<int
- , std::vector<Ty, typename Rebind<Alloc, Ty>::type>
- , std::less<int>
- , typename Rebind<Alloc, int>::type> >(length);
+ std::list<Ty, typename Rebind<Alloc, Ty>::type> list;
+ fill_n(back_inserter(list), count, 42);
+ return 0;
         }
 };
 
-struct test_dupe_list
+struct test_list_dupe
 {
         template <class Alloc>
         int test(Alloc alloc, size_t count) const
@@ -127,15 +115,37 @@
         }
 };
 
-struct test_dupe_vector
+template <class Ty>
+struct test_list_sort
 {
         template <class Alloc>
         int test(Alloc alloc, size_t count) const
         {
- typedef std::vector<int, typename Rebind<Alloc, Unaligned>::type> Vector;
- Vector vector(count*rand()/RAND_MAX);
- Vector dupe = vector;
- return dupe.size();
+ std::list<Ty, typename Rebind<Alloc, Ty>::type> list;
+ for (size_t n = 0; n < count; ++n)
+ list.push_back(count - n);
+ list.sort();
+ return 0;
+ }
+};
+
+struct test_map_list
+{
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ std::map<int
+ , std::list<Unaligned, typename Rebind<Alloc, Unaligned>::type>
+ , std::less<int>
+ , typename Rebind<Alloc, int>::type
+ > map;
+ size_t mod = length/10;
+ for (size_t n = 0; n < length; ++n)
+ {
+ int random = rand() % mod;
+ map[random].push_back(n);
+ }
+ return 0;
         }
 };
 
@@ -160,45 +170,31 @@
         }
 };
 
-template <class Ty>
-struct test_list_create
-{
- template <class Alloc>
- int test(Alloc alloc, size_t count) const
- {
- std::list<Ty, typename Rebind<Alloc, Ty>::type> list;
- fill_n(back_inserter(list), count, 42);
- return 0;
- }
-};
-
-
-template <class Ty>
-struct test_list_sort
+template <class Map>
+int test_map_vector_impl(size_t length)
 {
- template <class Alloc>
- int test(Alloc alloc, size_t count) const
+ Map map;
+ size_t mod = length/10;
+ if (mod == 0)
+ mod = 5;
+ for (size_t n = 0; n < length; ++n)
         {
- std::list<Ty, typename Rebind<Alloc, Ty>::type> list;
- for (size_t n = 0; n < count; ++n)
- list.push_back(count - n);
- //trace_ptrs("trace", list);
- list.sort();
- return 0;
+ int random = rand() % mod;
+ map[random].push_back(n);
         }
-};
+ return 0;
+}
 
 template <class Ty>
-struct test_vector_sort
+struct test_map_vector
 {
         template <class Alloc>
- int test(Alloc, size_t count) const
+ int test(Alloc, size_t length) const
         {
- std::vector<Ty, typename Rebind<Alloc, Ty>::type> vector(count);
- for (size_t n = 0; n < count; ++n)
- vector[n] = count - n;
- sort(vector.begin(), vector.end());
- return 0;
+ return test_map_vector_impl<std::map<int
+ , std::vector<Ty, typename Rebind<Alloc, Ty>::type>
+ , std::less<int>
+ , typename Rebind<Alloc, int>::type> >(length);
         }
 };
 
@@ -359,38 +355,14 @@
 {
         cout << "results of running test at:" << endl;
         cout << "https://svn.boost.org/svn/boost/sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp" << endl << endl;
+
         boost::timer timer;
         Type test_map_vector_types;
         Type test_dupe_list_types;
 
- bool run_large = 0;//true;
- bool run_medium = 1;//true;
- bool run_small = 1;//true;
-
- // large-size (~1000000 elements) containers
- if (run_large)
- {
- heading("MEDIUM");
- print(run_tests(10, 10000, 10, "list_create<int>", test_list_create<int>()));
- print(run_tests(20, 1000000, 10, "vector_sort<int>", test_vector_sort<int>()));
- print(run_tests(5, 100000, 10, "list_sort<int>", test_list_sort<int>()));
-
-#ifndef WIN32
- print(run_tests(1000000, 10000, 10, "dupe_vector", test_dupe_vector()));
- print(run_tests(20000, 1000, 10, "dupe_list", test_dupe_list(), test_dupe_list_types));
- print(run_tests(5000000, 2000, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(2000, 1000, 10, "vector_random_sort", test_vector_random_sort()));
- print(run_tests(5000, 500, 10, "set_vector", test_set_vector()));
- print(run_tests(500, 1000, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
-#else
- print(run_tests(1000, 100000000, 10, "dupe_vector", test_dupe_vector()));
- print(run_tests(10, 10000, 10, "dupe_list", test_dupe_list(), test_dupe_list_types));
- print(run_tests(500, 2000000, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(10, 100000, 5, "vector_random_sort", test_vector_random_sort()));
- print(run_tests(2, 50000, 5, "set_vector", test_set_vector()));
- print(run_tests(2, 1000000, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
-#endif
- }
+ bool run_small = 0;//true;
+ bool run_medium = 0;//true;
+ bool run_large = 1;//true;
 
         // small-size (~100 elements) containers
         if (run_small)
@@ -399,21 +371,21 @@
 #ifndef WIN32
                 print(run_tests(50000, 100, 10, "list_create<int>", test_list_create<int>()));
                 print(run_tests(50000, 100, 10, "list_sort<int>", test_list_sort<int>()));
- print(run_tests(200000, 100, 10, "sort_vector<int>", test_vector_sort<int>()));
- print(run_tests(1000000, 100, 10, "dupe_vector", test_dupe_vector()));
- print(run_tests(20000, 100, 10, "dupe_list", test_dupe_list(), test_dupe_list_types));
+ print(run_tests(2000000, 100, 10, "vector_create<int>", test_vector_create<int>()));
+ print(run_tests(200000, 100, 10, "vector_sort<int>", test_vector_sort()));
+ print(run_tests(1000000, 100, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(20000, 100, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
                 print(run_tests(500000, 100, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(2000, 100, 10, "vector_random_sort", test_vector_random_sort()));
                 print(run_tests(5000, 100, 10, "set_vector", test_set_vector()));
                 print(run_tests(500, 100, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
 #else
                 print(run_tests(50000, 100, 10, "list_create<int>", test_list_create<int>()));
                 print(run_tests(5000, 100, 10, "list_sort<int>", test_list_sort<int>()));
- print(run_tests(20000, 100, 10, "sort_vector<int>", test_vector_sort<int>()));
- print(run_tests(100000, 100, 10, "dupe_vector", test_dupe_vector()));
- print(run_tests(20000, 100, 10, "dupe_list", test_dupe_list(), test_dupe_list_types));
+ print(run_tests(2000000, 100, 10, "vector_create<int>", test_vector_create()));
+ print(run_tests(20000, 100, 10, "vector_sort<int>", test_vector_sort<int>()));
+ print(run_tests(100000, 100, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(20000, 100, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
                 print(run_tests(500000, 100, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(2000, 100, 10, "vector_random_sort", test_vector_random_sort()));
                 print(run_tests(50, 100, 10, "set_vector", test_set_vector()));
                 print(run_tests(500, 100, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
 #endif
@@ -425,25 +397,48 @@
                 heading("MEDIUM");
                 print(run_tests(10000, 1000, 10, "list_create<int>", test_list_create<int>()));
                 print(run_tests(5000, 1000, 10, "list_sort<int>", test_list_sort<int>()));
- print(run_tests(30000, 1000, 10, "sort_vector<int>", test_vector_sort<int>()));
+ print(run_tests(300, 100000, 10, "vector_create<int>", test_vector_create()));
+ print(run_tests(30000, 1000, 10, "vector_sort<int>", test_vector_sort<int>()));
 
 #ifndef WIN32
- print(run_tests(1000000, 10000, 10, "dupe_vector", test_dupe_vector()));
- print(run_tests(2000, 1000, 10, "dupe_list", test_dupe_list(), test_dupe_list_types));
+ print(run_tests(1000000, 10000, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(2000, 1000, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
                 print(run_tests(5000000, 2000, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(200, 1000, 10, "vector_random_sort", test_vector_random_sort()));
                 print(run_tests(5000, 500, 10, "set_vector", test_set_vector()));
                 print(run_tests(50, 1000, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
 #else
- print(run_tests(500, 10000, 10, "dupe_vector", test_dupe_vector()));
- print(run_tests(500, 1000, 10, "dupe_list", test_dupe_list(), test_dupe_list_types));
+ print(run_tests(500, 10000, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(500, 1000, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
                 print(run_tests(50000, 2000, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(100, 1000, 10, "vector_random_sort", test_vector_random_sort()));
                 print(run_tests(20, 500, 5, "set_vector", test_set_vector()));
                 print(run_tests(50, 1000, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
 #endif
         }
 
+ // large-size (~1000000 elements) containers
+ if (run_large)
+ {
+ heading("LARGE");
+ print(run_tests(10, 25000, 10, "list_create<int>", test_list_create<int>()));
+ print(run_tests(10, 1000000, 10, "list_sort<int>", test_list_sort<int>()));
+ print(run_tests(1000, 1000000, 10, "vector_create<int>", test_vector_create()));
+ print(run_tests(300, 500000, 10, "vector_sort<int>", test_vector_sort<int>()));
+
+#ifndef WIN32
+ print(run_tests(1000, 10000000, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(20, 100000, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
+ print(run_tests(5000, 20000000, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(50, 50000, 10, "set_vector", test_set_vector()));
+ print(run_tests(5, 10000, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
+#else
+ print(run_tests(200, 10000000, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(50, 10000, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
+ print(run_tests(500, 10000000, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(5, 2000, 5, "set_vector", test_set_vector()));
+ print(run_tests(10, 50000, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
+#endif
+ }
+
         cout << "tests completed in " << setprecision(5) << timer.elapsed() << "s" << endl;
 
         return 0;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk