Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54201 - sandbox/monotonic/libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-22 06:58:56


Author: cschladetsch
Date: 2009-06-22 06:58:56 EDT (Mon, 22 Jun 2009)
New Revision: 54201
URL: http://svn.boost.org/trac/boost/changeset/54201

Log:
added Tests.h
Added:
   sandbox/monotonic/libs/monotonic/test/Tests.h (contents, props changed)
Text files modified:
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 170 ---------------------------------------
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj | 4
   2 files changed, 5 insertions(+), 169 deletions(-)

Added: sandbox/monotonic/libs/monotonic/test/Tests.h
==============================================================================
--- (empty file)
+++ sandbox/monotonic/libs/monotonic/test/Tests.h 2009-06-22 06:58:56 EDT (Mon, 22 Jun 2009)
@@ -0,0 +1,180 @@
+// (C) 2009 Christian Schladetsch
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// documentation at https://svn.boost.org/svn/boost/sandbox/monotonic/libs/monotonic/doc/index.html
+// sandbox at https://svn.boost.org/svn/boost/sandbox/monotonic/
+
+#pragma once
+
+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 vector.size();
+ }
+};
+
+struct test_vector_dupe
+{
+ template <class Alloc>
+ int test(Alloc alloc, size_t count) const
+ {
+ 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
+{
+ 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);
+ }
+};
+
+struct test_vector_accumulate_unaligned
+{
+ 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;
+ }
+};
+
+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;
+ }
+};
+
+struct test_list_dupe
+{
+ template <class Alloc>
+ int test(Alloc alloc, size_t count) const
+ {
+ typedef std::list<int, typename Rebind<Alloc, int>::type> List;
+ List list;
+ fill_n(back_inserter(list), count, 42);
+ List dupe = list;
+ return dupe.size();
+ }
+};
+
+template <class Ty>
+struct test_list_sort
+{
+ template <class Alloc>
+ int test(Alloc alloc, size_t count) const
+ {
+ 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_set_vector
+{
+ template <class Alloc>
+ int test(Alloc alloc, size_t count) const
+ {
+ typedef std::vector<int, typename Rebind<Alloc, int>::type> Vector;
+ typedef std::set<Vector, std::less<Vector>, typename Rebind<Alloc, Vector>::type> Set;
+ int dummy = 0;
+ Set set;
+ for (size_t n = 0; n < count; ++n)
+ {
+ size_t size = count*rand()/RAND_MAX;
+ Vector vector(size);
+ generate_n(vector.begin(), size, rand);
+ set.insert(vector);
+ dummy += set.size();
+ }
+ return dummy;
+ }
+};
+
+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
+{
+ template <class Alloc>
+ int test(Alloc, size_t length) 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);
+ }
+};
+
+struct test_map_list_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)
+ {
+ int random = rand() % mod;
+ map[random].push_back(n);
+ }
+ return 0;
+ }
+};
+
+//EOF

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-22 06:58:56 EDT (Mon, 22 Jun 2009)
@@ -21,179 +21,11 @@
 
 #include "./AllocatorTypes.h"
 #include "./PoolResult.h"
+#include "./Tests.h"
 
 using namespace std;
 using namespace boost;
 
-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 vector.size();
- }
-};
-
-struct test_vector_dupe
-{
- template <class Alloc>
- int test(Alloc alloc, size_t count) const
- {
- 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
-{
- 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);
- }
-};
-
-struct test_vector_accumulate_unaligned
-{
- 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;
- }
-};
-
-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;
- }
-};
-
-struct test_list_dupe
-{
- template <class Alloc>
- int test(Alloc alloc, size_t count) const
- {
- typedef std::list<int, typename Rebind<Alloc, int>::type> List;
- List list;
- fill_n(back_inserter(list), count, 42);
- List dupe = list;
- return dupe.size();
- }
-};
-
-template <class Ty>
-struct test_list_sort
-{
- template <class Alloc>
- int test(Alloc alloc, size_t count) const
- {
- 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_set_vector
-{
- template <class Alloc>
- int test(Alloc alloc, size_t count) const
- {
- typedef std::vector<int, typename Rebind<Alloc, int>::type> Vector;
- typedef std::set<Vector, std::less<Vector>, typename Rebind<Alloc, Vector>::type> Set;
- int dummy = 0;
- Set set;
- for (size_t n = 0; n < count; ++n)
- {
- size_t size = count*rand()/RAND_MAX;
- Vector vector(size);
- generate_n(vector.begin(), size, rand);
- set.insert(vector);
- dummy += set.size();
- }
- return dummy;
- }
-};
-
-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
-{
- template <class Alloc>
- int test(Alloc, size_t length) 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);
- }
-};
-
-struct test_map_list_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)
- {
- int random = rand() % mod;
- map[random].push_back(n);
- }
- return 0;
- }
-};
-
 template <class Fun>
 PoolResult run_test(size_t count, size_t length, Fun fun, Type types)
 {

Modified: sandbox/monotonic/libs/monotonic/test/monotonic.vcproj
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/monotonic.vcproj (original)
+++ sandbox/monotonic/libs/monotonic/test/monotonic.vcproj 2009-06-22 06:58:56 EDT (Mon, 22 Jun 2009)
@@ -451,6 +451,10 @@
                         RelativePath=".\TestPoolAlloc.h"
>
                 </File>
+ <File
+ RelativePath=".\Tests.h"
+ >
+ </File>
         </Files>
         <Globals>
         </Globals>


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