OGS
RunTime.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2
// SPDX-License-Identifier: BSD-3-Clause
3
4
#pragma once
5
6
#ifdef USE_PETSC
7
#include <mpi.h>
8
9
#include <limits>
10
#else
11
#include <chrono>
12
#endif
13
14
namespace
BaseLib
15
{
17
class
RunTime
18
{
19
public
:
21
void
start
()
22
{
23
#ifdef USE_PETSC
24
start_time_
= MPI_Wtime();
25
#else
26
start_time_
= std::chrono::system_clock::now();
27
#endif
28
}
29
31
double
elapsed
()
const
32
{
33
#ifdef USE_PETSC
34
return
MPI_Wtime() -
start_time_
;
35
#else
36
using namespace
std::chrono;
37
return
duration<double>(system_clock::now() -
start_time_
).count();
38
#endif
39
}
40
41
private
:
42
#ifdef USE_PETSC
43
double
start_time_
= std::numeric_limits<double>::quiet_NaN();
44
#else
45
std::chrono::time_point<std::chrono::system_clock>
start_time_
;
46
#endif
47
};
48
49
}
// end namespace BaseLib
BaseLib::RunTime
Count the running time.
Definition
RunTime.h:18
BaseLib::RunTime::elapsed
double elapsed() const
Get the elapsed time in seconds.
Definition
RunTime.h:31
BaseLib::RunTime::start_time_
double start_time_
Definition
RunTime.h:43
BaseLib::RunTime::start
void start()
Start the timer.
Definition
RunTime.h:21
BaseLib
Definition
TestDefinition.h:13
BaseLib
RunTime.h
Generated by
1.14.0