https://gitlab.opengeosys.org/ogs/ogs.git
Tip revision: 7a5ee81952dc36bf13e3d9b310fca4cf731a6aad authored by joergbuchwald on 07 December 2020, 13:07:48 UTC
Merge branch 'saturation_dependent_heat_conductivity' into 'master'
Merge branch 'saturation_dependent_heat_conductivity' into 'master'
Tip revision: 7a5ee81
RunTime.h
/**
* \file
* \author Thomas Fischer
* \author Wenqing Wang
* \date 2012-05-10, 2014-10.10
* \brief Definition of the RunTime class.
*
* \copyright
* Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*/
#pragma once
#ifdef USE_MPI
#include <mpi.h>
#else
#include <chrono>
#endif
namespace BaseLib
{
/// Count the running time.
class RunTime
{
public:
/// Start the timer.
void start()
{
#ifdef USE_MPI
_start_time = MPI_Wtime();
#else
_start_time = std::chrono::system_clock::now();
#endif
}
/// Get the elapsed time in seconds.
double elapsed() const
{
#ifdef USE_MPI
return MPI_Wtime() - _start_time;
#else
using namespace std::chrono;
return duration<double>(system_clock::now() - _start_time).count();
#endif
}
private:
#ifdef USE_MPI
double _start_time = std::numeric_limits<double>::quiet_NaN();
#else
std::chrono::time_point<std::chrono::system_clock> _start_time;
#endif
};
} // end namespace BaseLib