TimerForSequencer.cpp
Go to the documentation of this file.
1 
2 // local
3 #include "TimerForSequencer.h"
4 
5 //-----------------------------------------------------------------------------
6 // Implementation file for class : TimerForSequencer
7 //
8 // 2013-04-21 : Chris Jones
9 //-----------------------------------------------------------------------------
10 
12 {
13  double cpuTime = double(System::cpuTime( System::microSec ) - m_startCpu );
15 
16  //== Change to normalized millisecond
17  cpuTime *= m_factor;
18  lastTime *= m_factor;
19 
20  //== Update the counter
21  m_num += 1;
22  m_sum += lastTime;
23  m_sumCpu += cpuTime;
24 
25  if ( 1 == m_num )
26  {
27  m_min = lastTime;
28  m_max = lastTime;
29  }
30  else
31  {
32  if ( lastTime < m_min ) m_min = lastTime;
33  if ( lastTime > m_max ) m_max = lastTime;
34  }
37  return lastTime;
38 }
39 
41 {
42  double ave = 0.;
43  double cpu = 0.;
44 
45  if ( 0 != m_num )
46  {
47  ave = m_sum / m_num;
48  cpu = m_sumCpu / m_num;
49  }
50 
51  return s << m_name.substr(0,m_size)
52  << format( "| %9.3f | %9.3f | %8.3f %9.1f | %7d | %9.3f |",
53  cpu, ave, m_min, m_max, m_num, m_sum * 0.001 );
54 }
55 
56 std::string TimerForSequencer::header( std::string::size_type size )
57 {
58  if ( size < 21 ) size = 21;
59  const std::string blank( size - 20, ' ' );
60  const std::string s =
61  "Algorithm" + blank + "(millisec) | <user> | <clock> |" +
62  " min max | entries | total (s) |";
63  return s;
64 }
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:80
double lastTime() const
returns the last measured time
string s
Definition: gaudirun.py:244
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:169
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:133