LDMX Software
Timer.cxx
1
2#include "Framework/Performance/Timer.h"
3
5
6namespace framework::performance {
7
9 begin_ = {};
10 end_ = {};
11 start_time_ = -1;
12 duration_ = -1;
13}
14
16 begin_ = clock::now();
17 start_time_ = std::chrono::duration_cast<std::chrono::nanoseconds>(
18 begin_.time_since_epoch())
19 .count();
20}
21
23 end_ = clock::now();
24 duration_ = std::chrono::duration<double>(end_ - begin_).count();
25}
26
27double Timer::duration() const { return duration_; }
28
29void Timer::write(TDirectory* location, const std::string& name) const {
30 location->WriteObject(this, name.c_str());
31}
32
33} // namespace framework::performance
Time how long a specific operation takes and serialize the result with ROOT.
Definition Timer.h:38
void reset()
reset a timer to un-started state without re-allocating
Definition Timer.cxx:8
void write(TDirectory *location, const std::string &name) const
Write ourselves under the input name to the input location.
Definition Timer.cxx:29
long int start_time_
Time stamp for when timer was started in nanoseconds since UNIX epoch.
Definition Timer.h:63
double duration_
Length of time recorded by the timer in seconds.
Definition Timer.h:74
void stop()
stop the timer
Definition Timer.cxx:22
double duration() const
retrieve the value of the duration in seconds
Definition Timer.cxx:27
void start()
start the timer
Definition Timer.cxx:15
std::chrono::time_point< clock > end_
The time_point when the timer is stopped.
Definition Timer.h:56
std::chrono::time_point< clock > begin_
The time_point when the timer is started.
Definition Timer.h:47