Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55107 - in trunk/libs/spirit/benchmarks: . qi
From: joel_at_[hidden]
Date: 2009-07-22 23:01:17


Author: djowel
Date: 2009-07-22 23:01:16 EDT (Wed, 22 Jul 2009)
New Revision: 55107
URL: http://svn.boost.org/trac/boost/changeset/55107

Log:
made the report print the total accumulated time (not for one iteration which gives a very small number).
Text files modified:
   trunk/libs/spirit/benchmarks/boiler_plate.cpp | 4 +---
   trunk/libs/spirit/benchmarks/measure.hpp | 10 ++++++++--
   trunk/libs/spirit/benchmarks/qi/int_parser.cpp | 17 ++++-------------
   3 files changed, 13 insertions(+), 18 deletions(-)

Modified: trunk/libs/spirit/benchmarks/boiler_plate.cpp
==============================================================================
--- trunk/libs/spirit/benchmarks/boiler_plate.cpp (original)
+++ trunk/libs/spirit/benchmarks/boiler_plate.cpp 2009-07-22 23:01:16 EDT (Wed, 22 Jul 2009)
@@ -8,7 +8,7 @@
 
 namespace
 {
- struct f
+ struct f : test::base
     {
         void benchmark()
         {
@@ -16,8 +16,6 @@
                             // to benchmark. Make sure it returns something.
                             // Anything.
         }
-
- int val; // This is needed to avoid dead-code elimination
     };
 }
 

Modified: trunk/libs/spirit/benchmarks/measure.hpp
==============================================================================
--- trunk/libs/spirit/benchmarks/measure.hpp (original)
+++ trunk/libs/spirit/benchmarks/measure.hpp 2009-07-22 23:01:16 EDT (Wed, 22 Jul 2009)
@@ -86,8 +86,8 @@
 
         // Now start a timer
         util::high_resolution_timer time;
- hammer<Accumulator>(repeats); // This time, we'll measure
- return time.elapsed() / repeats; // return the time of one iteration
+ hammer<Accumulator>(repeats); // This time, we'll measure
+ return time.elapsed(); // return the elapsed time
     }
     
     template <class Accumulator>
@@ -104,6 +104,12 @@
         std::cout << std::flush << std::endl;
     }
     
+ struct base
+ {
+ base() : val(0) {}
+ int val; // This is needed to avoid dead-code elimination
+ };
+
 #define BOOST_SPIRIT_TEST_HAMMER(r, data, elem) \
     test::hammer<elem>(repeats);
     /***/

Modified: trunk/libs/spirit/benchmarks/qi/int_parser.cpp
==============================================================================
--- trunk/libs/spirit/benchmarks/qi/int_parser.cpp (original)
+++ trunk/libs/spirit/benchmarks/qi/int_parser.cpp 2009-07-22 23:01:16 EDT (Wed, 22 Jul 2009)
@@ -13,7 +13,7 @@
 namespace
 {
     ///////////////////////////////////////////////////////////////////////////
- // Random number string generator
+ // Generate a random number string with N digits
     std::string
     gen_int(int digits)
     {
@@ -32,33 +32,27 @@
     char const* last[9];
 
     ///////////////////////////////////////////////////////////////////////////
- struct atoi_test
+ struct atoi_test : test::base
     {
- atoi_test() : val(0) {}
         void benchmark()
         {
             for (int i = 0; i < 9; ++i)
                 this->val += atoi(first[i]);
         }
-
- int val; // This is needed to avoid dead-code elimination
     };
     
     ///////////////////////////////////////////////////////////////////////////
- struct strtol_test
+ struct strtol_test : test::base
     {
- strtol_test() : val(0) {}
         void benchmark()
         {
             for (int i = 0; i < 9; ++i)
                 this->val += strtol(first[i], const_cast<char**>(&last[i]), 10);
         }
-
- int val; // This is needed to avoid dead-code elimination
     };
     
     ///////////////////////////////////////////////////////////////////////////
- struct spirit_int_test
+ struct spirit_int_test : test::base
     {
         static int parse(char const* first, char const* last)
         {
@@ -69,7 +63,6 @@
             return n;
         }
 
- spirit_int_test() : val(0) {}
         void benchmark()
         {
             namespace qi = boost::spirit::qi;
@@ -78,8 +71,6 @@
             for (int i = 0; i < 9; ++i)
                 this->val += parse(first[i], last[i]);
         }
-
- int val; // This is needed to avoid dead-code elimination
     };
 }
 


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