Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53950 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-15 19:34:29


Author: cschladetsch
Date: 2009-06-15 19:34:27 EDT (Mon, 15 Jun 2009)
New Revision: 53950
URL: http://svn.boost.org/trac/boost/changeset/53950

Log:
test_map_list now produces a table for different inner_loop lengths

Text files modified:
   sandbox/monotonic/boost/monotonic/storage_base.h | 1
   sandbox/monotonic/libs/monotonic/test/main.cpp | 2
   sandbox/monotonic/libs/monotonic/test/test_map_list.cpp | 48 ++++++++++++++++++++++++++++++++-------
   3 files changed, 41 insertions(+), 10 deletions(-)

Modified: sandbox/monotonic/boost/monotonic/storage_base.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage_base.h (original)
+++ sandbox/monotonic/boost/monotonic/storage_base.h 2009-06-15 19:34:27 EDT (Mon, 15 Jun 2009)
@@ -18,6 +18,7 @@
                         virtual void deallocate(void *base, size_t num_bytes) = 0;
                         virtual size_t max_size() const = 0;
                         virtual size_t remaining() const = 0;
+ virtual void reset() = 0;
                 };
         }
 }

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 19:34:27 EDT (Mon, 15 Jun 2009)
@@ -422,7 +422,7 @@
 
 int main()
 {
- test_map_list();
+ test_map_list_heap_stack();
         test_dupe();
         //graph_bubble_sort();
         //test_bubble_sort();

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 19:34:27 EDT (Mon, 15 Jun 2009)
@@ -19,22 +19,17 @@
         }
 }
 
-void test_map_list()
+pair<double,double> test_map_list(size_t outter_loops, size_t inner_loops, monotonic::storage_base &storage)
 {
- monotonic::storage<1000000> storage;// = new monotonic::storage<10000000>;
- const size_t outter_loops = 10*1000;
- const size_t inner_loops = 10000;
-
         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);
- storage.reset(); ///<<< reset the memory usage to zero
+ storage.reset();
         }
         double e0 = t0.elapsed();
- cout << "test_map_list: mono: " << e0 << endl;
 
         boost::timer t1;
         for (size_t n = 0; n < outter_loops; ++n)
@@ -44,8 +39,43 @@
                 test_map_list_impl(inner_loops, map);
         }
         double e1 = t1.elapsed();
- cout << "test_map_list: std: " << e1 << endl;
- //delete storage;
+
+ cout << "test_map_list: " << inner_loops << ": " << e0 << ", " << e1 << endl;
+ return make_pair(e0, e1);
+}
+
+void test_map_list_heap_stack()
+{
+ const size_t outter_loops = 10*1000;
+ const size_t inner_loops = 10000;
+
+ monotonic::storage<1000000> storage;
+ typedef std::map<size_t, pair<double, double> > Results;
+ Results results;
+ for (size_t inner = 100; inner < inner_loops; inner += 1000)
+ {
+ results[inner] = test_map_list(outter_loops, inner, storage);
+ }
+ cout << "test_map_list" << endl;
+ 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;
+ }
+
+ //cout << "stack:" << endl;
+ //{
+ // test_map_list(outter_loops, inner_loops, storage);
+ //}
+
+ //cout << "heap:" << endl;
+ //{
+ // monotonic::storage<1000000> *storage = new monotonic::storage<1000000>;
+ // test_map_list(outter_loops, inner_loops, *storage);
+ // delete storage;
+ //}
 }
 
 //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