|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53954 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-15 21:49:39
Author: cschladetsch
Date: 2009-06-15 21:49:37 EDT (Mon, 15 Jun 2009)
New Revision: 53954
URL: http://svn.boost.org/trac/boost/changeset/53954
Log:
changed test_map_list to use chained_storage
Text files modified:
sandbox/monotonic/boost/monotonic/allocator.h | 3 ++-
sandbox/monotonic/boost/monotonic/chained_storage.h | 4 +++-
sandbox/monotonic/libs/monotonic/test/main.cpp | 4 +++-
sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp | 6 ++++--
sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp | 7 ++++---
sandbox/monotonic/libs/monotonic/test/test_map_list.cpp | 11 +++++++----
6 files changed, 23 insertions(+), 12 deletions(-)
Modified: sandbox/monotonic/boost/monotonic/allocator.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/allocator.h (original)
+++ sandbox/monotonic/boost/monotonic/allocator.h 2009-06-15 21:49:37 EDT (Mon, 15 Jun 2009)
@@ -113,7 +113,8 @@
size_type max_size() const throw()
{
- BOOST_ASSERT(storage != 0);
+ if (!storage)
+ return 0;
return storage->max_size();
}
Modified: sandbox/monotonic/boost/monotonic/chained_storage.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/chained_storage.h (original)
+++ sandbox/monotonic/boost/monotonic/chained_storage.h 2009-06-15 21:49:37 EDT (Mon, 15 Jun 2009)
@@ -17,11 +17,13 @@
/// once that is exhausted, later requests are serviced from the heap.
///
/// all allocations remain valid at all times.
- template <size_t N, size_t MinLinkSize = N*2, class Al = std::allocator<char> >
+ template <size_t N, size_t MinLinkSize = N*1000, class Al = std::allocator<char> >
struct chained_storage : storage_base
{
typedef Al Allocator;
typedef typename Allocator::template rebind<char>::other CharAllocator;
+
+ /// a link in the chain of heap-based memory buffers
struct Link
{
size_t capacity, cursor;
Modified: sandbox/monotonic/libs/monotonic/test/main.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/main.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/main.cpp 2009-06-15 21:49:37 EDT (Mon, 15 Jun 2009)
@@ -12,7 +12,6 @@
#include <boost/iterator/counting_iterator.hpp>
-#include <boost/monotonic/chain.h>
#include <boost/timer.hpp>
#include <boost/foreach.hpp>
@@ -25,6 +24,9 @@
#include <boost/array.hpp>
#include <boost/scoped_ptr.hpp>
+#include <boost/monotonic/chain.h>
+#include <boost/monotonic/chained_storage.h>
+
template <class T
, size_t C = 64
, class Al = std::allocator<T>
Modified: sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp 2009-06-15 21:49:37 EDT (Mon, 15 Jun 2009)
@@ -30,8 +30,10 @@
boost::timer mono_timer;
for (size_t n = 0; n < count; ++n)
{
- std::list<int, monotonic::allocator<int> > list(storage);
- test_bubble_sort_impl(length, list);
+ {
+ std::list<int, monotonic::allocator<int> > list(storage);
+ test_bubble_sort_impl(length, list);
+ }
storage.reset();
}
double mono_total = mono_timer.elapsed();
Modified: sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp 2009-06-15 21:49:37 EDT (Mon, 15 Jun 2009)
@@ -5,9 +5,10 @@
{
monotonic::chained_storage<10> store;
{
- std::vector<char, monotonic::allocator<char> > vec(store);
- vec.resize(5);
- vec.resize(500);
+ typedef std::vector<char, monotonic::allocator<char> > Vector;
+ Vector vec(store);
+ vec.resize(5); // still on the stack
+ vec.resize(500); // now on the heap
}
}
Modified: sandbox/monotonic/libs/monotonic/test/test_map_list.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_map_list.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/test_map_list.cpp 2009-06-15 21:49:37 EDT (Mon, 15 Jun 2009)
@@ -24,9 +24,11 @@
boost::timer t0;
for (size_t n = 0; n < outter_loops; ++n)
{
- typedef std::map<int, std::list<int, monotonic::allocator<int> >, std::less<int>, monotonic::allocator<int> > Map;
- Map map(std::less<int>(), storage);
- test_map_list_impl(inner_loops, map);
+ {
+ typedef std::map<int, std::list<int, monotonic::allocator<int> >, std::less<int>, monotonic::allocator<int> > Map;
+ Map map(std::less<int>(), storage);
+ test_map_list_impl(inner_loops, map);
+ }
storage.reset();
}
double e0 = t0.elapsed();
@@ -49,11 +51,12 @@
const size_t outter_loops = 10*1000;
const size_t inner_loops = 10000;
- monotonic::storage<1000000> storage;
+ monotonic::chained_storage<1000> storage;
typedef std::map<size_t, pair<double, double> > Results;
Results results;
// do a test with a large dataset on the heap
+ if (0)
{
const size_t buffer_size = 10*1000*1000;
monotonic::storage<buffer_size> *storage = new monotonic::storage<buffer_size>;
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