Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59462 - sandbox/statistics/detail/assign/libs/assign/example
From: erwann.rogard_at_[hidden]
Date: 2010-02-03 22:23:19


Author: e_r
Date: 2010-02-03 22:23:18 EST (Wed, 03 Feb 2010)
New Revision: 59462
URL: http://svn.boost.org/trac/boost/changeset/59462

Log:
m
Text files modified:
   sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp | 58 +++++++++++++++++++++++++++++----------
   1 files changed, 43 insertions(+), 15 deletions(-)

Modified: sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp 2010-02-03 22:23:18 EST (Wed, 03 Feb 2010)
@@ -6,6 +6,7 @@
 // Boost Software License, Version 1.0. (See accompanying file //
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
 //////////////////////////////////////////////////////////////////////////////
+#include <boost/timer.hpp>
 #include <iostream>
 #include <vector>
 #include <boost/assign/list_of.hpp>
@@ -18,21 +19,48 @@
         using namespace boost::assign;
     
           typedef std::vector<int> ints_;
-
- int a=1,b=2;
-
- ints_ ints;
-
- ints = cref_list_of<3>(a)(b)(3);
- BOOST_ASSERT(ints[0] == a);
- BOOST_ASSERT(ints[1] == b);
- BOOST_ASSERT(ints[2] == 3);
- ints.clear();
- ints = cref_list_of2(a)(b)(3);
- BOOST_ASSERT(ints[0] == a);
- BOOST_ASSERT(ints[1] == b);
- BOOST_ASSERT(ints[2] == 3);
-
+
+ {
+ int a=1,b=2;
+ ints_ ints;
+
+ ints = cref_list_of<3>(a)(b)(3);
+ BOOST_ASSERT(ints[0] == a);
+ BOOST_ASSERT(ints[1] == b);
+ BOOST_ASSERT(ints[2] == 3);
+ ints.clear();
+ ints = cref_list_of2(a)(b)(3);
+ BOOST_ASSERT(ints[0] == a);
+ BOOST_ASSERT(ints[1] == b);
+ BOOST_ASSERT(ints[2] == 3);
+ }
+ {
+ const int n = 100 * 1000;
+ typedef std::vector<ints_> vec_ints_;
+ ints_ a( n );
+ ints_ b( n );
+ boost::timer t;
+
+ {
+ t.restart();
+ vec_ints_ vec_ints = cref_list_of<3>( a )( b )( ints_( n ) );
+ double t_val = t.elapsed();
+ os << "cref_list_of : t = " << t_val << std::endl;
+ BOOST_ASSERT(vec_ints[0] == a);
+ BOOST_ASSERT(vec_ints[1] == b);
+ BOOST_ASSERT(vec_ints[2] == ints_( n ));
+ }
+ {
+ t.restart();
+ vec_ints_ vec_ints = cref_list_of2( a )( b )( ints_( n ) );
+ double t_val = t.elapsed();
+ os << "cref_list_of2 : t = " << t_val << std::endl;
+ BOOST_ASSERT(vec_ints[0] == a);
+ BOOST_ASSERT(vec_ints[1] == b);
+ BOOST_ASSERT(vec_ints[2] == ints_( n ));
+ }
+ }
+
         os << "<- " << std::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