| The Gaudi Framework v32r1 (f65d50dc)

TimerForSequencer.h
Go to the documentation of this file.
1 #ifndef TIMERFORSEQUENCER_H
2
3 # include "GaudiKernel/MsgStream.h"
4 # include "GaudiKernel/Timing.h"
5 # include <inttypes.h>
6
20 class TimerForSequencer {
21
22 public:
24 TimerForSequencer( std::string name, unsigned int size, double factor )
25 : m_name( std::move( name ) ), m_size( size ), m_factor( factor ) {}
26
27 ~TimerForSequencer() = default;
28
30 inline void start() {
31 m_startClock = System::currentTime( System::microSec );
32 m_startCpu = System::cpuTime( System::microSec );
33 }
34
38 uint64_t stop();
39
41 inline const std::string& name() const { return m_name; }
42
44 inline double lastTime() const { return m_lastTime * m_factor; }
45
47 inline double lastCpu() const { return m_lastCpu * m_factor; }
48
50 inline double elapsedTotal() const { return m_sum * m_factor; }
51
53 inline double cpuTotal() const { return m_sumCpu * m_factor; }
54
56 inline uint64_t count() const { return m_num; }
57
59 MsgStream& fillStream( MsgStream& s ) const;
60
62 static std::string header( std::string::size_type size );
63
64 private:
65 std::string m_name;
66 unsigned int m_size;
67 double m_factor;
68 uint64_t m_startClock = 0ULL;
69 uint64_t m_startCpu = 0ULL;
70
71 uint64_t m_num = 0ULL;
72 uint64_t m_lastTime = 0ULL;
73 uint64_t m_lastCpu = 0ULL;
74 uint64_t m_min = 0ULL;
75 uint64_t m_max = 0ULL;
76 uint64_t m_sum = 0ULL;
77 uint64_t m_sum2 = 0ULL;
78 uint64_t m_sumCpu = 0ULL;
79 };
80
81 inline MsgStream& operator<<( MsgStream& ms, const TimerForSequencer& count ) { return count.fillStream( ms ); }
82
83 #endif // TIMERFORSEQUENCER_H
TimerForSequencer::m_lastCpu
uint64_t m_lastCpu
Definition: TimerForSequencer.h:73
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
TimerForSequencer
Auxiliary class.
Definition: TimerForSequencer.h:20
TimerForSequencer::header
static std::string header(std::string::size_type size)
header matching the previous format
Definition: TimerForSequencer.cpp:60
MsgStream.h
TimerForSequencer::lastCpu
double lastCpu() const
returns the last measured time
Definition: TimerForSequencer.h:47
TimerForSequencer::count
uint64_t count() const
Returns the number run count.
Definition: TimerForSequencer.h:56
TimerForSequencer::stop
uint64_t stop()
Stop time measurement and return the last elapsed time.
Definition: TimerForSequencer.cpp:10
TimerForSequencer::name
const std::string & name() const
returns the name
Definition: TimerForSequencer.h:41
std
STL namespace.
TimerForSequencer::cpuTotal
double cpuTotal() const
returns the toptal cpu time
Definition: TimerForSequencer.h:53
uint64_t
unsigned long long uint64_t
Definition: instrset.h:143
TimerForSequencer::start
void start()
Start a time measurement.
Definition: TimerForSequencer.h:30
TimerForSequencer::m_min
uint64_t m_min
Definition: TimerForSequencer.h:74
std::string
STL class.
TimerForSequencer::elapsedTotal
double elapsedTotal() const
returns the total elapsed time
Definition: TimerForSequencer.h:50
TimerForSequencer::m_startClock
uint64_t m_startClock
Definition: TimerForSequencer.h:68
TimerForSequencer::TimerForSequencer
TimerForSequencer(std::string name, unsigned int size, double factor)
Constructor.
Definition: TimerForSequencer.h:24
System::currentTime
GAUDI_API long long currentTime()
Retrieve absolute system time.
Definition: Timing.h:250
TimerForSequencer::m_factor
double m_factor
Definition: TimerForSequencer.h:67
TimerForSequencer::m_size
unsigned int m_size
Definition: TimerForSequencer.h:66
System::microSec
Definition: Timing.h:57
operator<<
MsgStream & operator<<(MsgStream &ms, const TimerForSequencer &count)
Definition: TimerForSequencer.h:81
System::cpuTime
GAUDI_API long long cpuTime(TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
Consumed CPU time of process in milliseconds.
Definition: Timing.cpp:186
TimerForSequencer::m_sum
uint64_t m_sum
Definition: TimerForSequencer.h:76
TimerForSequencer::m_sum2
uint64_t m_sum2
Definition: TimerForSequencer.h:77
Timing.h
TimerForSequencer::m_startCpu
uint64_t m_startCpu
Definition: TimerForSequencer.h:69
TimerForSequencer::m_max
uint64_t m_max
Definition: TimerForSequencer.h:75
TimerForSequencer::~TimerForSequencer
~TimerForSequencer()=default
gaudirun.s
string s
Definition: gaudirun.py:316
TimerForSequencer::m_lastTime
uint64_t m_lastTime
Definition: TimerForSequencer.h:72
TimerForSequencer::m_name
std::string m_name
Definition: TimerForSequencer.h:65
TimerForSequencer::m_num
uint64_t m_num
Definition: TimerForSequencer.h:71
TimerForSequencer::m_sumCpu
uint64_t m_sumCpu
Definition: TimerForSequencer.h:78
Gaudi::Units::ms
constexpr double ms
Definition: SystemOfUnits.h:134
TimerForSequencer::fillStream
MsgStream & fillStream(MsgStream &s) const
Write measured time into the message stream.
Definition: TimerForSequencer.cpp:34
TimerForSequencer::lastTime
double lastTime() const
returns the last measured time
Definition: TimerForSequencer.h:44