Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60801 - sandbox/odeint/libs/numeric/odeint/performance
From: karsten.ahnert_at_[hidden]
Date: 2010-03-24 03:55:00


Author: karsten
Date: 2010-03-24 03:54:59 EDT (Wed, 24 Mar 2010)
New Revision: 60801
URL: http://svn.boost.org/trac/boost/changeset/60801

Log:
added performance test const versus non const time
Added:
   sandbox/odeint/libs/numeric/odeint/performance/const_vs_nonconst_time.cpp (contents, props changed)
Text files modified:
   sandbox/odeint/libs/numeric/odeint/performance/Jamfile | 11 +++++++----
   1 files changed, 7 insertions(+), 4 deletions(-)

Modified: sandbox/odeint/libs/numeric/odeint/performance/Jamfile
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/performance/Jamfile (original)
+++ sandbox/odeint/libs/numeric/odeint/performance/Jamfile 2010-03-24 03:54:59 EDT (Wed, 24 Mar 2010)
@@ -6,10 +6,10 @@
 
 project
     : requirements
- <include>../../../../..
- <include>$BOOST_ROOT
- <include>$BLITZ_ROOT
- <include>$MTL4_ROOT
+ <include>../../../..
+ <include>$(BOOST_ROOT)
+ <include>$(BLITZ_ROOT)
+ <include>$(MTL4_ROOT)
       <define>BOOST_ALL_NO_LIB=1
     : build-dir .
     ;
@@ -25,3 +25,6 @@
 
 exe gsl_compare_lorenz :
     gsl_compare_lorenz.cpp libgsl libgslcblas ;
+
+exe const_vs_nonconst_time :
+ const_vs_nonconst_time.cpp ;

Added: sandbox/odeint/libs/numeric/odeint/performance/const_vs_nonconst_time.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/libs/numeric/odeint/performance/const_vs_nonconst_time.cpp 2010-03-24 03:54:59 EDT (Wed, 24 Mar 2010)
@@ -0,0 +1,89 @@
+#include <iostream>
+#include <algorithm>
+#include <vector>
+
+#include <boost/accumulators/accumulators.hpp>
+#include <boost/accumulators/statistics.hpp>
+#include <boost/timer.hpp>
+
+#include <boost/numeric/odeint.hpp>
+
+#define tab "\t"
+
+using namespace std;
+using namespace boost::accumulators;
+using namespace boost::numeric::odeint;
+
+typedef accumulator_set<
+ double , stats< tag::mean , tag::variance >
+ > accumulator_type;
+
+typedef boost::timer timer_type;
+
+ostream& operator<<( ostream& out , accumulator_type &acc )
+{
+ out << boost::accumulators::mean( acc ) << tab;
+// out << boost::accumulators::variance( acc ) << tab;
+ return out;
+}
+
+const size_t n = 3;
+const double dt = 0.01;
+
+typedef vector< double > state_type;
+typedef stepper_rk4< state_type > stepper_type;
+
+void lorenz( state_type &x , state_type &dxdt , double t )
+{
+ const double sigma = 10.0;
+ const double R = 28.0;
+ const double b = 8.0 / 3.0;
+
+ dxdt[0] = sigma * ( x[1] - x[0] );
+ dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
+ dxdt[2] = x[0]*x[1] - b * x[2];
+}
+
+
+
+int main( int argc , char **argv )
+{
+ const size_t num_of_steps = 1024 * 1024 * 16;
+ state_type x1( 3 , 0.0 ) , x2( 3 , 0.0 );
+ stepper_type stepper;
+ stepper.adjust_size( x1 );
+
+ x1[0] = x2[0] = 1.0;
+
+ accumulator_type acc1 , acc2;
+ timer_type timer;
+
+ size_t count = 0;
+ clog.precision(4);
+ while( true )
+ {
+ timer.restart();
+ double t1 = 0.0;
+ for( size_t i=0 ; i<num_of_steps ; ++i,t1+=dt )
+ stepper.do_step( lorenz , x1 , t1 , dt );
+ acc1( timer.elapsed() );
+
+ timer.restart();
+ for( size_t i=0 ; i<num_of_steps; ++i )
+ stepper.do_step( lorenz , x2 , 0.0 , dt );
+ acc2( timer.elapsed() );
+
+ if( x1[0] != x2[0] ) cerr << "Error!" << endl;
+
+ ++count;
+
+ clog << count << tab;
+ clog << acc1 << tab;
+ clog << acc2 << tab;
+
+ clog << endl;
+ }
+
+ return 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