Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60057 - in sandbox/statistics/detail/assign/libs/assign: doc test
From: erwann.rogard_at_[hidden]
Date: 2010-03-01 16:03:32


Author: e_r
Date: 2010-03-01 16:03:31 EST (Mon, 01 Mar 2010)
New Revision: 60057
URL: http://svn.boost.org/trac/boost/changeset/60057

Log:
m
Text files modified:
   sandbox/statistics/detail/assign/libs/assign/doc/speed2.txt | 59 +++++++++--------------
   sandbox/statistics/detail/assign/libs/assign/test/speed2.cpp | 99 +++++++++++++++++++++++++++++++++++++--
   sandbox/statistics/detail/assign/libs/assign/test/speed_common.cpp | 38 ++++++++++++++
   sandbox/statistics/detail/assign/libs/assign/test/speed_common.h | 14 +++++
   4 files changed, 165 insertions(+), 45 deletions(-)

Modified: sandbox/statistics/detail/assign/libs/assign/doc/speed2.txt
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/doc/speed2.txt (original)
+++ sandbox/statistics/detail/assign/libs/assign/doc/speed2.txt 2010-03-01 16:03:31 EST (Mon, 01 Mar 2010)
@@ -4,41 +4,30 @@
 
 2.4 GHz Intel Core 2 Duo - Mac OS Leopard 10.6 - x86_64 - Release mode - gcc 4.2
 
-cref_list_of(1) => 0.13 s
-
-cref_list_of_csv(1) => 0.25 s
-
-cref_list_of<>(1) => 0.00 s
-
-list_of(1) => 130.01 s
-
-
-cref_list_of(3) => 0.56 s
-
-cref_list_of_csv(3) => 1.41 s
-
-cref_list_of<>(3) => 0.39 s
-
-
-cref_list_of(10) => 2.10 s
-
-cref_list_of_csv(10) => 4.62 s
-
-cref_list_of<>(10) => 1.07 s
-
-
-cref_list_of(30) => 7.31 s
-
-cref_list_of_csv(30) => 14.58 s
-
-cref_list_of<>(30) => 4.03 s
-
-
-cref_list_of(90) => 25.62 s
-
-cref_list_of_csv(90) => 44.08 s
-
-cref_list_of<>(90) => 6.97 s
+cref_list_of(1) => 0.15 s
+cref_list_of_csv(1) => 0.33 s
+cref_list_of<>(1) => 0.00 s
+list_of(1) => 131.03 s
+
+cref_list_of(3) => 0.54 s
+cref_list_of_csv(3) => 1.45 s
+cref_list_of<>(3) => 0.37 s
+list_of(3) => 342.12 s
+
+cref_list_of(10) => 2.01 s
+cref_list_of_csv(10) => 3.53 s
+cref_list_of<>(10) => 1.05 s
+list_of(10) => 878.79 s
+
+cref_list_of(30) => 7.15 s
+cref_list_of_csv(30) => 9.63 s
+cref_list_of<>(30) => 4.16 s
+list_of(30) =>2475.13 s
+
+cref_list_of(90) => 25.68 s
+cref_list_of_csv(90) => 28.22 s
+cref_list_of<>(90) => 7.19 s
+list_of(90) =>7284.27 s
 
 Warning :
 For both compilers tested under Win7-32 below, a virtual machine was used so

