DFT-EFE
 
Loading...
Searching...
No Matches
Timer.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Avirup Sircar
24 */
25
26#ifndef dftefeTimer_h
27#define dftefeTimer_h
28
29#include <utils/TypeConfig.h>
30#include <utils/MPITypes.h>
31#include <utils/MPIWrapper.h>
33#include <iostream>
34#include <string>
35#include <vector>
36#include <chrono>
37namespace dftefe
38{
39 namespace utils
40 {
41 class Timer
42 {
43 public:
44 using wallClockType = std::chrono::high_resolution_clock;
45
46 public:
48 const bool syncLapTimes = false);
49
52
55
56 void
58 const ConditionalOStream &stream = ConditionalOStream(std::cout)) const;
59
60 void
62 const ConditionalOStream &stream = ConditionalOStream(std::cout)) const;
63
64 void
65 start();
66
67 void
68 stop();
69
70 void
71 reset();
72
73 void
75
76 double
77 wallTime() const;
78
79 double
80 lastWallTime() const;
81
82 private:
83 template <class clockType>
85 {
86 using timePointType = typename clockType::time_point;
87
88 using durationType = typename clockType::duration;
89
91
93
95
97
98 void
99 reset();
100 };
101
103
105
107
109
111
113
114 }; // end of class Timer
115 } // end of namespace utils
116} // end of namespace dftefe
117#endif // dftefeTimer_h
Provides an interface to print based on whether a certain condition is met or not....
Definition: ConditionalOStream.h:45
Definition: Timer.h:42
void start()
Definition: Timer.cpp:124
ClockMeasurements< wallClockType > d_wallTimes
Definition: Timer.h:102
double lastWallTime() const
Definition: Timer.cpp:176
std::chrono::high_resolution_clock wallClockType
Definition: Timer.h:44
const utils::mpi::MinMaxAvg< double > & getLastLapWallTimeData() const
Definition: Timer.cpp:94
void reset()
Definition: Timer.cpp:182
utils::mpi::MinMaxAvg< double > d_lastLapWallTimeData
Definition: Timer.h:110
void printAccumulatedWallTimeData(const ConditionalOStream &stream=ConditionalOStream(std::cout)) const
Definition: Timer.cpp:115
bool d_syncLapTimes
Definition: Timer.h:108
bool d_running
Definition: Timer.h:104
double wallTime() const
Definition: Timer.cpp:162
utils::mpi::MinMaxAvg< double > d_accumulatedWallTimeData
Definition: Timer.h:112
const utils::mpi::MinMaxAvg< double > & getAccumulatedWallTimeData() const
Definition: Timer.cpp:100
void printLastLapWallTimeData(const ConditionalOStream &stream=ConditionalOStream(std::cout)) const
Definition: Timer.cpp:106
utils::mpi::MPIComm d_mpiComm
Definition: Timer.h:106
void stop()
Definition: Timer.cpp:135
int MPIComm
Definition: MPITypes.h:83
MPIComm MPICommSelf
Definition: MPITypes.cpp:155
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
durationType accumulatedTime
Definition: Timer.h:92
timePointType currentLapStartTime
Definition: Timer.h:90
durationType lastLapTime
Definition: Timer.h:94
typename clockType::duration durationType
Definition: Timer.h:88
typename clockType::time_point timePointType
Definition: Timer.h:86
ClockMeasurements()
Definition: Timer.cpp:69
void reset()
Definition: Timer.cpp:77
Definition: MPIWrapper.h:42