Boost logo

Boost-Commit :

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


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

Log:
added pools

Added:
   sandbox/monotonic/boost/monotonic/link.hpp (contents, props changed)
Removed:
   sandbox/monotonic/libs/monotonic/test/main.cpp
   sandbox/monotonic/libs/monotonic/test/rope.cpp
   sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp
   sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp
   sandbox/monotonic/libs/monotonic/test/test_dupe.cpp
   sandbox/monotonic/libs/monotonic/test/test_map_list.cpp
   sandbox/monotonic/libs/monotonic/test/test_shared_storage.cpp
Text files modified:
   sandbox/monotonic/boost/monotonic/allocator_base.hpp | 52 +++++++
   sandbox/monotonic/boost/monotonic/fixed_storage.hpp | 23 ++-
   sandbox/monotonic/boost/monotonic/static_storage.hpp | 9 -
   sandbox/monotonic/boost/monotonic/storage.hpp | 138 ++++++++++++----------
   sandbox/monotonic/libs/monotonic/test/AllocatorTypes.h | 1
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 208 ++++++++++++++++++++++++----------
   sandbox/monotonic/libs/monotonic/test/monotonic.sln | 6 +
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj | 239 +++++++++++++--------------------------
   8 files changed, 374 insertions(+), 302 deletions(-)

Modified: sandbox/monotonic/boost/monotonic/allocator_base.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/allocator_base.hpp (original)
+++ sandbox/monotonic/boost/monotonic/allocator_base.hpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
@@ -6,6 +6,8 @@
 #ifndef BOOST_MONOTONIC_ALLOCATOR_BASE_HPP
 #define BOOST_MONOTONIC_ALLOCATOR_BASE_HPP
 
+//#define BOOST_MONOTONIC_USE_POOLS
+
 #include <boost/assert.hpp>
 #include <boost/type_traits/has_trivial_constructor.hpp>
 #include <boost/type_traits/has_trivial_destructor.hpp>
@@ -13,6 +15,10 @@
 #include <boost/monotonic/static_storage.hpp>
 #include <boost/monotonic/container.hpp>
 
+#ifdef BOOST_MONOTONIC_USE_POOLS
+# include <boost/monotonic/storage_pool.hpp>
+#endif
+
 namespace boost
 {
         namespace monotonic
@@ -70,12 +76,24 @@
                                 }
                         };
                 }
+ namespace detail
+ {
+ template <size_t A, size_t B>
+ struct miniumum
+ {
+ BOOST_STATIC_CONSTANT(size_t, value = A < B ? A : B);
+ };
+ template <size_t A, size_t B>
+ struct maximum
+ {
+ BOOST_STATIC_CONSTANT(size_t, value = B < A ? A : B);
+ };
+ }
 
                 /// common to other monotonic allocators for type T of type Derived
                 template <class T, class Derived>
                 struct allocator_base
                 {
- BOOST_STATIC_CONSTANT(size_t, alignment = boost::aligned_storage<sizeof(T)>::alignment);
                         typedef size_t size_type;
                         typedef ptrdiff_t difference_type;
                         typedef T *pointer;
@@ -84,19 +102,31 @@
                         typedef const T &const_reference;
                         typedef T value_type;
 
- private:
+ BOOST_STATIC_CONSTANT(size_t, PoolSize = 1000);
+ BOOST_STATIC_CONSTANT(size_t, alignment = boost::aligned_storage<sizeof(T)>::alignment);
+ BOOST_STATIC_CONSTANT(size_t, MinSize = 72);
+ BOOST_STATIC_CONSTANT(size_t, AlignedSize = alignment + sizeof(T));
+
+ BOOST_STATIC_CONSTANT(size_t, Size = sizeof(T));
+ BOOST_STATIC_CONSTANT(size_t, NodeSize1 = (Size + MinSize)/MinSize);
+ BOOST_STATIC_CONSTANT(size_t, NodeSize = NodeSize1*MinSize);
+
+ typedef storage_pool<T, NodeSize> Pool;
+
+ //private:
                         storage_base *storage;
+ static Pool pool;
 
                 public:
                         allocator_base(storage_base &store) throw()
                                 : storage(&store) { }
 
                         allocator_base(const allocator_base& alloc) throw()
- : storage(alloc.get_storage()) { }
+ : storage(alloc.storage) { }
 
                         template <class U, class D>
                         allocator_base(const allocator_base<U,D> &alloc) throw()
- : storage(alloc.get_storage()) { }
+ : storage(alloc.storage) { }
 
                         pointer address(reference x) const
                         {
@@ -112,7 +142,16 @@
                         {
                                 BOOST_ASSERT(num > 0);
                                 BOOST_ASSERT(storage != 0);
- return static_cast<pointer>(storage->allocate(num*sizeof(value_type), alignment));
+#ifdef BOOST_MONOTONIC_USE_POOLS
+ if (pointer ptr = pool.allocate(num))
+ {
+ return ptr;
+ }
+ pool.reserve_pool(storage, std::max<size_t>(8, std::max(num*2, pool.capacity()*2)));
+ return pool.allocate(num);
+#else
+ return reinterpret_cast<T *>(storage->allocate(num*sizeof(T), alignment));
+#endif
                         }
 
                         void deallocate(pointer, size_type)
@@ -175,6 +214,9 @@
                         }
                 };
 
+ template <class T, class Derived>
+ typename allocator_base<T, Derived>::Pool allocator_base<T, Derived>::pool;
+
         } // namespace monotonic
 
 } // namespace boost

Modified: sandbox/monotonic/boost/monotonic/fixed_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/fixed_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/fixed_storage.hpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
@@ -11,8 +11,9 @@
 #include <boost/monotonic/forward_declarations.hpp>
 #include <boost/monotonic/exceptions.hpp>
 #include <boost/monotonic/storage_base.hpp>
+#include <boost/monotonic/storage_pool.hpp>
 