Modified: sandbox/statistics/detail/assign/libs/assign/test/speed2.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/speed2.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/test/speed2.cpp 2010-03-01 16:03:31 EST (Mon, 01 Mar 2010)
@@ -22,8 +22,9 @@
 {
         os << "-> test_speed : " << std::endl;
     
- const int m = 100; // max size of vec
- const int n = 100 * 1000 * 1000; // number of loops
+ const int m = 100; // max size of vec
+ const int n = 100 * 1000 * 1000; // number of loops
+ const int f = 1000; // factor for list_of (else too slow)
 
         os << "Each arg is a vec of max size : " << m << std::endl;
         os << "Number of repeated function calls : " << n << std::endl;
@@ -120,8 +121,7 @@
         a88 = rand_vec(m),
         a89 = rand_vec(m);
 
- typedef boost::progress_timer timer_;
-
+ typedef boost::timer timer_;
     {
         int const N = 1;
         os << "cref_list_of(" << N << ") => ";
@@ -134,6 +134,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of_csv(" << N << ") => ";
         {
@@ -145,6 +146,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of<>(" << N << ") => ";
         {
@@ -156,18 +158,19 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
- // For N > 1, list_of is too slow to be included in this test.
         os << "list_of(" << N << ") => ";
         {
                          timer_ timer;
- for(int i = 0; i < n; ++i)
+ for(int i = 0; i < n/f; ++i)
             {
                 BOOST_AUTO(rng, boost::assign::list_of(a00));
                 int sz = (int)rng.size();
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() * f << " s" << std::endl;;
         }
     }
     {
@@ -182,6 +185,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of_csv(" << N << ") => ";
         {
@@ -193,6 +197,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of<>(" << N << ") => ";
         {
@@ -204,6 +209,19 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
+ }
+ os << "list_of(" << N << ") => ";
+ {
+ timer_ timer;
+ for(int i = 0; i < n/f; ++i)
+ {
+ BOOST_AUTO(rng, boost::assign::list_of(a00)(a01)(a02));
+ int sz = (int)rng.size();
+ if(sz != N)
+ os << "ERROR\n";
+ }
+ os << timer.elapsed() * f << " s" << std::endl;;
         }
     }
     
@@ -220,6 +238,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of_csv(" << N << ") => ";
         {
@@ -233,6 +252,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of<>(" << N << ") => ";
         {
@@ -246,6 +266,20 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
+ }
+ os << "list_of(" << N << ") => ";
+ {
+ timer_ timer;
+ for(int i = 0; i < n/f; ++i)
+ {
+ BOOST_AUTO(rng, boost::assign::list_of(a00)(a01)(a02)(a03)(a04)
+ (a05)(a06)(a07)(a08)(a09));
+ int sz = (int)rng.size();
+ if(sz != N)
+ os << "ERROR\n";
+ }
+ os << timer.elapsed() * f << " s" << std::endl;;
         }
     }
     {
@@ -265,6 +299,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of_csv(" << N << ") => ";
         {
@@ -282,6 +317,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of<>(" << N << ") => ";
         {
@@ -299,9 +335,26 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
+ }
+ os << "list_of(" << N << ") => ";
+ {
+ timer_ timer;
+ for(int i = 0; i < n/f; ++i)
+ {
+ BOOST_AUTO(rng, boost::assign::list_of(a00)(a01)(a02)(a03)(a04)
+ (a05)(a06)(a07)(a08)(a09)
+ (a10)(a11)(a12)(a13)(a14)
+ (a15)(a16)(a17)(a18)(a19)
+ (a20)(a21)(a22)(a23)(a24)
+ (a25)(a26)(a27)(a28)(a29));
+ int sz = (int)rng.size();
+ if(sz != N)
+ os << "ERROR\n";
+ }
+ os << timer.elapsed() * f << " s" << std::endl;;
         }
     }
-
     {
         int const N = 90;
         os << "cref_list_of(" << N << ") => ";
@@ -331,6 +384,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of_csv(" << N << ") => ";
         {
@@ -360,6 +414,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
         }
         os << "cref_list_of<>(" << N << ") => ";
         {
@@ -389,6 +444,36 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
+ os << timer.elapsed() << " s" << std::endl;;
+ }
+ os << "list_of(" << N << ") => ";
+ {
+ timer_ timer;
+ for(int i = 0; i < n/f; ++i)
+ {
+ BOOST_AUTO(rng, boost::assign::list_of(a00)(a01)(a02)(a03)(a04)
+ (a05)(a06)(a07)(a08)(a09)
+ (a10)(a11)(a12)(a13)(a14)
+ (a15)(a16)(a17)(a18)(a19)
+ (a20)(a21)(a22)(a23)(a24)
+ (a25)(a26)(a27)(a28)(a29)
+ (a30)(a31)(a32)(a33)(a34)
+ (a35)(a36)(a37)(a38)(a39)
+ (a40)(a41)(a42)(a43)(a44)
+ (a45)(a46)(a47)(a48)(a49)
+ (a50)(a51)(a52)(a53)(a54)
+ (a55)(a56)(a57)(a58)(a59)
+ (a60)(a61)(a62)(a63)(a64)
+ (a65)(a66)(a67)(a68)(a69)
+ (a70)(a71)(a72)(a73)(a74)
+ (a75)(a76)(a77)(a78)(a79)
+ (a80)(a81)(a82)(a83)(a84)
+ (a85)(a86)(a87)(a88)(a89));
+ int sz = (int)rng.size();
+ if(sz != N)
+ os << "ERROR\n";
+ }
+ os << timer.elapsed() * f << " s" << std::endl;;
         }
     }
 

Modified: sandbox/statistics/detail/assign/libs/assign/test/speed_common.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/speed_common.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/test/speed_common.cpp 2010-03-01 16:03:31 EST (Mon, 01 Mar 2010)
@@ -13,6 +13,7 @@
 #include <string>
 #include <vector>
 #include <iterator>
+#include <cstdlib>
 #include <boost/bind.hpp>
 #include <libs/assign/test/speed_common.h>
 
@@ -43,13 +44,13 @@
 rand_vec(int max_n)
 {
     std::vector<int> result(
- (std::size_t)rand(1, max_n)
+ (std::size_t)mpg::rand(1, max_n)
     );
     std::generate(
         result.begin(),
         result.end(),
         boost::bind(
- &rand,
+ &mpg::rand,
             0,
             20
         )
@@ -104,4 +105,37 @@
     }
 }
 
+namespace mpg
+{
+ inline double rand_dbl()
+ {
+ return double(::rand()) / RAND_MAX;
+ }
+
+ inline double rand_dbl(double M, double N)
+ {
+ return M + rand_dbl() * (N - M);
+ }
+
+ // http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx
+ inline int rand(int M, int N) // Range (M..N)
+ {
+ return int(M + std::rand() * ( 1.0 / ( RAND_MAX + 1.0 )) * (N - M));
+ }
+
+ inline char rand_letter()
+ {
+ return char(rand('a', 'z' + 1));
+ }
+
+ inline std::string rand_str(int len)
+ {
+ std::string result;
+ result.reserve(len);
+ for(int i = 0; i < len; ++i)
+ result.push_back(rand_letter());
+ return result;
+ }
+}
+
 

Modified: sandbox/statistics/detail/assign/libs/assign/test/speed_common.h
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/speed_common.h (original)
+++ sandbox/statistics/detail/assign/libs/assign/test/speed_common.h 2010-03-01 16:03:31 EST (Mon, 01 Mar 2010)
@@ -14,7 +14,7 @@
 #include <string>
 
 double uniform_deviate ( int seed );
-int rand(int M, int N);
+//int rand(int M, int N);
 char rand_letter();
 std::string rand_str(int len);
 std::vector<int> rand_vec(int);
@@ -37,6 +37,18 @@
     
     template<class Proc, class Result>
     double time_it(Proc proc, Result & result);
+
+ double rand_dbl();
+
+ double rand_dbl(double M, double N);
+
+ // http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx
+ int rand(int M, int N);
+
+ char rand_letter();
+
+ std::string rand_str(int len);
+
 }
 
 


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