Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55068 - trunk/libs/spirit/benchmarks
From: joel_at_[hidden]
Date: 2009-07-21 12:45:39


Author: djowel
Date: 2009-07-21 12:45:39 EDT (Tue, 21 Jul 2009)
New Revision: 55068
URL: http://svn.boost.org/trac/boost/changeset/55068

Log:
updates
Text files modified:
   trunk/libs/spirit/benchmarks/boiler_plate.cpp | 2
   trunk/libs/spirit/benchmarks/measure.hpp | 41 ++++++++++++++++-----------------------
   2 files changed, 18 insertions(+), 25 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-21 12:45:39 EDT (Tue, 21 Jul 2009)
@@ -28,7 +28,7 @@
 {
     int result;
     double base_time;
- int ret = test::benchmark<f>::test(result, base_time);
+ int ret = test::run<f>(result, base_time, 100);
 
     std::cout
         << "f accumulated result: "

Modified: trunk/libs/spirit/benchmarks/measure.hpp
==============================================================================
--- trunk/libs/spirit/benchmarks/measure.hpp (original)
+++ trunk/libs/spirit/benchmarks/measure.hpp 2009-07-21 12:45:39 EDT (Tue, 21 Jul 2009)
@@ -90,32 +90,25 @@
         return time.elapsed() / repeats; // return the time of one iteration
     }
   
- template <typename Accumulator, int Repeats = 100>
- struct benchmark
+ template <typename Accumulator>
+ static int run(typename Accumulator::type& result, double& base_time, long repeats = 100)
     {
- static int test(typename Accumulator::type& result, double& base_time)
+ double measured = 0;
+ while (measured < 2.0 && repeats <= 10000000)
         {
- std::cout.setf(std::ios::scientific);
-
- // first decide how many repetitions to measure
- long repeats = Repeats;
- double measured = 0;
- while (measured < 2.0 && repeats <= 10000000)
- {
- repeats *= 10;
- util::high_resolution_timer time;
- test::hammer<Accumulator>(0, repeats);
- measured = time.elapsed();
- }
+ repeats *= 10;
+ util::high_resolution_timer time;
+ test::hammer<Accumulator>(0, repeats);
+ measured = time.elapsed();
+ }
 
- test::measure<Accumulator>(1, 1);
- result = test::live_code;
- base_time = test::measure<Accumulator>(1, repeats);
+ test::measure<Accumulator>(1, 1);
+ result = test::live_code;
+ base_time = test::measure<Accumulator>(1, repeats);
 
- // This is ultimately responsible for preventing all the test code
- // from being optimized away. Change this to return 0 and you
- // unplug the whole test's life support system.
- return test::live_code != 0;
- }
- };
+ // This is ultimately responsible for preventing all the test code
+ // from being optimized away. Change this to return 0 and you
+ // unplug the whole test's life support system.
+ return test::live_code != 0;
+ }
 }


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