Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74298 - in sandbox/endian/libs/endian/test: . msvc10/benchmark
From: bdawes_at_[hidden]
Date: 2011-09-07 14:43:27


Author: bemandawes
Date: 2011-09-07 14:43:26 EDT (Wed, 07 Sep 2011)
New Revision: 74298
URL: http://svn.boost.org/trac/boost/changeset/74298

Log:
Add option to build tests for two argument types
Text files modified:
   sandbox/endian/libs/endian/test/benchmark.cpp | 37 +++++++++++++++++++++++++++++++++++++
   sandbox/endian/libs/endian/test/msvc10/benchmark/benchmark.vcxproj | 2 +-
   2 files changed, 38 insertions(+), 1 deletions(-)

Modified: sandbox/endian/libs/endian/test/benchmark.cpp
==============================================================================
--- sandbox/endian/libs/endian/test/benchmark.cpp (original)
+++ sandbox/endian/libs/endian/test/benchmark.cpp 2011-09-07 14:43:26 EDT (Wed, 07 Sep 2011)
@@ -28,7 +28,11 @@
   int places = 2;
   bool verbose (false);
 
+#ifndef BOOST_TWO_ARG
   typedef int32_t (*timee_func)(int32_t);
+#else
+ typedef void (*timee_func)(int32_t, int32_t&);
+#endif
 
   endian::microsecond_t benchmark(timee_func timee, const char* msg,
     endian::microsecond_t overhead = 0)
@@ -42,7 +46,13 @@
                                                 
     for (long long i = n; i; --i)
     {
+# ifndef BOOST_TWO_ARG
       sum += timee(static_cast<int32_t>(i)) ;
+# else
+ int32_t y;
+ timee(static_cast<int32_t>(i), y);
+ sum += y;
+# endif
     }
     times = t.stop();
     cpu_time = (times.system + times.user) - overhead;
@@ -115,6 +125,12 @@
       | ((x >> 8) & 0x0000ff00);
   }
 
+ inline int32_t two_operand(int32_t x, int32_t& y)
+ {
+ return y = ((x << 24) & 0xff000000) | ((x << 8) & 0x00ff0000) | ((x >> 24) & 0x000000ff)
+ | ((x >> 8) & 0x0000ff00);
+ }
+
   int32_t modify_noop(int32_t x)
   {
     int32_t v(x);
@@ -134,6 +150,21 @@
     return by_return(v);
   }
 
+ void non_modify_assign(int32_t x, int32_t& y)
+ {
+ y = x;
+ }
+
+ void non_modify_two_operand(int32_t x, int32_t& y)
+ {
+ two_operand(x, y);
+ }
+
+ void non_modify_by_return(int32_t x, int32_t& y)
+ {
+ y = by_return(x);
+ }
+
 } // unnamed namespace
 
 //-------------------------------------- main() ---------------------------------------//
@@ -144,9 +175,15 @@
 
   endian::microsecond_t overhead;
 
+#ifndef BOOST_TWO_ARG
   overhead = benchmark(modify_noop, "modify no-op");
   benchmark(modify_in_place, "modify in place", overhead);
   benchmark(modify_by_return, "modify by return", overhead);
+#else
+ overhead = benchmark(non_modify_assign, "non_modify_assign ");
+ benchmark(non_modify_two_operand, "non_modify_two_operand", overhead);
+ benchmark(non_modify_by_return, "non_modify_by_return ", overhead);
+#endif
 
   return 0;
 }

Modified: sandbox/endian/libs/endian/test/msvc10/benchmark/benchmark.vcxproj
==============================================================================
--- sandbox/endian/libs/endian/test/msvc10/benchmark/benchmark.vcxproj (original)
+++ sandbox/endian/libs/endian/test/msvc10/benchmark/benchmark.vcxproj 2011-09-07 14:43:26 EDT (Wed, 07 Sep 2011)
@@ -70,7 +70,7 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>BOOST_TWO_ARG;BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <SubSystem>Console</SubSystem>


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