-//#define BOOST_MONOTONIC_FIXED_EARLY_OUT
+//#define BOOST_MONOTONIC_STORAGE_EARLY_OUT
 
 namespace boost
 {
@@ -26,7 +27,7 @@
 
                 private:
                         Buffer buffer; ///< the storage
-#ifdef BOOST_MONOTONIC_FIXED_EARLY_OUT
+#ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
                         /// if `full` is true, buffer has reached its capacity; used for early-out on allocation.
                         /// this maybe should be removed, because although it may speed up allocation
                         /// a little when the buffer is full, it also slows it down a little when it is not
@@ -39,7 +40,7 @@
                 public:
                         fixed_storage()
                                 : cursor(0)
-#ifdef BOOST_MONOTONIC_FIXED_EARLY_OUT
+#ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
                                 , full(false)
 #endif
 #ifndef NDEBUG
@@ -63,7 +64,7 @@
                         void reset()
                         {
                                 cursor = 0;
-#ifdef BOOST_MONOTONIC_FIXED_EARLY_OUT
+#ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
                                 full = false;
 #endif
 #ifndef NDEBUG
@@ -86,22 +87,30 @@
                         }
 
                         // testing performance against a fixed-size alignment
- BOOST_STATIC_CONSTANT(size_t, alignment = 16);
+ BOOST_STATIC_CONSTANT(size_t, alignment = 64);
 
                         /// allocate storage, given alignment requirement
                         void *allocate(size_t num_bytes, size_t /*alignment*/)
                         {
-#ifdef BOOST_MONOTONIC_FIXED_EARLY_OUT
+ if (0)
+ {
+ void *ptr = &buffer[cursor];
+ cursor += 64;
+ return ptr;
+ }
+
+#ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
                                 if (full)
                                         return 0;
 #endif
+
                                 size_t extra = cursor & (alignment - 1);
                                 if (extra > 0)
                                         extra = alignment - extra;
                                 size_t required = num_bytes + extra;
                                 if (cursor + required > InlineSize)
                                 {
-#ifdef BOOST_MONOTONIC_FIXED_EARLY_OUT
+#ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
                                         full = InlineSize - cursor < 16;
 #endif
                                         return 0;

Added: sandbox/monotonic/boost/monotonic/link.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/monotonic/link.hpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
@@ -0,0 +1,86 @@
+// Copyright (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)
+
+#ifndef BOOST_MONOTONIC_ALLOCATOR_DETAIL_LINK_HPP
+#define BOOST_MONOTONIC_ALLOCATOR_DETAIL_LINK_HPP
+
+//#include <boost/monotonic/allocator_base.hpp>
+
+namespace boost
+{
+ namespace monotonic
+ {
+ namespace detail
+ {
+ /// a link in the chain of heap-based memory buffers used by a storage<> structure
+ template <class Al>
+ struct Link : storage_base
+ {
+ typedef Al CharAllocator;
+
+ private:
+ size_t capacity, cursor;
+ char *buffer;
+ CharAllocator alloc;
+
+ public:
+ Link() : capacity(0), cursor(0), buffer(0)
+ {
+ }
+ template <class Al2>
+ Link(Al2 const &al, size_t cap)
+ : capacity(cap), cursor(0), buffer(0), alloc(typename Al2::template rebind<char>::other(al))
+ {
+ buffer = alloc.allocate(capacity);
+ if (buffer == 0)
+ capacity = 0;
+ }
+ size_t max_size() const
+ {
+ return capacity;
+ }
+ size_t remaining() const
+ {
+ return capacity - cursor;
+ }
+ void reset()
+ {
+ cursor = 0;
+ }
+ void release()
+ {
+ alloc.deallocate(buffer, 1);
+ }
+ size_t used() const
+ {
+ return cursor;
+ }
+ inline void *allocate(size_t num_bytes, size_t alignment)
+ {
+ size_t extra = cursor & (alignment - 1);
+ if (extra > 0)
+ extra = alignment - extra;
+ size_t required = num_bytes + extra;
+ if (capacity - cursor < required)
+ return 0;
+ char *ptr = buffer + cursor;
+ cursor += required;
+ return ptr + extra;
+ }
+ friend bool operator<(Link const &A, Link const &B)
+ {
+ return A.remaining() < B.remaining();
+ }
+ };
+
+ } // namespace detail
+
+ } // namespace monotonic
+
+} // namespace boost
+
+#endif // BOOST_MONOTONIC_ALLOCATOR_DETAIL_LINK_HPP
+
+//EOF

Modified: sandbox/monotonic/boost/monotonic/static_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/static_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/static_storage.hpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
@@ -77,16 +77,7 @@
                 {
                         static_storage = &default_static_storage;
                 }
-
- /// TODO: this will be specialised for
- /// static_storage_base<..., shared_storage>, but to avoid having to link against boost::thread
- /// it is currently synonymous with unshared storage ATM
 
- // BOOST_MONOTONIC_SHARED_STORAGE_DEFINED is just a hack to avoid having to link with boost::thread
- // while allowing the possible inclusion of boost/monotonic/shared_storage.hpp for testing
-//#ifndef BOOST_MONOTONIC_SHARED_STORAGE_DEFINED
-// extern static_storage_base<> static_shared_storage;
-//#endif
 
         } // namespace monotonic
 

Modified: sandbox/monotonic/boost/monotonic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage.hpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
@@ -9,6 +9,7 @@
 #include <algorithm>
 //#include <boost/monotonic/allocator.hpp>
 #include <boost/monotonic/fixed_storage.hpp>
+#include <boost/monotonic/link.hpp>
 
 namespace boost
 {
@@ -25,80 +26,74 @@
                 {
                         typedef Al Allocator;
                         typedef typename Allocator::template rebind<char>::other CharAllocator;
+ typedef detail::Link<CharAllocator> Link;
+ typedef storage<InlineSize, MinHeapIncrement, Al> This;
+ typedef std::vector<Link> Chain;
 
- /// a link in the chain of heap-based memory buffers
- struct Link
+ private:
+ fixed_storage<InlineSize> fixed; // the inline fixed-sized storage which may be on the stack
+ Chain chain; // heap-based storage
+ Allocator alloc; // allocator for heap-based storage
+
+ BOOST_STATIC_CONSTANT(size_t, NumPools = 8);
+ BOOST_STATIC_CONSTANT(size_t, MinPoolSize = 8);
+ BOOST_STATIC_CONSTANT(size_t, ChunkShift = 4);
+ BOOST_STATIC_CONSTANT(size_t, ChunkSize = 1 << ChunkShift);
+
+ template <class Storage>
+ struct Pool
                         {
- size_t capacity, cursor;
- char *buffer;
- CharAllocator alloc;
- Link() : capacity(0), cursor(0), buffer(0)
+ char *first, *next, *last;
+ size_t bucket_size;
+ Pool() : first(0), next(0), last(0), bucket_size(0)
                                 {
                                 }
- Link(Allocator const &al, size_t cap)
- : capacity(cap), cursor(0), buffer(0), alloc(al)
+ Pool(size_t bs) : first(0), next(0), last(0), bucket_size(bs)
                                 {
- Construct();
                                 }
- void Construct()
+ void *allocate(Storage *storage)
                                 {
- buffer = alloc.allocate(capacity);
- if (buffer == 0)
- capacity = 0;
+ if (next == last)
+ expand(storage);
+ void *ptr = next;
+ next += bucket_size;
+ return ptr;
                                 }
- size_t remaining() const
+ void expand(Storage *storage)
                                 {
- return capacity - cursor;
+ size_t capacity = std::max(MinPoolSize*bucket_size, (last - first)*bucket_size*2);
+ void *ptr = storage->from_fixed(capacity, 16);
+ if (ptr == 0)
+ {
+ ptr = storage->from_heap(capacity, 16);
+ }
+ first = next = (char *)ptr;
+ last = first + capacity;
                                 }
                                 void reset()
                                 {
- cursor = 0;
- }
- void clear()
- {
- alloc.deallocate(buffer, 1);
- }
- size_t used() const
- {
- return cursor;
- }
- bool CanAllocate(size_t num_bytes) const
- {
- return capacity - cursor >= num_bytes;
- }
- inline void *Allocate(size_t num_bytes, size_t alignment)
- {
- size_t extra = cursor & (alignment - 1);
- if (extra > 0)
- extra = alignment - extra;
- size_t required = num_bytes + extra;
- if (capacity - cursor < required)
- return 0;
- char *ptr = buffer + cursor;
- cursor += required;
- return ptr + extra;
- }
- friend bool operator<(Link const &A, Link const &B)
- {
- return A.remaining() < B.remaining();
+ first = next = last = 0;
                                 }
                         };
- typedef std::vector<Link > Chain; // maintained a priority-queue
- typedef fixed_storage<8*1024> ChainStorage; // local storage for the chain
+ boost::array<Pool<This>, NumPools> pools;
 
- private:
- fixed_storage<InlineSize> fixed; // the inline fixed-sized storage which may be on the stack
- //ChainStorage chain_storage; // use a seperate inline storage for the chains.
- Chain chain; // heap-based storage
- Allocator alloc; // allocator for heap-based storage
+ void create_pools()
+ {
+ for (size_t n = 0; n < NumPools; ++n)
+ {
+ pools[n] = Pool<This>(n*ChunkSize);
+ }
+ }
 
                 public:
- storage()// : chain(chain_storage)
+ storage()
                         {
+ create_pools();
                         }
                         storage(Allocator const &A)
                                 : alloc(A)
                         {
+ create_pools();
                         }
                         ~storage()
                         {
@@ -108,6 +103,10 @@
                         void reset()
                         {
                                 fixed.reset();
+ BOOST_FOREACH(Pool<This> &pool, pools)
+ {
+ pool.reset();
+ }
                                 BOOST_FOREACH(Link &link, chain)
                                 {
                                     link.reset();
@@ -119,31 +118,49 @@
                                 reset();
                                 BOOST_FOREACH(Link &link, chain)
                                 {
- link.clear();
+ link.release();
                                 }
                                 chain.clear();
                         }
 
                         void *allocate(size_t num_bytes, size_t alignment)
                         {
- if (void *ptr = fixed.allocate(num_bytes, alignment))
- {
+ if (void *ptr = from_pool(num_bytes, alignment))
                                         return ptr;
- }
+ if (void *ptr = from_fixed(num_bytes, alignment))
+ return ptr;
+ return from_heap(num_bytes, alignment);
+ }
+
+ void *from_pool(size_t num_bytes, size_t alignment)
+ {
+ size_t bucket_num = (ChunkSize + num_bytes) >> ChunkShift;
+ if (bucket_num >= NumPools)
+ return 0;
+ return pools[bucket_num].allocate(this);
+ }
+
+ void *from_fixed(size_t num_bytes, size_t alignment)
+ {
+ return fixed.allocate(num_bytes, alignment);
+ }
+
+ void *from_heap(size_t num_bytes, size_t alignment)
+ {
                                 if (!chain.empty())
                                 {
- if (void *ptr = chain.front().Allocate(num_bytes, alignment))
+ if (void *ptr = chain.front().allocate(num_bytes, alignment))
                                         {
                                                 return ptr;
                                         }
                                         std::make_heap(chain.begin(), chain.end());
- if (void *ptr = chain.front().Allocate(num_bytes, alignment))
+ if (void *ptr = chain.front().allocate(num_bytes, alignment))
                                         {
                                                 return ptr;
                                         }
                                 }
                                 AddLink(std::max(MinHeapIncrement, num_bytes*2));
- void *ptr = chain.front().Allocate(num_bytes, alignment);
+ void *ptr = chain.front().allocate(num_bytes, alignment);
                                 if (ptr == 0)
                                         throw std::bad_alloc();
                                 return ptr;
@@ -181,11 +198,10 @@
                         void AddLink(size_t size)
                         {
                                 chain.push_back(Link(alloc, size));
- std::push_heap(chain.begin(), chain.end());
+ std::make_heap(chain.begin(), chain.end());
                         }
                 };
 
-
         } // namespace monotonic
 
 } // namespace boost

Modified: sandbox/monotonic/libs/monotonic/test/AllocatorTypes.h
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/AllocatorTypes.h (original)
+++ sandbox/monotonic/libs/monotonic/test/AllocatorTypes.h 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
@@ -33,6 +33,7 @@
         Type(unsigned bits = All) : flags(bits) { }
         bool Includes(unsigned bit) const { return (flags & bit) != 0; }
         void Exclude(unsigned bit) { flags &= ~bit; }
+ void Include(unsigned bit) { flags |= bit; }
         std::string ToString() const;
 };
 

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 03:35:04 EDT (Sun, 21 Jun 2009)
@@ -24,6 +24,21 @@
 
 #include "./AllocatorTypes.h"
 
+template <class List>
+void trace_ptrs(const char *t, List const &list)
+{
+ printf("%s\n", t);
+ typename List::const_iterator A = list.begin(), B = list.end(), C;
+ C = A;
+ C++;
+ for (; C != B; ++A, ++C)
+ {
+ char *p = (char *)&*C;
+ char *q = (char *)&*A;
+ printf("%p: %d\n", q, p - q);
+ }
+}
+
 using namespace std;
 using namespace boost;
 
@@ -49,18 +64,6 @@
         }
 };
 
-struct thrash_pool_sort_list_int
-{
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- std::list<int, typename Rebind<Alloc, int>::type> list;
- generate_n(back_inserter(list), length, rand);
- list.sort();
- return 0;
- }
-};
-
 struct test_vector_accumulate_unaligned
 {
         template <class Alloc>
@@ -101,6 +104,8 @@
 {
         Map map;
         size_t mod = length/10;
+ if (mod == 0)
+ mod = 5;
         for (size_t n = 0; n < length; ++n)
         {
                 int random = rand() % mod;
@@ -168,30 +173,21 @@
         }
 };
 
-template <class Container>
-int bubble_sort(Container &cont)
+template <class Ty>
+struct test_list_create
 {
- bool swapped;
- do
+ template <class Alloc>
+ int test(Alloc alloc, size_t count) const
         {
- swapped = false;
- typename Container::iterator A = cont.begin(), B = --cont.end();
- typename Container::iterator C = A;
- for (++C, --B; A != B; ++A, ++C)
- {
- if (*C < *A)
- {
- std::swap(*A, *C);
- swapped = true;
- }
- }
+ std::list<Ty, typename Rebind<Alloc, Ty>::type> list;
+ fill_n(back_inserter(list), count, 42);
+ return 0;
         }
- while (swapped);
- return 0;
-}
+};
+
 
 template <class Ty>
