OGS
RunTime.h
Go to the documentation of this file.
1
15
#pragma once
16
17
#ifdef USE_PETSC
18
#include <mpi.h>
19
20
#include <limits>
21
#else
22
#include <chrono>
23
#endif
24
25
namespace
BaseLib
26
{
28
class
RunTime
29
{
30
public
:
32
void
start
()
33
{
34
#ifdef USE_PETSC
35
start_time_
= MPI_Wtime();
36
#else
37
start_time_
= std::chrono::system_clock::now();
38
#endif
39
}
40
42
double
elapsed
()
const
43
{
44
#ifdef USE_PETSC
45
return
MPI_Wtime() -
start_time_
;
46
#else
47
using namespace
std::chrono;
48
return
duration<double>(system_clock::now() -
start_time_
).count();
49
#endif
50
}
51
52
private
:
53
#ifdef USE_PETSC
54
double
start_time_
= std::numeric_limits<double>::quiet_NaN();
55
#else
56
std::chrono::time_point<std::chrono::system_clock>
start_time_
;
57
#endif
58
};
59
60
}
// end namespace BaseLib
BaseLib::RunTime
Count the running time.
Definition
RunTime.h:29
BaseLib::RunTime::elapsed
double elapsed() const
Get the elapsed time in seconds.
Definition
RunTime.h:42
BaseLib::RunTime::start_time_
double start_time_
Definition
RunTime.h:54
BaseLib::RunTime::start
void start()
Start the timer.
Definition
RunTime.h:32
BaseLib
Definition
TestDefinition.h:21
BaseLib
RunTime.h
Generated by
1.12.0