BmnRoot
26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
L1Timer.h
Go to the documentation of this file.
1
#ifndef _L1Timer_H
2
#define _L1Timer_H
3
4
/*
5
*=====================================================
6
*
7
* Authors: I.Kulakov
8
*
9
*/
10
11
#include "
TStopwatch.h
"
12
13
#include <iomanip>
14
#include <iostream>
15
#include <string>
16
#include <vector>
17
18
using
std::cout;
19
using
std::endl;
20
using
std::ios;
21
using
std::setw;
22
using
std::string;
23
using
std::vector;
24
25
class
TimerInfo
26
{
27
public
:
28
TimerInfo
()
29
:
fName
(
""
)
30
,
fReal
(0.)
31
,
fCpu
(0.) {};
32
TimerInfo
(
const
string
& name)
33
:
fName
(name)
34
,
fReal
(0.)
35
,
fCpu
(0.) {};
36
37
void
operator=
(
TStopwatch
& sw)
38
{
39
fReal
= sw.
RealTime
();
40
fCpu
= sw.
CpuTime
();
41
};
42
void
operator+=
(
TStopwatch
& sw)
43
{
44
fReal
+= sw.
RealTime
();
45
fCpu
+= sw.
CpuTime
();
46
};
47
void
operator+=
(
const
TimerInfo
& t)
48
{
49
fReal
+= t.
fReal
;
50
fCpu
+= t.
fCpu
;
51
}
52
TimerInfo
operator/
(
const
float
f)
const
53
{
54
TimerInfo
r;
55
r.
fName
=
fName
;
56
r.
fReal
=
fReal
/ f;
57
r.
fCpu
=
fCpu
/ f;
58
return
r;
59
}
60
61
// void Print(){ cout << fReal << "/" << fCpu; };
62
void
PrintReal
() { cout <<
fReal
; };
63
float
Real
() {
return
fReal
; };
64
string
&
Name
() {
return
fName
; };
65
66
private
:
67
string
fName
;
68
float
fReal
,
fCpu
;
69
};
70
71
class
L1CATFIterTimerInfo
72
{
73
public
:
74
L1CATFIterTimerInfo
()
75
:
fNameToI
()
76
,
fTIs
()
77
{}
78
void
Add
(
string
name)
79
{
80
fNameToI
[name] =
fTIs
.size();
81
fTIs
.push_back(
TimerInfo
(name));
82
};
83
TimerInfo
&
operator[]
(
string
name) {
return
fTIs
[
fNameToI
[name]]; };
84
TimerInfo
&
operator[]
(
int
i
) {
return
fTIs
[
i
]; };
85
void
operator+=
(
L1CATFIterTimerInfo
& t)
86
{
87
for
(
unsigned
int
i
= 0;
i
<
fTIs
.size(); ++
i
)
88
fTIs
[
i
] += t[
i
];
89
}
90
L1CATFIterTimerInfo
operator/
(
float
f)
91
{
92
L1CATFIterTimerInfo
r;
93
r.
fNameToI
=
fNameToI
;
94
r.
fTIs
.resize(
fTIs
.size());
95
for
(
unsigned
int
i
= 0;
i
<
fTIs
.size(); ++
i
) {
96
r.
fTIs
[
i
] =
fTIs
[
i
] / f;
97
}
98
return
r;
99
}
100
101
void
PrintReal
(
int
f = 0)
102
{
103
if
(f) {
104
PrintNames
();
105
cout << endl;
106
}
107
fTIs
[0].PrintReal();
108
for
(
unsigned
int
i
= 1;
i
<
fTIs
.size(); ++
i
) {
109
cout <<
" | "
<< setw(
fTIs
[
i
].Name().size());
110
fTIs
[
i
].PrintReal();
111
}
112
if
(f)
113
cout << endl;
114
};
115
void
PrintNames
()
116
{
117
cout <<
fTIs
[0].Name();
118
for
(
unsigned
int
i
= 1;
i
<
fTIs
.size(); ++
i
) {
119
cout <<
" | "
<<
fTIs
[
i
].Name();
120
}
121
};
122
123
private
:
124
map<string, int>
fNameToI
;
125
vector<TimerInfo>
fTIs
;
126
};
127
128
class
L1CATFTimerInfo
129
{
130
public
:
131
L1CATFTimerInfo
()
132
:
fTIIs
()
133
,
fTIAll
() {};
134
void
SetNIter
(
int
n) {
fTIIs
.resize(n); };
135
136
void
Add
(
string
name)
137
{
138
for
(
unsigned
int
i
= 0;
i
<
fTIIs
.size(); ++
i
)
139
fTIIs
[
i
].
Add
(name);
140
fTIAll
.Add(name);
141
};
// use after setniter
142
L1CATFIterTimerInfo
&
GetTimerAll
() {
return
fTIAll
; };
143
L1CATFIterTimerInfo
&
operator[]
(
int
i
) {
return
fTIIs
[
i
]; };
144
void
operator+=
(
L1CATFTimerInfo
& t)
145
{
146
for
(
unsigned
int
i
= 0;
i
<
fTIIs
.size(); ++
i
)
147
fTIIs
[
i
] += t[
i
];
148
fTIAll
+= t.
GetAllInfo
();
149
}
150
L1CATFTimerInfo
operator/
(
float
f)
151
{
152
L1CATFTimerInfo
r;
153
r.
fTIAll
=
fTIAll
/ f;
154
r.
SetNIter
(
fTIIs
.size());
155
for
(
unsigned
int
i
= 0;
i
<
fTIIs
.size(); ++
i
) {
156
r.
fTIIs
[
i
] =
fTIIs
[
i
] / f;
157
}
158
return
r;
159
}
160
161
void
Calc
()
162
{
163
fTIAll
=
fTIIs
[0];
164
for
(
unsigned
int
i
= 1;
i
<
fTIIs
.size(); ++
i
)
165
fTIAll
+=
fTIIs
[
i
];
166
}
167
168
L1CATFIterTimerInfo
&
GetAllInfo
() {
return
fTIAll
; };
169
void
PrintReal
()
170
{
171
cout.precision(1);
172
cout.setf(ios::fixed);
173
cout <<
" stage "
<<
" : "
;
174
fTIAll
.PrintNames();
175
cout << endl;
176
for
(
unsigned
int
i
= 0;
i
<
fTIIs
.size(); ++
i
) {
177
cout <<
" iter "
<<
i
<<
" : "
;
178
fTIIs
[
i
].PrintReal();
179
cout << endl;
180
}
181
cout <<
" all "
<<
" : "
;
182
fTIAll
.PrintReal();
183
cout << endl;
184
};
185
186
private
:
187
vector<L1CATFIterTimerInfo>
fTIIs
;
188
L1CATFIterTimerInfo
fTIAll
;
189
};
190
191
#endif
i
int i
Definition
P4_F32vec4.h:22
TStopwatch.h
L1CATFIterTimerInfo
Definition
L1Timer.h:72
L1CATFIterTimerInfo::operator[]
TimerInfo & operator[](string name)
Definition
L1Timer.h:83
L1CATFIterTimerInfo::PrintNames
void PrintNames()
Definition
L1Timer.h:115
L1CATFIterTimerInfo::fTIs
vector< TimerInfo > fTIs
Definition
L1Timer.h:125
L1CATFIterTimerInfo::PrintReal
void PrintReal(int f=0)
Definition
L1Timer.h:101
L1CATFIterTimerInfo::L1CATFIterTimerInfo
L1CATFIterTimerInfo()
Definition
L1Timer.h:74
L1CATFIterTimerInfo::fNameToI
map< string, int > fNameToI
Definition
L1Timer.h:124
L1CATFIterTimerInfo::Add
void Add(string name)
Definition
L1Timer.h:78
L1CATFIterTimerInfo::operator+=
void operator+=(L1CATFIterTimerInfo &t)
Definition
L1Timer.h:85
L1CATFIterTimerInfo::operator/
L1CATFIterTimerInfo operator/(float f)
Definition
L1Timer.h:90
L1CATFIterTimerInfo::operator[]
TimerInfo & operator[](int i)
Definition
L1Timer.h:84
L1CATFTimerInfo::Add
void Add(string name)
Definition
L1Timer.h:136
L1CATFTimerInfo::fTIIs
vector< L1CATFIterTimerInfo > fTIIs
Definition
L1Timer.h:187
L1CATFTimerInfo::operator/
L1CATFTimerInfo operator/(float f)
Definition
L1Timer.h:150
L1CATFTimerInfo::GetAllInfo
L1CATFIterTimerInfo & GetAllInfo()
Definition
L1Timer.h:168
L1CATFTimerInfo::operator+=
void operator+=(L1CATFTimerInfo &t)
Definition
L1Timer.h:144
L1CATFTimerInfo::L1CATFTimerInfo
L1CATFTimerInfo()
Definition
L1Timer.h:131
L1CATFTimerInfo::GetTimerAll
L1CATFIterTimerInfo & GetTimerAll()
Definition
L1Timer.h:142
L1CATFTimerInfo::operator[]
L1CATFIterTimerInfo & operator[](int i)
Definition
L1Timer.h:143
L1CATFTimerInfo::fTIAll
L1CATFIterTimerInfo fTIAll
Definition
L1Timer.h:188
L1CATFTimerInfo::PrintReal
void PrintReal()
Definition
L1Timer.h:169
L1CATFTimerInfo::Calc
void Calc()
Definition
L1Timer.h:161
L1CATFTimerInfo::SetNIter
void SetNIter(int n)
Definition
L1Timer.h:134
TStopwatch
TStopwatch::RealTime
Double_t RealTime()
TStopwatch::CpuTime
Double_t CpuTime()
TimerInfo
Definition
L1Timer.h:26
TimerInfo::operator/
TimerInfo operator/(const float f) const
Definition
L1Timer.h:52
TimerInfo::Name
string & Name()
Definition
L1Timer.h:64
TimerInfo::operator=
void operator=(TStopwatch &sw)
Definition
L1Timer.h:37
TimerInfo::fReal
float fReal
Definition
L1Timer.h:68
TimerInfo::TimerInfo
TimerInfo()
Definition
L1Timer.h:28
TimerInfo::PrintReal
void PrintReal()
Definition
L1Timer.h:62
TimerInfo::fCpu
float fCpu
Definition
L1Timer.h:68
TimerInfo::operator+=
void operator+=(TStopwatch &sw)
Definition
L1Timer.h:42
TimerInfo::fName
string fName
Definition
L1Timer.h:67
TimerInfo::TimerInfo
TimerInfo(const string &name)
Definition
L1Timer.h:32
TimerInfo::Real
float Real()
Definition
L1Timer.h:63
TimerInfo::operator+=
void operator+=(const TimerInfo &t)
Definition
L1Timer.h:47
reconstruction
cat
L1Algo
L1Timer.h
Generated on
for BmnRoot by
1.17.0