| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
10 uint64_t TimerForSequencer::stop() {
11 uint64_t cpuTime = System::cpuTime( System::microSec ) - m_startCpu ;
12 uint64_t lastTime = System::currentTime( System::microSec ) - m_startClock ;
13
14 //== Update the counter
15 m_num += 1ULL;
16 m_sum += lastTime;
17 m_sum2 += lastTime*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
25 m_min = lastTime < m_min ? lastTime : m_min;
26 m_max = lastTime > m_max ? lastTime : m_max;
27
28 m_lastTime = lastTime;
29 m_lastCpu = cpuTime;
30
31 return lastTime;
32 }
33
34 MsgStream & TimerForSequencer::fillStream(MsgStream & s) const
35 {
36 float ave = 0.f;
37 float cpu = 0.f;
38
39 if ( 0ULL != m_num ) {
40 ave = m_sum / m_num;
41 cpu = m_sumCpu / m_num;
42 }
43
44 ave *= m_factor;
45 cpu *= m_factor;
46 float min = m_min * m_factor;
47 float max = m_max * m_factor;
48 float sum = m_sum * m_factor;
49
50 // Calculate the sigma with 2 momenta. ROOT histos call this quantity
51 // RMS but just to be consistent with paw.
52 // The division is by N-1 since one degree of freedom is used to calculate
53 // the average. See your favourite book for the proof!
54 float sigma = m_num <= 1ULL
55 ? 0.f
56 : m_factor * sqrt( (m_sum2 - m_sum*m_sum/m_num)/(m_num-1) );
57
58 return s << m_name.substr(0, m_size)
59 << format( "| %9.3f | %9.3f | %8.3f %9.1f %8.2f | %7d | %9.3f |",
60 cpu, ave, min, max, sigma, m_num, sum * 0.001f );
61 }
62
63 std::string TimerForSequencer::header( std::string::size_type size )
64 {
65 return "Algorithm" + std::string( std::max(std::string::size_type(21),size) - 20, ' ' )
66 + "(millisec) | <user> | <clock> |"
67 + " min max sigma | entries | total (s) |";
68 }
69
TimerForSequencer::m_lastCpu
uint64_t m_lastCpu
Definition: TimerForSequencer.h:80
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
TimerForSequencer::fillStream
MsgStream & fillStream(MsgStream &s) const
Write measured time into the message stream.
Definition: TimerForSequencer.cpp:34
TimerForSequencer::header
static std::string header(std::string::size_type size)
header matching the previous format
Definition: TimerForSequencer.cpp:63
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
sum
double sum(double x, double y, double z)
Definition: 3DoubleFuncTest.cpp:25
TimerForSequencer::stop
uint64_t stop()
Stop time measurement and return the last elapsed time.
Definition: TimerForSequencer.cpp:10
uint64_t
unsigned long long uint64_t
Definition: instrset.h:144
System::cpuTime
GAUDI_API longlong cpuTime(TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
Consumed CPU time of process in milliseconds.
Definition: Timing.cpp:167
TimerForSequencer::m_min
uint64_t m_min
Definition: TimerForSequencer.h:81
std::string
STL class.
TimerForSequencer::m_startClock
uint64_t m_startClock
Definition: TimerForSequencer.h:75
TimerForSequencer::m_factor
double m_factor
Definition: TimerForSequencer.h:74
TimerForSequencer::m_size
unsigned int m_size
Definition: TimerForSequencer.h:73
System::microSec
Definition: Timing.h:57
TimerForSequencer.h
TimerForSequencer::lastTime
double lastTime() const
returns the last measured time
Definition: TimerForSequencer.h:51
System::currentTime
GAUDI_API longlong currentTime()
Retrieve absolute system time.
Definition: Timing.h:245
std::max
T max(T...args)
TimerForSequencer::m_sum
uint64_t m_sum
Definition: TimerForSequencer.h:83
TimerForSequencer::m_sum2
uint64_t m_sum2
Definition: TimerForSequencer.h:84
TimerForSequencer::m_startCpu
uint64_t m_startCpu
Definition: TimerForSequencer.h:76
TimerForSequencer::m_max
uint64_t m_max
Definition: TimerForSequencer.h:82
gaudirun.s
string s
Definition: gaudirun.py:245
TimerForSequencer::m_lastTime
uint64_t m_lastTime
Definition: TimerForSequencer.h:79
std::string::substr
T substr(T...args)
TimerForSequencer::m_name
std::string m_name
Definition: TimerForSequencer.h:72
TimerForSequencer::m_num
uint64_t m_num
Definition: TimerForSequencer.h:78
TimerForSequencer::m_sumCpu
uint64_t m_sumCpu
Definition: TimerForSequencer.h:85