Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53926 - sandbox/monotonic/libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-15 03:39:17


Author: cschladetsch
Date: 2009-06-15 03:39:16 EDT (Mon, 15 Jun 2009)
New Revision: 53926
URL: http://svn.boost.org/trac/boost/changeset/53926

Log:
shifted bubble sort to separate file.
really need to add a jam file soon and fix up the mess in main.cpp

Text files modified:
   sandbox/monotonic/libs/monotonic/test/main.cpp | 78 +--------------------------------------
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj | 12 ++++++
   sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp | 13 ++++--
   3 files changed, 23 insertions(+), 80 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 03:39:16 EDT (Mon, 15 Jun 2009)
@@ -487,81 +487,6 @@
 void test_rope();
 void test_chain();
 
-template <class List>
-void test_bubble_sort_impl(size_t length, List &list)
-{
- for (size_t n = 0; n < length; ++n)
- list.push_back(length - n);
- bool swapped = false;
- do
- {
- swapped = false;
- typename List::iterator A = list.begin(), B = --list.end();
- for (--B; A != B; ++A)
- {
- typename List::iterator C = A;
- ++C;
- if (*A > *C)
- {
- std::swap(*A, *C);
- swapped = true;
- }
- }
- }
- while (swapped);
-}
-
-pair<double,double> test_bubble_sort(size_t count = 50*1000, size_t length = 20)
-{
- monotonic::inline_storage<100000> storage;
- 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);
- storage.reset();
- }
- double mono_total = mono_timer.elapsed();
- //cout << "mono bubble sort: " << 1000*1000*mono_total/count << "us" << endl;
-
- boost::timer std_timer;
- for (size_t n = 0; n < count; ++n)
- {
- std::list<int> list;
- test_bubble_sort_impl(length, list);
- }
- double std_total = std_timer.elapsed();
- //cout << "std bubble sort: " << 1000*1000*std_total/count << "us" << endl;
- return make_pair(mono_total, std_total);
-}
-
-void graph_bubble_sort()
-{
- const size_t count = 10000;
- typedef std::map<size_t, pair<double, double> > Results;
- Results results;
- for (size_t length = 3; length < 50; length += 10)
- {
- results[length] = test_bubble_sort(count, length);
- }
- stringstream chart;
- chart << "http://chart.apis.google.com/chart?chco=FF0000,00FF00&chs=250x100&cht=lc&chd=t:";
- stringstream first;
- stringstream second;
- string comma = "";
- double m = 0;
- BOOST_FOREACH(Results::value_type const &result, results)
- {
- cout << result.first << '\t' << result.second.first << '\t' << result.second.second << endl;
- first << comma << result.second.first;
- second << comma << result.second.second;
- comma = ",";
- m = max(m, max(result.second.first, result.second.second));
- }
- chart << first.str() << "|" << second.str() << "&chds=0," << m << ",0," << m;
- cout << chart.str() << endl;
-}
-
 /*
 
 http://chart.apis.google.com/chart?chco=FF0000,00FF00&chs=250x100&cht=lc&chd=t:0.001,0.028,0.092,0.188,0.317|0.009,0.054,0.121,0.24,0.376&chds=0,0.376,0,0.376
@@ -571,6 +496,9 @@
 http://chart.apis.google.com/chart?chco=FF0000,00FF00&chs=250x100&cht=lc&chd=t:0.001,0.029,0.087,0.19,0.315,0.483,0.696,0.929,1.198,1.488,1.809,2.227,2.725,3.019,3.523,3.997,4.538,5.221,5.704,6.405|0.009,0.048,0.118,0.233,0.372,0.561,0.753,1.007,1.298,1.595,1.922,2.396,2.774,3.175,3.65,4.128,5.021,5.283,5.975,6.537&chds=0,6.537,0,6.537
 
 */
+
+#include "test_bubble_sort.cpp"
+
 int main()
 {
         graph_bubble_sort();

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 03:39:16 EDT (Mon, 15 Jun 2009)
@@ -263,6 +263,18 @@
                         RelativePath=".\rope.cpp"
>
                 </File>
+ <File
+ RelativePath=".\test_bubble_sort.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 03:39:16 EDT (Mon, 15 Jun 2009)
@@ -49,7 +49,7 @@
         const size_t count = 10000;
         typedef std::map<size_t, pair<double, double> > Results;
         Results results;
- for (size_t length = 3; length < 50; length += 10)
+ for (size_t length = 3; length < 100; length += 10)
         {
                 results[length] = test_bubble_sort(count, length);
         }
@@ -61,11 +61,14 @@
         double m = 0;
         BOOST_FOREACH(Results::value_type const &result, results)
         {
- cout << result.first << '\t' << result.second.first << '\t' << result.second.second << endl;
- first << comma << result.second.first;
- second << comma << result.second.second;
+ 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;
+ first << comma << mono_time;
+ second << comma << std_time;
                 comma = ",";
- m = max(m, max(result.second.first, result.second.second));
+ m = max(m, max(std_time, mono_time));
         }
         chart << first.str() << "|" << second.str() << "&chds=0," << m << ",0," << m;
         cout << chart.str() << 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