-struct test_sort_list
+struct test_list_sort
 {
         template <class Alloc>
         int test(Alloc alloc, size_t count) const
@@ -199,6 +195,7 @@
                 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;
         }
@@ -307,17 +304,17 @@
 
         if (types.Includes(Type::Monotonic))
         {
- srand(42);
- monotonic::local<monotonic::storage<100000> > storage;
- boost::timer timer;
- for (size_t n = 0; n < count; ++n)
- {
- {
- fun.test(mono_alloc(), length);
- }
- storage.reset();
- }
- result.local_mono_elapsed = timer.elapsed();
+ //srand(42);
+ //monotonic::local<monotonic::storage<100000> > storage;
+ //boost::timer timer;
+ //for (size_t n = 0; n < count; ++n)
+ //{
+ // {
+ // fun.test(mono_alloc(), length);
+ // }
+ // storage.reset();
+ //}
+ //result.local_mono_elapsed = timer.elapsed();
         }
 
         if (types.Includes(Type::Standard))
@@ -340,13 +337,14 @@
 template <class Fun>
 PoolResults run_tests(size_t count, size_t max_length, size_t num_iterations, const char *title, Fun fun, Type types = Type::All)
 {
+ boost::timer timer;
         cout << title << ": reps=" << count << ", len=" << max_length << ", steps=" << num_iterations;
         PoolResults results;
- for (size_t length = 10; length < max_length; length += max_length/num_iterations)
+ for (size_t length = 1; length < max_length; length += max_length/num_iterations)
         {
                 results[length] = run_test(count, length, fun, types);
         }
- cout << endl;
+ cout << endl << "completed in " << timer.elapsed() << "s" << endl;
         return results;
 }
 
