Gaudi Framework, version v23r6
Home
Generated: Wed Jan 30 2013
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
GaudiAlg
src
components
TimerForSequencer.h
Go to the documentation of this file.
1
// $Id: TimerForSequencer.h,v 1.5 2004/11/25 13:26:26 mato Exp $
2
#ifndef TIMERFORSEQUENCER_H
3
4
#include "
GaudiKernel/MsgStream.h
"
5
#include "
GaudiKernel/Timing.h
"
6
14
class
TimerForSequencer
{
15
16
public
:
19
TimerForSequencer
(
std::string
name
,
double
factor ) {
20
m_name
=
name
;
21
m_num
= 0L;
22
m_min
= 0.;
23
m_max
= 0.;
24
m_sum
= 0.;
25
m_sumCpu
= 0.;
26
m_factor
= factor;
27
m_lastTime
= 0.;
28
m_lastCpu
= 0.;
29
m_startClock
= 0LL;
30
m_startCpu
= 0LL;
31
}
32
33
~TimerForSequencer
() {};
34
36
void
start
() {
37
m_startClock
=
System::currentTime
(
System::microSec
);
38
m_startCpu
=
System::cpuTime
(
System::microSec
);
39
}
40
44
double
stop
() {
45
double
cpuTime
= double(
System::cpuTime
(
System::microSec
) -
m_startCpu
);
46
double
lastTime
= double(
System::currentTime
(
System::microSec
) -
m_startClock
);
47
48
//== Change to normalized millisecond
49
cpuTime *=
m_factor
;
50
lastTime *=
m_factor
;
51
52
//== Update the counter
53
m_num
+= 1;
54
m_sum
+=
lastTime
;
55
m_sumCpu
+=
cpuTime
;
56
57
if
( 1 ==
m_num
) {
58
m_min
=
lastTime
;
59
m_max
=
lastTime
;
60
}
else
{
61
if
( lastTime <
m_min
)
m_min
=
lastTime
;
62
if
( lastTime >
m_max
)
m_max
=
lastTime
;
63
}
64
m_lastTime
=
lastTime
;
65
m_lastCpu
=
cpuTime
;
66
return
lastTime
;
67
}
68
70
std::string
name
()
const
{
return
m_name
; }
71
73
double
lastTime
()
const
{
return
m_lastTime
; }
74
76
double
lastCpu
()
const
{
return
m_lastCpu
; }
77
79
double
elapsedTotal
()
80
{
81
return
m_sum
;
82
}
83
85
double
cpuTotal
()
86
{
87
return
m_sumCpu
;
88
}
89
91
double
count
()
92
{
93
return
m_num
;
94
}
95
97
MsgStream
&
fillStream
(
MsgStream
&
s
)
const
{
98
double
ave = 0.;
99
double
cpu
= 0.;
100
101
if
( 0 !=
m_num
) {
102
ave =
m_sum
/
m_num
;
103
cpu =
m_sumCpu
/
m_num
;
104
}
105
106
return
s <<
m_name
107
<<
format
(
"| %9.3f | %9.3f | %8.3f %9.1f | %7d | %9.3f |"
,
108
cpu, ave,
m_min
,
m_max
,
m_num
,
m_sum
* 0.001 );
109
}
110
112
static
std::string
header
(
std::string::size_type
size ) {
113
if
( size < 21 ) size = 21;
114
std::string
blank( size - 20,
' '
);
115
std::string
s
=
"Algorithm"
+ blank +
"(millisec) | <user> | <clock> |"
;
116
s +=
" min max | entries | total (s) |"
;
117
return
s
;
118
}
119
120
private
:
121
std::string
m_name
;
122
double
m_factor
;
123
longlong
m_startClock
;
124
longlong
m_startCpu
;
125
126
long
m_num
;
127
double
m_lastTime
;
128
double
m_lastCpu
;
129
double
m_min
;
130
double
m_max
;
131
double
m_sum
;
132
double
m_sumCpu
;
133
};
134
135
inline
MsgStream
&
operator<<
(
MsgStream
&
ms
,
const
TimerForSequencer
& count) {
136
return
count.
fillStream
( ms );
137
}
138
139
#endif // TIMERFORSEQUENCER_H
Generated at Wed Jan 30 2013 17:13:37 for Gaudi Framework, version v23r6 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004