Newer
Older
* \author Wenqing Wang
* \date 2012-05-10, 2014-10.10
* \brief Definition of the RunTime class.
*
* \copyright
* Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
Tom Fischer
committed
*/
#ifndef RUNTIME_H
#define RUNTIME_H
#if defined(USE_MPI) || defined(USE_PETSC)
#include <mpi.h>
#else
#else
#include <windows.h>
#endif
Tom Fischer
committed
public:
/// Start the timer.
void start()
{
#if defined(USE_MPI) || defined(USE_PETSC)
_timer = -MPI_Wtime();
#else
#ifndef _MSC_VER
timeval t;
gettimeofday(&t, 0);
_timer = -t.tv_sec - t.tv_usec/1000000.0;
#else
_timer = -timeGetTime()/1000.0;
#endif
#endif
}
/// Get the epalsed time after started.
double elapsed()
{
#if defined(USE_MPI) || defined(USE_PETSC)
return _timer + MPI_Wtime();
#else
timeval t;
gettimeofday(&t, 0);
_timer += t.tv_sec + t.tv_usec/1000000.0;
return _timer;
return _timer + timeGetTime()/1000.0;
#endif
Tom Fischer
committed
} // end namespace BaseLib