@@ -370,37 +368,120 @@
 
 int main()
 {
+ if (0)
+ {
+ std::list<int, Allocator<Type::FastPool, int> > fp_list;
+ std::list<int, Allocator<Type::TBB, int> > tbb_list;
+ std::list<int, Allocator<Type::Monotonic, int> > m_list;
+
+ size_t ms = Allocator<Type::Monotonic, char>::NodeSize;
+ printf("ms=%d\n", ms);
+
+ fp_list.push_back(1);
+ fp_list.push_back(2);
+ fp_list.push_back(3);
+ tbb_list.push_back(1);
+ tbb_list.push_back(2);
+ tbb_list.push_back(3);
+ m_list.push_back(1);
+ m_list.push_back(2);
+ m_list.push_back(3);
+ trace_ptrs("fp", fp_list);
+ trace_ptrs("tbb", tbb_list);
+ trace_ptrs("mono", m_list);
+ }
+ //Type types = Type::None;
+ //types.Include(Type::TBB);
+ //types.Include(Type::Monotonic);
+
+ //print(run_tests(1, 10, 2, "list_create<int>", test_list_create<int>(), types));
+ //print(run_tests(100, 10, 2, "list_sort<int>", test_list_sort<int>(), types));
+ //return 0;
+ //print(run_tests(1, 10, 2, "list_create<int>", test_list_create<int>(), types));
+ //return 1;
+ //print(run_tests(5000, 100, 10, "list_create<int>", test_list_create<int>()));
+ //print(run_tests(1, 100, 10, "list_sort<int>", test_list_sort<int>()));
+ //return 0;
+
         boost::timer timer;
         Type test_map_vector_types;
         Type test_dupe_list_types;
 
- ///test_map_vector_types.Exclude(Type::FastPool);
- ///test_dupe_list_types.Exclude(Type::Pool);
- size_t scale = 1;
+ bool run_large = 0;//true;
+ bool run_medium = 1;//true;
+ bool run_small = 0;//true;
+
+ // large-size (~1000000 elements) containers
+ if (run_large)
+ {
+ print(run_tests(10, 10000, 10, "list_create<int>", test_list_create<int>()));
+ print(run_tests(20, 1000000, 10, "vector_sort<int>", test_sort_vector<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
+ }
+
+ // small-size (~100 elements) containers
+ if (run_small)
+ {
+ print(run_tests(5000, 100, 10, "list_sort<int>", test_list_sort<int>()));
+ print(run_tests(5000, 100, 10, "list_create<int>", test_list_create<int>()));
+ print(run_tests(200000, 100, 10, "sort_vector<int>", test_sort_vector<int>()));
+
 #ifndef WIN32
- scale = 50;
+ print(run_tests(1000000, 100, 10, "dupe_vector", test_dupe_vector()));
+ print(run_tests(200000, 100, 10, "dupe_list", test_dupe_list(), test_dupe_list_types));
+ print(run_tests(50000000, 100, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(20000, 100, 10, "vector_random_sort", test_vector_random_sort()));
+ print(run_tests(50000, 10, 10, "set_vector", test_set_vector()));
+ print(run_tests(5000, 100, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
 #else
- // these are very slow with MSVC
+ print(run_tests(500000, 100, 10, "dupe_vector", test_dupe_vector()));
+ print(run_tests(50000, 100, 10, "dupe_list", test_dupe_list(), 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(200, 50, 10, "set_vector", test_set_vector()));
+ print(run_tests(800, 100, 10, "map_vector<int>", test_map_vector<int>(), test_map_vector_types));
 #endif
+ }
 
- print(run_tests(20000, 1000, 10, "sort_vector<int>", test_sort_vector<int>()));
- print(run_tests(5000, 1000, 10, "sort_list<int>", test_sort_list<int>()));
+ // medium-size (~1000 elements) containers
+ if (run_medium)
+ {
+ print(run_tests(1000, 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(20000, 1000, 10, "sort_vector<int>", test_sort_vector<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));
+ 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(10000, 10000, 10, "dupe_vector", test_dupe_vector()));
- print(run_tests(1000, 1000, 10, "dupe_list", test_dupe_list(), test_dupe_list_types));
- print(run_tests(50000, 2000, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(1000, 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));
+ print(run_tests(10000, 10000, 10, "dupe_vector", test_dupe_vector()));
+ print(run_tests(1000, 1000, 10, "dupe_list", test_dupe_list(), test_dupe_list_types));
+ print(run_tests(50000, 2000, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(1000, 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
+ }
 
         cout << "tests completed in " << timer.elapsed() << "s" << endl;
 
@@ -411,6 +492,7 @@
 {
         namespace monotonic
         {
+ Pools pools;
                 static_storage_base<> default_static_storage;
                 storage_base *static_storage = &default_static_storage;
         }

Deleted: sandbox/monotonic/libs/monotonic/test/main.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/main.cpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
+++ (empty file)
@@ -1,392 +0,0 @@
-// 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)
-
-// the documentation is at https://svn.boost.org/svn/boost/sandbox/monotonic/libs/monotonic/doc/index.html
-
-// the sandbox is at https://svn.boost.org/svn/boost/sandbox/monotonic/
-
-// commented-out till i add the correct libs for boost::mutex
-//#include <boost/monotonic/shared_storage.hpp>
-//#include <boost/monotonic/shared_allocator.hpp>
-
-#include <boost/monotonic/local.hpp>
-#include <boost/monotonic/static_storage.hpp>
-
-#include <boost/monotonic/vector.hpp>
-#include <boost/monotonic/list.hpp>
-#include <boost/monotonic/map.hpp>
-#include <boost/monotonic/set.hpp>
-#include <boost/bind.hpp>
-
-#include <algorithm>
-#include <functional>
-
-
-#include <boost/iterator/counting_iterator.hpp>
-
-
-#include <boost/timer.hpp>
-#include <boost/foreach.hpp>
-#include <iostream>
-#include <deque>
-#include <sstream>
-
-#include <boost/range.hpp>
-#include <boost/iterator/counting_iterator.hpp>
-#include <boost/array.hpp>
-#include <boost/scoped_ptr.hpp>
-
-#include <boost/monotonic/chain.hpp>
-#include <boost/monotonic/storage.hpp>
-////#include <boost/monotonic/shared_allocator.hpp>
-
-template <class T
-, size_t C = 64
-, class Al = std::allocator<T>
-, class Link = std::vector<T, Al>
-, class Links = std::deque<Link, Al>
->
-struct chain;
-
-
-using namespace std;
-using namespace boost;
-
-void test_deque()
-{
- monotonic::local<> storage;
- {
- {
- std::list<int, boost::monotonic::allocator<int> > list;
- fill_n(back_inserter(list), 100, 42);
- cout << "list: " << storage.used() << endl;
- }
- storage.reset();
- {
- std::deque<int, boost::monotonic::allocator<int> > deque;
- fill_n(back_inserter(deque), 100, 42);
- cout << "deque: " << storage.used() << endl;
- }
- storage.reset();
-
- {
- std::vector<int, boost::monotonic::allocator<int> > vector;
- fill_n(back_inserter(vector), 100, 42);
- cout << "vector: " << storage.used() << endl;
- }
- storage.reset();
-
- {
- monotonic::chain<int> chain;
- fill_n(back_inserter(chain), 100, 42);
- cout << "default chain: " << storage.used() << endl;
- }
- storage.reset();
-
- {
- monotonic::chain<int, 100> chain;
- fill_n(back_inserter(chain), 100, 42);
- cout << "chain<100>: " << storage.used() << endl;
- }
- storage.reset();
- }
-}
-
-void test_speed()
-{
- monotonic::local<monotonic::storage<1000000> > storage;
- typedef monotonic::map<int, monotonic::list<int> > map_with_list;
- {
- map_with_list m;
- size_t count = 10000;
- boost::timer timer;
- for (size_t i = 0; i < count; ++i)
- {
- int random = rand() % 100;
- map_with_list::iterator iter = m.find(random);
- if (iter == m.end())
- m.insert(make_pair(random, monotonic::list<int>()));
- else
- iter->second.push_back(i);
- }
- double elapsed = timer.elapsed();
- cout << "monotonic: " << elapsed << endl;
-
- // do the same thing, with std::containers
- {
- typedef std::map<int, std::list<int> > map_with_list;
- map_with_list m;
- boost::timer timer;
- for (size_t i = 0; i < count; ++i)
- {
- int random = rand() % 100;
- map_with_list::iterator iter = m.find(random);
- if (iter == m.end())
- m[random] = std::list<int>();
- else
- iter->second.push_back(i);
- }
- double elapsed = timer.elapsed();
- cout << "std: " << elapsed << endl;
- }
- }
-}
-
-namespace
-{
- template<typename C>
- struct Foo
- {
- long ord;
- C c;
- };
-
- const int LOOP_COUNT = 100000000;
- const int ELEM_COUNT = 1000;
-
- template<typename C>
- void test_loop_monotonic()
- {
- monotonic::local<> storage;
- std::vector<Foo<C>, monotonic::allocator<Foo<C> > > vec;
- Foo<C> orig = { 'A', 65 };
- vec.assign(ELEM_COUNT, orig);
- boost::timer timer;
- for (int i = 0; i < LOOP_COUNT; ++i)
- ++vec[1 + i % (ELEM_COUNT - 2)].ord;
- double elapsed = timer.elapsed();
- std::cout << "Incrementing ord = " << 1000000000*elapsed/LOOP_COUNT << " ps per iteration" << std::endl;
- }
-
- template <class C>
- void test_loop_std()
- {
- Foo<C> orig = { 'A', 65 };
- std::vector<Foo<C> > vec;
- vec.assign(ELEM_COUNT, orig);
- boost::timer timer;
- for (int i = 0; i < LOOP_COUNT; ++i)
- ++vec[1 + i % (ELEM_COUNT - 2)].ord;
- double elapsed = timer.elapsed();
- std::cout << "STD: Incrementing ord = " << 1000000000*elapsed/LOOP_COUNT << " ps per iteration" << std::endl;
- }
-
-} // namespace
-
-void test_alignment()
-{
- monotonic::fixed_storage<10000> storage;
-
- // the two arguments to storage.allocate are the size, and the required alignment
- void *P = storage.allocate(3, 4);
- assert(P == storage.begin() + 0);
-
- P = storage.allocate(3, 4);
- assert(P == storage.begin() + 4);
-
- P = storage.allocate(11, 4);
- assert(P == storage.begin() + 8);
-
- P = storage.allocate(11, 16);
- assert(P == storage.begin() + 32);
-
-
- typedef boost::array<char, 3> c0;
- typedef boost::array<char, 6> c1;
- typedef boost::array<char, 11> c2;
- typedef boost::array<char, 31> c3;
- typedef boost::array<char, 33> c4;
- typedef boost::array<char, 57> c5;
- typedef boost::array<char, 111> c6;
-
- monotonic::vector<c0> v0;
- monotonic::vector<c1> v1;
- monotonic::vector<c2> v2;
- monotonic::vector<c3> v3;
- monotonic::vector<c4> v4;
- monotonic::vector<c5> v5;
- monotonic::vector<c6> v6;
-
- v0.resize(5);
- v1.resize(5);
- v2.resize(5);
- v3.resize(5);
- v4.resize(5);
- v5.resize(5);
- v6.resize(5);
-#define write_cn(n) \
- BOOST_FOREACH(c ## n &c, v ## n) \
- c = c ## n();
- write_cn(0);
- write_cn(1);
- write_cn(2);
- write_cn(3);
- write_cn(4);
- write_cn(5);
- write_cn(6);
-#undef write_cn
-
-
- test_loop_monotonic<char>();
- test_loop_monotonic<long>();
-
- test_loop_std<char>();
- test_loop_std<short>();
-
-}
-
-
-
-template <class T>
-pair<boost::counting_iterator<T>, boost::counting_iterator<T> > range(T start, T end)
-{
- typedef boost::counting_iterator<T> cit;
- return std::make_pair(cit(start), cit(end));
-}
-
-
-void test_chain();
-
-#include "test_map_list.cpp"
-#include "test_bubble_sort.cpp"
-#include "test_dupe.cpp"
-#include "test_chained_storage.cpp"
-#include "test_shared_storage.cpp"
-#include "compare_memory_pool.cpp"
-
-namespace boost
-{
- namespace monotonic
- {
- static_storage_base<> default_static_storage;
- storage_base *static_storage = &default_static_storage;
-
- //storage<> static_storage_base<storage<> >::global;
- }
-}
-
-void test_static_storage()
-{
- // reset the global static storage to zero use
- boost::monotonic::get_storage().reset();
-
- typedef std::list<int, monotonic::allocator<int> > List;
- typedef std::map<int, List, std::less<int>, monotonic::allocator<int> > Map;
- {
- List list0, list1;
- Map map;
- list0.push_back(1);
- list1.push_back(2);
- list0.splice(list0.begin(), list1);
- map[42] = list0;
- map[123] = list1;
- }
- cout << monotonic::get_storage().used() << endl;
- boost::monotonic::get_storage().reset();
-}
-
-void run_all_tests()
-{
- test_static_storage();
- test_shared_storage();
- test_chained_storage();
- test_map_list_heap_stack();
- test_dupe();
- graph_bubble_sort();
- test_bubble_sort();
- //test_chain();
- test_deque();
- test_alignment();
- //test_speed();
- //test_speed_heap();
-}
-
-void test_mono_map()
-{
- monotonic::local<> store;
-/*
-// commented out till i add the required libraries for boost::mutex :/
-
- monotonic::shared_storage<> shared_store;
- {
- typedef std::list<int, monotonic::shared_allocator<int> > List;
- typedef std::vector<List, monotonic::shared_allocator<List> > Vector;
-
- BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<List>::value);
- BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<Vector>::value);
-
- Vector vec(shared_store);
-
- vec.resize(1);
- BOOST_ASSERT(vec[0].get_allocator().get_storage() == vec.get_allocator().get_storage());
- vec[0].push_back(42);
- }
-*/
-
- // this can't work in general:
- //{
- // typedef std::list<int, monotonic::allocator<int> > List;
- // BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<List>::value);
- // typedef std::map<int, List, std::less<int>, monotonic::allocator<int> > Map;
- // BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<Map>::value);
- // Map map(less<int>(), store);
- // //map[42].push_back(123);
- // map.insert(make_pair(42, List(store)));
- // map[42].push_back(123);
- // BOOST_ASSERT(map[42].get_allocator().get_storage() == map.get_allocator().get_storage());
- //}
-
- // but this can:
- {
- typedef monotonic::list<int> List;
- BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<List>::value);
- typedef monotonic::map<int, List > Map;
- BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<Map>::value);
- Map map;
- map[42].push_back(123);
- BOOST_ASSERT(map[42].get_allocator().get_storage() == map.get_allocator().get_storage());
- }
-
- {
- typedef monotonic::map<int, monotonic::map<int, monotonic::list<int> > > Map;
- Map map;
- map[42][64].push_back(13);
- BOOST_ASSERT(map[42][64].get_allocator().get_storage() == map.get_allocator().get_storage());
- }
-}
-
-#ifdef WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-//warning C4297: 'straight_to_debugger' : function assumed not to throw an exception but does
-#pragma warning(disable:4297)
-extern "C" void straight_to_debugger(unsigned int, EXCEPTION_POINTERS*)
-{
- throw;
-}
-#endif
-
-
-int main()
-{
- {
- typedef std::list<int, monotonic::allocator<int> > List;
- std::map<int, List, std::less<int>, monotonic::allocator<int> > map;
- generate_n(inserter(map, map.begin()), 42, boost::bind(std::make_pair<int,List>, 123, List()));
- }
- monotonic::reset_storage();
-
-#ifdef WIN32
- _set_se_translator(straight_to_debugger);
-#endif
-
- //test_chained_storage();
- //test_map_list_heap_stack();
- compare();
- //test_mono_map();
- //test_mono_map();
- //test_static_storage();
- //run_all_tests();
-}
-
-//EOF

Modified: sandbox/monotonic/libs/monotonic/test/monotonic.sln
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/monotonic.sln (original)
+++ sandbox/monotonic/libs/monotonic/test/monotonic.sln 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
@@ -9,15 +9,21 @@
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
                 Release|Win32 = Release|Win32
+ ReleaseSym|Win32 = ReleaseSym|Win32
         EndGlobalSection
         GlobalSection(ProjectConfigurationPlatforms) = postSolution
                 {5688980A-015B-4C7D-8D8D-F5894205FACE}.Debug|Win32.ActiveCfg = Debug|Win32
                 {5688980A-015B-4C7D-8D8D-F5894205FACE}.Debug|Win32.Build.0 = Debug|Win32
                 {5688980A-015B-4C7D-8D8D-F5894205FACE}.Release|Win32.ActiveCfg = Release|Win32
                 {5688980A-015B-4C7D-8D8D-F5894205FACE}.Release|Win32.Build.0 = Release|Win32
+ {5688980A-015B-4C7D-8D8D-F5894205FACE}.ReleaseSym|Win32.ActiveCfg = ReleaseSym|Win32
+ {5688980A-015B-4C7D-8D8D-F5894205FACE}.ReleaseSym|Win32.Build.0 = ReleaseSym|Win32
                 {470832FD-33D6-4F31-AD06-BB7838371077}.Debug|Win32.ActiveCfg = Debug|Win32
+ {470832FD-33D6-4F31-AD06-BB7838371077}.Debug|Win32.Build.0 = Debug|Win32
                 {470832FD-33D6-4F31-AD06-BB7838371077}.Release|Win32.ActiveCfg = Release|Win32
                 {470832FD-33D6-4F31-AD06-BB7838371077}.Release|Win32.Build.0 = Release|Win32
+ {470832FD-33D6-4F31-AD06-BB7838371077}.ReleaseSym|Win32.ActiveCfg = ReleaseSym|Win32
+ {470832FD-33D6-4F31-AD06-BB7838371077}.ReleaseSym|Win32.Build.0 = ReleaseSym|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

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-21 03:35:04 EDT (Sun, 21 Jun 2009)
@@ -139,6 +139,83 @@
                                 Name="VCLinkerTool"
                                 LinkIncremental="1"
                                 AdditionalLibraryDirectories="C:\Lib\tbb21_20080605oss\ia32\vc9\lib"
+ GenerateDebugInformation="false"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="ReleaseSym|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="$(ProjectDir)/../../..;C:\Lib\tbb21_20080605oss\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ ExceptionHandling="2"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="C:\Lib\tbb21_20080605oss\ia32\vc9\lib"
                                 GenerateDebugInformation="true"
                                 SubSystem="1"
                                 OptimizeReferences="2"
@@ -214,6 +291,10 @@
>
                                 </File>
                                 <File
+ RelativePath="..\..\..\boost\monotonic\link.hpp"
+ >
+ </File>
+ <File
                                         RelativePath="..\..\..\boost\monotonic\list.hpp"
>
                                 </File>
@@ -266,10 +347,6 @@
                                 Name="utility"
>
                                 <File
- RelativePath="..\..\..\boost\utility\chain.h"
- >
- </File>
- <File
                                         RelativePath="..\..\..\boost\utility\iter_range.hpp"
>
                                 </File>
@@ -322,20 +399,8 @@
                                         Name="VCCLCompilerTool"
                                 />
                         </FileConfiguration>
- </File>
- <File
- RelativePath=".\chain.cpp"
- >
                         <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
+ Name="ReleaseSym|Win32"
                                 ExcludedFromBuild="true"
>
                                 <Tool
@@ -354,146 +419,6 @@
                                 />
                         </FileConfiguration>
                 </File>
- <File
- RelativePath=".\main.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\rope.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\test_bubble_sort.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\test_chained_storage.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\test_dupe.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\test_map_list.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\test_shared_storage.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
         </Files>
         <Globals>
         </Globals>

Deleted: sandbox/monotonic/libs/monotonic/test/rope.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/rope.cpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
+++ (empty file)
@@ -1,114 +0,0 @@
-// 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)
-
-// the documentation is at https://svn.boost.org/svn/boost/sandbox/monotonic/libs/monotonic/doc/index.html
-
-// the sandbox is at https://svn.boost.org/svn/boost/sandbox/monotonic/
-
-#include <boost/monotonic/vector.hpp>
-#include <boost/monotonic/list.hpp>
-#include <boost/monotonic/map.hpp>
-#include <boost/monotonic/set.hpp>
-
-#include <boost/timer.hpp>
-#include <boost/foreach.hpp>
-#include <iostream>
-
-#include <boost/range.hpp>
-#include <boost/iterator/counting_iterator.hpp>
-#include <boost/array.hpp>
-#include <boost/scoped_ptr.hpp>
-#include <boost/noncopyable.hpp>
-
-#include <boost/monotonic/chain.hpp>
-
-using namespace boost;
-using namespace std;
-
-void test_iter_range()
-{
- std::vector<int> v(10);
- boost::iter_range<std::vector<int> > r(v);
- *r = 10;
- *r++ = 10;
- //while (r)
- //{
- // *r++ = 10;
- //}
- boost::const_iter_range<std::vector<int> > c(r);
-}
-
-struct Foo : boost::noncopyable
-{
- int n;
- Foo(int N) : n(N) { }
-};
-
-void test_chain()
-{
- {
- monotonic::local<> storage;
- {
- monotonic::chain<int, 100> rope;
- for (int n = 0; n < 200; ++n)
- {
- rope.push_back(n);
- }
- }
- }
-
-
- monotonic::local<> storage;
- {
- typedef monotonic::chain<Foo, 2> Rope2;
- Rope2 foo(4);
-
- typedef monotonic::chain<int, 2> Rope;
- Rope rope;
- rope.push_back(0);
- rope.push_back(1);
- rope.push_back(2);
- rope.push_back(3);
-
- Rope::iterator A = rope.begin(), B = rope.end();
- for (; A != B; ++A)
- {
- *A *= 2;
- }
- Rope::iterator Q = rope.begin();
- *Q++ = 13;
-
- Rope::const_iterator C = rope.begin(), D = rope.end();
- for (; C != D; ++C)
- {
- cout << *C;
- }
-
- BOOST_FOREACH(int n, rope)
- {
- cout << n << endl;
- }
-
- BOOST_FOREACH(int &n, rope)
- {
- n *= 2;
- }
- BOOST_FOREACH(int n, rope)
- {
- cout << n << endl;
- }
-
-
- rope[0] = 0;
- rope[1] = 1;
- rope[2] = 2;
- rope[3] = 3;
- assert(*rope.begin() == 0);
- assert(rope.at(0) == 0);
- assert(rope.at(1) == 1);
- assert(rope.at(2) == 2);
- assert(rope.at(3) == 3);
- }
-}
-
-//EOF

Deleted: sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
+++ (empty file)
@@ -1,80 +0,0 @@
-
-template <class List>
-void test_bubble_sort_impl(size_t length, List &list)
-{
- for (size_t n = 0; n < length; ++n)
- list.push_back(length - n);
- bool swapped = false;
- do
- {
- swapped = false;
- typename List::iterator A = list.begin(), B = --list.end();
- for (--B; A != B; ++A)
- {
- typename List::iterator C = A;
- ++C;
- if (*A > *C)
- {
- std::swap(*A, *C);
- swapped = true;
- }
- }
- }
- while (swapped);
-}
-
-pair<double,double> test_bubble_sort(size_t count = 50*1000, size_t length = 20)
-{
- monotonic::local<> storage;
- boost::timer mono_timer;
- for (size_t n = 0; n < count; ++n)
- {
- {
- std::list<int, monotonic::allocator<int> > list;
- test_bubble_sort_impl(length, list);
- }
- storage.reset();
- }
- double mono_total = mono_timer.elapsed();
-
- boost::timer std_timer;
- for (size_t n = 0; n < count; ++n)
- {
- std::list<int> list;
- test_bubble_sort_impl(length, list);
- }
- double std_total = std_timer.elapsed();
- return make_pair(mono_total, std_total);
-}
-
-void graph_bubble_sort()
-{
- const size_t count = 50000;
- typedef std::map<size_t, pair<double, double> > Results;
- Results results;
- for (size_t length = 3; length < 150; length += 10)
- {
- results[length] = test_bubble_sort(count, length);
- }
- stringstream chart;
- chart << "http://chart.apis.google.com/chart?chco=FF0000,00FF00&chs=250x100&cht=lc&chd=t:";
- stringstream first;
- stringstream second;
- string comma = "";
- double m = 0;
- BOOST_FOREACH(Results::value_type const &result, results)
- {
- double mono_time = result.second.first;
- double std_time = result.second.second;
- double perc = mono_time/std_time;
- cout << result.first << '\t' << mono_time << '\t' << std_time << '\t' << perc << "%" << endl;
- first << comma << mono_time;
- second << comma << std_time;
- comma = ",";
- m = max(m, max(std_time, mono_time));
- }
- chart << first.str() << "|" << second.str() << "&chds=0," << m << ",0," << m;
- cout << chart.str() << endl;
-}
-
-//EOF

Deleted: sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
+++ (empty file)
@@ -1,16 +0,0 @@
-
-#include <boost/monotonic/storage.hpp>
-
-void test_chained_storage()
-{
- monotonic::local<monotonic::storage<0, 16> > store;
- {
- typedef std::vector<char, monotonic::allocator<char> > Vector;
- Vector vec;
- vec.resize(5); // still on the stack
- vec.resize(32); // now on the heap
- vec.resize(500); // now on the heap
- }
-}
-
-//EOF

Deleted: sandbox/monotonic/libs/monotonic/test/test_dupe.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_dupe.cpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
+++ (empty file)
@@ -1,43 +0,0 @@
-
-template <class List>
-size_t test_dupe_impl(size_t count, size_t size, List list)
-{
- size_t dummy = 0;
- fill_n(back_inserter(list), size, 42);
- for (size_t n = 0; n < count; ++n)
- {
- List dupe = list;
- dummy += dupe.size();
- }
- return dummy;
-}
-
-pair<double,double> test_dupe(size_t num_tests, size_t count, size_t size)
-{
- monotonic::local<> storage;
-
- boost::timer mono_timer;
- for (size_t n = 0; n < num_tests; ++n)
- {
- std::list<int, monotonic::allocator<int> > list;
- test_dupe_impl(count, size, list);
- storage.reset();
- }
- double mono_time = mono_timer.elapsed();
-
- boost::timer std_timer;
- for (size_t n = 0; n < num_tests; ++n)
- {
- std::list<int> list;
- test_dupe_impl(count, size, list);
- }
- double std_time = std_timer.elapsed();
- return make_pair(mono_time, std_time);
-}
-
-void test_dupe()
-{
- pair<double,double> results = test_dupe(10000, 100, 100);
- cout << "test_dupe: mono: " << results.first << endl;
- cout << "test_dupe: std: " << results.second << endl;
-}

Deleted: sandbox/monotonic/libs/monotonic/test/test_map_list.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_map_list.cpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
+++ (empty file)
@@ -1,110 +0,0 @@
-
-template <class Map>
-void test_map_list_impl(size_t count, Map &map)
-{
- typedef typename Map::mapped_type List;
- size_t mod = count/10;
- for (size_t n = 0; n < count; ++n)
- {
- int random = rand() % mod;
- map[random].push_back(n);
- }
- //BOOST_FOREACH(typename Map::value_type &val, map)
- //{
- // val.second.sort();
- //}
-}
-
-struct Result
-{
- double local;
- double standard;
- double static_monotonic;
-};
-
-Result test_map_list(size_t outter_loops, size_t inner_loops, monotonic::storage_base &storage)
-{
- typedef std::map<int, std::list<int> > Map;
- typedef std::map<int, std::list<int, monotonic::allocator<int> >, std::less<int>, monotonic::allocator<int> > MonoMap;
-
- Result result;
-
-
- // use monotonic allocator with supplied storage
- {
- boost::timer timer;
- for (size_t n = 0; n < outter_loops; ++n)
- {
- {
- MonoMap map;
- test_map_list_impl(inner_loops, map);
- }
- storage.reset();
- }
- result.local = timer.elapsed();
- }
-
- // use standard allocator
- {
- boost::timer timer;
- for (size_t n = 0; n < outter_loops; ++n)
- {
- {
- Map map;
- test_map_list_impl(inner_loops, map);
- }
- }
- result.standard = timer.elapsed();
- }
-
- // use static monotonic allocator
- {
- boost::timer timer;
- boost::monotonic::storage_base *current = &monotonic::get_storage();
- boost::monotonic::default_storage();
- for (size_t n = 0; n < outter_loops; ++n)
- {
- {
- MonoMap map;
- test_map_list_impl(inner_loops, map);
- }
- boost::monotonic::reset_storage();
- }
- boost::monotonic::set_storage(*current);
- result.static_monotonic = timer.elapsed();
- }
-
-
- cout << "test_map_list: " << inner_loops << ": " << result.local << ", " << result.static_monotonic << ", " << result.standard << endl;
- return result;
-}
-
-void test_map_list_heap_stack()
-{
- const size_t outter_loops = 10*1000;
- const size_t inner_loops = 10000;
-
- typedef std::map<size_t, Result > Results;
- Results results;
-
- monotonic::local<monotonic::storage<1000000, 0> > storage;
- for (size_t inner = 100; inner < inner_loops; inner += 1000)
- {
- results[inner] = test_map_list(outter_loops, inner, storage);
- }
-
- cout << "test_map_list" << endl;
- cout << "count\t" << "local\t" << "mono_static\t" << "std\t" << "std/local\t" << "std/mono_static" << endl;
- BOOST_FOREACH(Results::value_type const &iter, results)
- {
- Result const &result = iter.second;
- double mono_time = result.local;
- double std_time = result.standard;
- double static_time = result.static_monotonic;
- double perc1 = 100.*std_time/mono_time;
- double perc2 = 100.*std_time/static_time;
- cout << iter.first << '\t' << mono_time << '\t' << static_time << "\t\t" << std_time << '\t' << perc1 << "%\t" << perc2 << "%"<< endl;
- }
-}
-
-//EOF

Deleted: sandbox/monotonic/libs/monotonic/test/test_shared_storage.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_shared_storage.cpp 2009-06-21 03:35:04 EDT (Sun, 21 Jun 2009)
+++ (empty file)
@@ -1,8 +0,0 @@
-//#include <boost/monotonic/shared_storage.hpp>
-//
-void test_shared_storage()
-{
- // TODO!
-}
-//
-////EOF


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