The Gaudi Framework  v33r0 (d5ea422b)
TimerForSequencer.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef TIMERFORSEQUENCER_H
12 
13 # include "GaudiKernel/MsgStream.h"
14 # include "GaudiKernel/Timing.h"
15 # include <inttypes.h>
16 
31 
32 public:
34  TimerForSequencer( std::string name, unsigned int size, double factor )
35  : m_name( std::move( name ) ), m_size( size ), m_factor( factor ) {}
36 
37  ~TimerForSequencer() = default;
38 
40  inline void start() {
43  }
44 
48  uint64_t stop();
49 
51  inline const std::string& name() const { return m_name; }
52 
54  inline double lastTime() const { return m_lastTime * m_factor; }
55 
57  inline double lastCpu() const { return m_lastCpu * m_factor; }
58 
60  inline double elapsedTotal() const { return m_sum * m_factor; }
61 
63  inline double cpuTotal() const { return m_sumCpu * m_factor; }
64 
66  inline uint64_t count() const { return m_num; }
67 
69  MsgStream& fillStream( MsgStream& s ) const;
70 
72  static std::string header( std::string::size_type size );
73 
74 private:
76  unsigned int m_size;
77  double m_factor;
80 
81  uint64_t m_num = 0ULL;
84  uint64_t m_min = 0ULL;
85  uint64_t m_max = 0ULL;
86  uint64_t m_sum = 0ULL;
87  uint64_t m_sum2 = 0ULL;
89 };
90 
91 inline MsgStream& operator<<( MsgStream& ms, const TimerForSequencer& count ) { return count.fillStream( ms ); }
92 
93 #endif // TIMERFORSEQUENCER_H
constexpr auto size(const T &, Args &&...) noexcept
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:34
Auxiliary class.
static std::string header(std::string::size_type size)
header matching the previous format
double lastCpu() const
returns the last measured time
uint64_t count() const
Returns the number run count.
uint64_t stop()
Stop time measurement and return the last elapsed time.
const std::string & name() const
returns the name
STL namespace.
double cpuTotal() const
returns the toptal cpu time
unsigned long long uint64_t
Definition: instrset.h:143
void start()
Start a time measurement.
STL class.
double elapsedTotal() const
returns the total elapsed time
TimerForSequencer(std::string name, unsigned int size, double factor)
Constructor.
GAUDI_API long long currentTime()
Retrieve absolute system time.
Definition: Timing.h:260
MsgStream & operator<<(MsgStream &ms, const TimerForSequencer &count)
GAUDI_API long long cpuTime(TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
Consumed CPU time of process in milliseconds.
Definition: Timing.cpp:197
~TimerForSequencer()=default
string s
Definition: gaudirun.py:328
constexpr double ms
MsgStream & fillStream(MsgStream &s) const
Write measured time into the message stream.
double lastTime() const
returns the last measured time