Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53929 - sandbox/monotonic/libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-15 05:47:55


Author: cschladetsch
Date: 2009-06-15 05:47:54 EDT (Mon, 15 Jun 2009)
New Revision: 53929
URL: http://svn.boost.org/trac/boost/changeset/53929

Log:
added test_dupe

Added:
   sandbox/monotonic/libs/monotonic/test/test_dupe.cpp (contents, props changed)
Text files modified:
   sandbox/monotonic/libs/monotonic/test/main.cpp | 4 +++-
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj | 12 ++++++++++++
   sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp | 8 +++++---
   3 files changed, 20 insertions(+), 4 deletions(-)

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 05:47:54 EDT (Mon, 15 Jun 2009)
@@ -498,10 +498,12 @@
 */
 
 #include "test_bubble_sort.cpp"
+#include "test_dupe.cpp"
 
 int main()
 {
- graph_bubble_sort();
+ test_dupe();
+ //graph_bubble_sort();
         //test_bubble_sort();
         //test_map_list_realtime();
         return 0;

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-15 05:47:54 EDT (Mon, 15 Jun 2009)
@@ -275,6 +275,18 @@
                                 />
                         </FileConfiguration>
                 </File>
+ <File
+ RelativePath=".\test_dupe.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
         </Files>
         <Globals>
         </Globals>

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 05:47:54 EDT (Mon, 15 Jun 2009)
@@ -1,3 +1,4 @@
+
 template <class List>
 void test_bubble_sort_impl(size_t length, List &list)
 {
@@ -17,6 +18,7 @@
                                 std::swap(*A, *C);
                                 swapped = true;
                         }
+
                 }
         }
         while (swapped);
@@ -24,7 +26,7 @@
 
 pair<double,double> test_bubble_sort(size_t count = 50*1000, size_t length = 20)
 {
- monotonic::inline_storage<100000> storage;
+ monotonic::inline_storage<100000> storage;// = new monotonic::inline_storage<100000>();
         boost::timer mono_timer;
         for (size_t n = 0; n < count; ++n)
         {
@@ -46,10 +48,10 @@
 
 void graph_bubble_sort()
 {
- const size_t count = 10000;
+ const size_t count = 50000;
         typedef std::map<size_t, pair<double, double> > Results;
         Results results;
- for (size_t length = 3; length < 100; length += 10)
+ for (size_t length = 3; length < 150; length += 10)
         {
                 results[length] = test_bubble_sort(count, length);
         }

Added: sandbox/monotonic/libs/monotonic/test/test_dupe.cpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/libs/monotonic/test/test_dupe.cpp 2009-06-15 05:47:54 EDT (Mon, 15 Jun 2009)
@@ -0,0 +1,43 @@
+
+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::inline_storage<1000000> storage;
+
+ boost::timer mono_timer;
+ for (size_t n = 0; n < num_tests; ++n)
+ {
+ std::list<int, monotonic::allocator<int> > list(storage);
+ 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;
+}


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