The Gaudi Framework  v32r2 (46d42edc)
TimerForSequencer.cpp
Go to the documentation of this file.
1 // local
2 #include "TimerForSequencer.h"
3 
4 //-----------------------------------------------------------------------------
5 // Implementation file for class : TimerForSequencer
6 //
7 // 2013-04-21 : Chris Jones
8 //-----------------------------------------------------------------------------
9 
13 
14  //== Update the counter
15  m_num += 1ULL;
16  m_sum += lastTime;
18  m_sumCpu += cpuTime;
19 
20  // Branchless update, only cast
21  bool numIsFirst = ( 1ULL == m_num );
22  m_min += lastTime * numIsFirst;
23  m_max += lastTime * numIsFirst;
24 
27 
30 
31  return lastTime;
32 }
33 
35  float ave = 0.f;
36  float cpu = 0.f;
37 
38  if ( 0ULL != m_num ) {
39  ave = m_sum / m_num;
40  cpu = m_sumCpu / m_num;
41  }
42 
43  ave *= m_factor;
44  cpu *= m_factor;
45  float min = m_min * m_factor;
46  float max = m_max * m_factor;
47  float sum = m_sum * m_factor;
48 
49  // Calculate the sigma with 2 momenta. ROOT histos call this quantity
50  // RMS but just to be consistent with paw.
51  // The division is by N-1 since one degree of freedom is used to calculate
52  // the average. See your favourite book for the proof!
53  float sigma = m_num <= 1ULL ? 0.f : m_factor * sqrt( ( m_sum2 - m_sum * m_sum / m_num ) / ( m_num - 1 ) );
54 
55  return s << m_name.substr( 0, m_size )
56  << format( "| %9.3f | %9.3f | %8.3f %9.1f %8.2f | %7d | %9.3f |", cpu, ave, min, max, sigma, m_num,
57  sum * 0.001f );
58 }
59 
60 std::string TimerForSequencer::header( std::string::size_type size ) {
61  return "Algorithm" + std::string( std::max( std::string::size_type( 21 ), size ) - 20, ' ' ) +
62  "(millisec) | <user> | <clock> |" + " min max sigma | entries | total (s) |";
63 }
constexpr auto size(const T &, Args &&...) noexcept
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
static std::string header(std::string::size_type size)
header matching the previous format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
uint64_t stop()
Stop time measurement and return the last elapsed time.
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:202
unsigned long long uint64_t
Definition: instrset.h:143
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:215
STL class.
GAUDI_API long long currentTime()
Retrieve absolute system time.
Definition: Timing.h:250
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
T max(T... args)
auto sqrt(std::chrono::duration< Rep, Period > d)
sqrt for std::chrono::duration
Definition: Counters.h:28
string s
Definition: gaudirun.py:318
T substr(T... args)
MsgStream & fillStream(MsgStream &s) const
Write measured time into the message stream.
double lastTime() const
returns the last measured time