Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54073 - sandbox/monotonic/libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-18 20:24:01


Author: cschladetsch
Date: 2009-06-18 20:24:00 EDT (Thu, 18 Jun 2009)
New Revision: 54073
URL: http://svn.boost.org/trac/boost/changeset/54073

Log:
added thrash_pool_iter
Text files modified:
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 67 ++++++++++++++++++++++++++-------------
   sandbox/monotonic/libs/monotonic/test/main.cpp | 8 ++++
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj | 2
   3 files changed, 54 insertions(+), 23 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 20:24:00 EDT (Thu, 18 Jun 2009)
@@ -1,5 +1,8 @@
+#include <ios>
+#include <iomanip>
 #include <list>
 #include <numeric>
+#include <vector>
 #include <boost/pool/pool.hpp>
 #include <boost/pool/pool_alloc.hpp>
 
@@ -25,6 +28,28 @@
         }
 };
 
+struct thrash_pool_iter
+{
+ struct Unaligned
+ {
+ int num;
+ char c;
+ };
+ template <class Pool>
+ int operator()(size_t length, Pool &pool) const
+ {
+ typedef typename Pool::allocator_type allocator;
+ std::vector<Unaligned, typename allocator::template rebind<Unaligned>::other> vec;
+ vec.resize(length);
+ int total = 0;
+ BOOST_FOREACH(Unaligned const &val, vec)
+ {
+ total += val.c;
+ }
+ return total;
+ }
+};
+
 struct PoolResult
 {
         double pool_elapsed;
@@ -34,10 +59,12 @@
         double std_elapsed;
         PoolResult()
         {
- pool_elapsed = fast_pool_elapsed = mono_elapsed = local_mono_elapsed = std_elapsed = 0;
+ pool_elapsed = fast_pool_elapsed = mono_elapsed = local_mono_elapsed = std_elapsed = -1;
         }
 };
 
+typedef std::map<size_t, PoolResult> PoolResults;
+
 template <class Fun>
 PoolResult compare_memory_pool(size_t count, size_t length, Fun fun)
 {
@@ -139,17 +166,10 @@
         return result;
 }
 
-typedef std::map<size_t, PoolResult> PoolResults;
-
 template <class Fun>
 PoolResults compare_memory_pool(size_t count, size_t max_length, size_t num_iterations, Fun fun)
 {
         PoolResults results;
- results[5] = compare_memory_pool(count*100, 5, fun);
- results[20] = compare_memory_pool(count*100, 20, fun);
- results[50] = compare_memory_pool(count*100, 50, fun);
- results[100] = compare_memory_pool(count*100, 100, fun);
-
         for (size_t length = 10; length < max_length; length += max_length/num_iterations)
         {
                 results[length] = compare_memory_pool(count, length, fun);
@@ -157,25 +177,28 @@
         return results;
 }
 
-void compare_memory_pool()
+void PrintResults(PoolResults const &results)
 {
- 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)
+ size_t w = 10;
+ cout << setw(0) << "count" << setw(w) << "fast_p" << setw(w) << "pool" << setw(w) << "std" << setw(w) << "mono" << setw(w) << "local" << setw(w) << "fp/mono" << setw(w) << "fp/local" << endl;
+ BOOST_FOREACH(PoolResults::value_type const &iter, results)
         {
                 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;
+ cout << setw(0) << setprecision(4) << iter.first << setw(w) <<result.fast_pool_elapsed << setw(w) << result.pool_elapsed << setw(w) << result.std_elapsed << setw(w) << result.mono_elapsed << setw(w) << result.local_mono_elapsed << setw(w) << 100.*result.fast_pool_elapsed/result.mono_elapsed << "%" << setw(w) << 100.*result.fast_pool_elapsed/result.local_mono_elapsed << "%" <<endl;
         }
- PoolResults r1 = compare_memory_pool(500, 500, 10, thrash_pool_sort());
+}
+
+void compare_memory_pool()
+{
+ cout << "thrash_pool_iter" << endl;
+ PrintResults(compare_memory_pool(50000, 1000, 10, thrash_pool_iter()));
+ cout << "thrash_pool" << endl;
+ PrintResults(compare_memory_pool(50000, 1000, 10, thrash_pool()));
         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;
- }
+ PrintResults(compare_memory_pool(1000, 500, 10, thrash_pool_sort()));
 }
 
 //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 20:24:00 EDT (Thu, 18 Jun 2009)
@@ -16,6 +16,7 @@
 #include <boost/monotonic/list.hpp>
 #include <boost/monotonic/map.hpp>
 #include <boost/monotonic/set.hpp>
+#include <boost/bind.hpp>
 
 #include <algorithm>
 #include <functional>
@@ -368,6 +369,13 @@
 
 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

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-18 20:24:00 EDT (Thu, 18 Jun 2009)
@@ -123,7 +123,7 @@
                                 EnableFunctionLevelLinking="true"
                                 UsePrecompiledHeader="0"
                                 WarningLevel="3"
- DebugInformationFormat="0"
+ DebugInformationFormat="3"
                         />
                         <Tool
                                 Name="VCManagedResourceCompilerTool"


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