Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54072 - sandbox/monotonic/libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-18 19:39:04


Author: cschladetsch
Date: 2009-06-18 19:39:04 EDT (Thu, 18 Jun 2009)
New Revision: 54072
URL: http://svn.boost.org/trac/boost/changeset/54072

Log:
better compare_pool
Text files modified:
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 28 +++++++++++++++-------------
   sandbox/monotonic/libs/monotonic/test/main.cpp | 7 +++++--
   2 files changed, 20 insertions(+), 15 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-18 19:39:04 EDT (Thu, 18 Jun 2009)
@@ -1,13 +1,15 @@
 #include <list>
+#include <numeric>
 #include <boost/pool/pool.hpp>
 #include <boost/pool/pool_alloc.hpp>
 
 struct thrash_pool
 {
         template <class Pool>
- void operator()(size_t length, Pool &pool) const
+ int operator()(size_t length, Pool &pool) const
         {
                 pool.resize(length*rand()/RAND_MAX);
+ return accumulate(pool.begin(), pool.end(), 0);
         }
 };
 
@@ -102,7 +104,7 @@
 
 
         // test local monotonic
- if (0)
+ if (1)
         {
                 srand(42);
                 monotonic::local<monotonic::storage<100000> > storage;
@@ -133,7 +135,7 @@
                 result.std_elapsed = timer.elapsed();
         }
 
- //cout << length << ": fast_pool, pool, std, mono, local: " << result.fast_pool_elapsed << ", " << result.pool_elapsed << ", " << result.std_elapsed << ", " << result.mono_elapsed << ", " << result.local_mono_elapsed << endl;
+ cout << length << ": fast_pool, pool, std, mono, local: " << result.fast_pool_elapsed << ", " << result.pool_elapsed << ", " << result.std_elapsed << ", " << result.mono_elapsed << ", " << result.local_mono_elapsed << endl;
         return result;
 }
 
@@ -157,8 +159,8 @@
 
 void compare_memory_pool()
 {
- size_t num_outter_loops = 1000;
- PoolResults r0 = compare_memory_pool(num_outter_loops, 20000, 10, thrash_pool());
+ size_t num_outter_loops = 50000;
+ PoolResults r0 = compare_memory_pool(num_outter_loops, 1000, 10, thrash_pool());
         cout << "thrash_pool" << endl;
         cout << "count\t" << "fast_p\t" << "pool\t" << "std\t" << "mono\t" << "fp/mono\t" << endl;
         BOOST_FOREACH(PoolResults::value_type const &iter, r0)
@@ -166,14 +168,14 @@
                 PoolResult const &result = iter.second;
                 cout << iter.first << '\t' << result.fast_pool_elapsed << '\t' << result.pool_elapsed << "\t" << result.std_elapsed << '\t' << result.mono_elapsed << '\t' << 100.*result.fast_pool_elapsed/result.mono_elapsed << "%\t" << endl;
         }
- //PoolResults r1 = compare_memory_pool(num_outter_loops, 1000, 10, thrash_pool_sort());
- //cout << "thrash_pool_sort" << endl;
- //cout << "count\t" << "fast_p\t" << "pool\t" << "std\t" << "mono\t" << "fp/mono\t" << endl;
- //BOOST_FOREACH(PoolResults::value_type const &iter, r1)
- //{
- // PoolResult const &result = iter.second;
- // cout << iter.first << '\t' << result.fast_pool_elapsed << '\t' << result.pool_elapsed << "\t" << result.std_elapsed << '\t' << result.mono_elapsed << '\t' << 100.*result.fast_pool_elapsed/result.mono_elapsed << "%\t" << endl;
- //}
+ PoolResults r1 = compare_memory_pool(500, 500, 10, thrash_pool_sort());
+ cout << "thrash_pool_sort" << endl;
+ cout << "count\t" << "fast_p\t" << "pool\t" << "std\t" << "mono\t" << "fp/mono\t" << endl;
+ BOOST_FOREACH(PoolResults::value_type const &iter, r1)
+ {
+ PoolResult const &result = iter.second;
+ cout << iter.first << '\t' << result.fast_pool_elapsed << '\t' << result.pool_elapsed << "\t" << result.std_elapsed << '\t' << result.mono_elapsed << '\t' << 100.*result.fast_pool_elapsed/result.mono_elapsed << "%\t" << endl;
+ }
 }
 
 //EOF

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-18 19:39:04 EDT (Thu, 18 Jun 2009)
@@ -17,6 +17,9 @@
 #include <boost/monotonic/map.hpp>
 #include <boost/monotonic/set.hpp>
 
+#include <algorithm>
+#include <functional>
+
 
 #include <boost/iterator/counting_iterator.hpp>
 
@@ -370,8 +373,8 @@
 #endif
 
         //test_chained_storage();
- test_map_list_heap_stack();
- //compare_memory_pool();
+ //test_map_list_heap_stack();
+ compare_memory_pool();
         //test_mono_map();
         //test_mono_map();
         //test_static_storage();


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