This is an example of how to use the Teuchos::TimeMonitor class.
#include "Teuchos_Version.hpp"
#ifdef HAVE_MPI
#include <mpi.h>
#endif
RCP<Time> CompTime = TimeMonitor::getNewCounter(
"Computational Time");
RCP<Time> FactTime = TimeMonitor::getNewCounter(
"Factorial Time");
double quadFunc( double x );
double factFunc( int x );
int main(int argc, char* argv[])
{
std::cout << Teuchos::Teuchos_Version() << std::endl << std::endl;
int i;
double x;
#ifdef HAVE_MPI
MPI_Init(&argc, &argv);
#endif
for( i=-100; i<100; i++ ) {
x = quadFunc( (double) i );
(void)x;
}
for( i=0; i<100; i++ ) {
x = factFunc( i );
(void)x;
}
TimeMonitor::summarize();
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return 0;
}
double quadFunc( double x )
{
return ( x*x - 1.0 );
}
double factFunc( int x )
{
if( x == 0 ) return 0.0;
if( x == 1 ) return 1.0;
return ( (double) x * factFunc(x-1) );
}
Scope guard for Teuchos::Time, with MPI collective timer reporting.
Smart reference counting pointer class for automatic garbage collection.
Scope guard for Time, that can compute MPI collective timer statistics.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...