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 
11 {
12  double cpuTime = double(System::cpuTime( System::microSec ) - m_startCpu );
14 
15  //== Change to normalized millisecond
16  cpuTime *= m_factor;
17  lastTime *= m_factor;
18 
19  //== Update the counter
20  m_num += 1;
21  m_sum += lastTime;
22  m_sumCpu += cpuTime;
23 
24  if ( 1 == m_num )
25  {
26  m_min = lastTime;
27  m_max = lastTime;
28  }
29  else
30  {
31  if ( lastTime < m_min ) m_min = lastTime;
32  if ( lastTime > m_max ) m_max = lastTime;
33  }
36  return lastTime;
37 }
38 
40 {
41  double ave = 0.;
42  double cpu = 0.;
43 
44  if ( 0 != m_num )
45  {
46  ave = m_sum / m_num;
47  cpu = m_sumCpu / m_num;
48  }
49 
50  return s << m_name.substr(0,m_size)
51  << format( "| %9.3f | %9.3f | %8.3f %9.1f | %7d | %9.3f |",
52  cpu, ave, m_min, m_max, m_num, m_sum * 0.001 );
53 }
54 
55 std::string TimerForSequencer::header( std::string::size_type size )
56 {
57  return "Algorithm" + std::string( std::max(std::string::size_type(21),size) - 20, ' ' )
58  + "(millisec) | <user> | <clock> |"
59  + " min max | entries | total (s) |";
60 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & fillStream(MsgStream &s) const
Write measured time into the message stream.
static std::string header(std::string::size_type size)
header matching the previous format
double stop()
Stop time measurement and return the last elapsed time.
GAUDI_API longlong currentTime(TimeType typ=milliSec)
Retrieve absolute system time.
Definition: Timing.cpp:79
double lastTime() const
returns the last measured time
string s
Definition: gaudirun.py:246
tuple cpu
Definition: ana.py:139
GAUDI_API longlong cpuTime(TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
Consumed CPU time of process in milliseconds.
Definition: Timing.cpp:168
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120