The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
plotBacklogPyRoot.py
Go to the documentation of this file.
1
11
import
re
12
import
sys
13
14
from
ROOT
import
(
15
TCanvas,
16
TGraph,
17
TLatex,
18
TLegend,
19
kBlue,
20
kFullCircle,
21
kGreen,
22
kOpenCircle,
23
kRed,
24
kWhite,
25
)
26
27
"""
28
Produces the backlog plot, parsing the output of the EventLoopManager.
29
Lines with the pattern "Event backlog" are looked for.
30
Events in flight are looked for as well.
31
"""
32
33
# configuration
34
35
NEventsInFlight = -1
36
NThreads = -1
37
38
LineStyles = [1, 2]
39
LineWidth = 3
40
Colors = [kBlue, kGreen + 2]
41
MarkerStyles = [kOpenCircle, kFullCircle]
42
MarkesSize = 1.5
43
44
graphCounter = 0
45
maxY = -1
46
47
LegendDrawOpts =
"lp"
48
49
50
def
parseLog
(logfilename):
51
# a line looks like
52
# "HiveSlimEventLoopMgr SUCCESS Event backlog (max= 3, min= 0 ) = 3"
53
global
NEventsInFlight
54
global
NThreads
55
ifile = open(logfilename)
56
lines = ifile.readlines()
57
ifile.close()
58
content = []
59
for
line
in
lines:
60
if
"Event backlog"
in
line:
61
content.append(
62
re.match(
63
r".* \(max= ([0-9]*), min= ([0-9]*) \) = ([0-9]*).*"
, line
64
).groups()
65
)
66
elif
"Running with"
in
line:
67
NEventsInFlight, NThreads = map(
68
int,
69
re.match(
".*Running with ([0-9]*).* ([0-9]*) threads"
, line).groups(),
70
)
71
72
return
content
73
74
75
def
createGraph
(max_min_blog_vals):
76
global
graphCounter
77
global
maxY
78
graph = TGraph(len(max_min_blog_vals))
79
counter = 0
80
for
maxn, minn, blog
in
max_min_blog_vals:
81
blog = float(blog)
82
graph.SetPoint(counter, counter + 1, float(blog))
83
if
maxY < blog:
84
maxY = blog
85
counter += 1
86
87
graph.SetMarkerSize(MarkesSize)
88
graph.SetMarkerStyle(MarkerStyles[graphCounter])
89
graph.SetMarkerColor(Colors[graphCounter])
90
graph.SetLineWidth(LineWidth)
91
graph.SetLineColor(Colors[graphCounter])
92
graph.SetLineStyle(LineStyles[graphCounter])
93
94
graphCounter += 1
95
96
return
graph
97
98
99
def
createInFlightGraph
(nevts):
100
global
NEventsInFlight
101
graph = TGraph(2)
102
graph.SetPoint(0, 0.0, float(NEventsInFlight))
103
graph.SetPoint(1, float(nevts) + 1, float(NEventsInFlight))
104
graph.SetLineWidth(3)
105
graph.SetLineColor(kRed)
106
graph.SetLineStyle(2)
107
graph.SetTitle(
"GaudiHive Backlog (Brunel, 100 evts);Events Finished;Event Backlog"
)
108
print(NEventsInFlight)
109
return
graph
110
111
112
def
getText
(x, y, text, scale, angle, colour, font, NDC=False):
113
lat = TLatex(
114
float(x),
115
float(y),
116
f
"#scale[{scale}]{{#color[{colour}]{{#font[{font}]{{{text}}}}}}}"
,
117
)
118
if
NDC:
119
lat.SetNDC()
120
if
angle != 0.0:
121
lat.SetTextAngle(angle)
122
return
lat
123
124
125
def
doPlot
(logfilename, logfilename_copy):
126
global
NEventsInFlight
127
global
maxY
128
global
NThreads
129
vals =
parseLog
(logfilename)
130
vals_c =
parseLog
(logfilename_copy)
131
n_vals = len(vals)
132
inFlightgraph =
createInFlightGraph
(n_vals)
133
graph =
createGraph
(vals)
134
graph_c =
createGraph
(vals_c)
135
136
canvas = TCanvas(
"Backlog"
,
"Backlog"
, 1100, 900)
137
canvas.cd()
138
canvas.SetGrid()
139
inFlightgraph.Draw(
"APL"
)
140
inFlightgraph.GetYaxis().SetRangeUser(0.0, maxY * 1.2)
141
inFlightgraph.GetXaxis().SetRangeUser(0.0, float(n_vals + 1))
142
graph.Draw(
"PLSame"
)
143
graph_c.Draw(
"PLSame"
)
144
145
# Labels
146
eventInFlightLabel =
getText
(
147
float(n_vals + 1) * 1.03,
148
NEventsInFlight,
149
"#splitline{# Simultaneous}{ Events}"
,
150
0.6,
151
270,
152
2,
153
12,
154
)
155
eventInFlightLabel.Draw()
156
nThreadsLabel =
getText
(0.15, 0.7, f
"{NThreads} Threads"
, 0.6, 0, 2, 12,
True
)
157
nThreadsLabel.Draw()
158
159
# Build a Legend
160
legend = TLegend(0.7, 0.75, 0.9, 0.9)
161
legend.SetFillColor(kWhite)
162
legend.SetHeader(
"Algo Management"
)
163
legend.AddEntry(graph,
"No Cloning"
, LegendDrawOpts)
164
legend.AddEntry(graph_c,
"Cloning enabled"
, LegendDrawOpts)
165
legend.Draw()
166
167
input(
"press enter to continue"
)
168
169
canvas.Print(
"EventBacklog.png"
)
170
171
172
if
__name__ ==
"__main__"
:
173
argc = len(sys.argv)
174
if
argc != 3:
175
print(
"Usage: plotBacklogPyRoot.py logfilename logfilename_copy"
)
176
sys.exit(1)
177
doPlot
(sys.argv[1], sys.argv[2])
plotBacklogPyRoot.createGraph
createGraph(max_min_blog_vals)
Definition
plotBacklogPyRoot.py:75
plotBacklogPyRoot.createInFlightGraph
createInFlightGraph(nevts)
Definition
plotBacklogPyRoot.py:99
plotBacklogPyRoot.parseLog
parseLog(logfilename)
Definition
plotBacklogPyRoot.py:50
plotBacklogPyRoot.getText
getText(x, y, text, scale, angle, colour, font, NDC=False)
Definition
plotBacklogPyRoot.py:112
plotBacklogPyRoot.doPlot
doPlot(logfilename, logfilename_copy)
Definition
plotBacklogPyRoot.py:125
GaudiHive
profiling
plotBacklogPyRoot.py
Generated on
for The Gaudi Framework by
1.17.0