The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
plotClonesPyRoot.py
Go to the documentation of this file.
1
11
import
re
12
import
sys
13
14
from
ROOT
import
TCanvas, TGraph, TLatex, kBlue, kFullStar
15
16
"""
17
Prepare the clones plot.
18
Parses the end of the output file, printed by the destructors of the CPUCruncher.
19
A line with the pattern "Summary: name=" is looked for.
20
The number of Events in flight is parsed as well.
21
"""
22
23
# configure
24
Color = kBlue
25
MarkerStyle = kFullStar
26
MarkerSize = 3.8
27
28
NEventsInFlight = 0
29
NThreads = -1
30
31
32
def
parseLog
(logfilename):
33
global
NEventsInFlight
34
global
NThreads
35
ifile = open(logfilename)
36
lines = ifile.readlines()
37
vals = []
38
for
line
in
lines:
39
if
"Summary: name="
in
line:
40
runtime_nclones = map(
41
float,
42
re.match(
43
".* avg_runtime= ([0-9]*.[0-9]*|[0-9]*.[0-9]*e-[0-9]*) n_clones= ([0-9]).*"
,
44
line,
45
).groups(),
46
)
47
vals.append(runtime_nclones)
48
elif
"Running with"
in
line:
49
NEventsInFlight, NThreads = map(
50
int,
51
re.match(
52
".* Running with ([0-9]*) parallel events.*algorithms, ([0-9]*) threads"
,
53
line,
54
).groups(),
55
)
56
57
return
vals
58
59
60
def
createGraph
(vals):
61
graph = TGraph(len(vals))
62
counter = 0
63
for
runtime, nclones
in
vals:
64
graph.SetPoint(counter, runtime, nclones)
65
counter += 1
66
67
graph.SetMarkerStyle(MarkerStyle)
68
graph.SetMarkerSize(MarkerSize)
69
graph.SetMarkerColor(Color)
70
graph.SetTitle(
71
"GaudiHive Speedup (Brunel, 100 evts);Algorithm Runtime [s];Number of Clones"
72
)
73
return
graph
74
75
76
def
getText
(x, y, text, scale, angle, colour, font, NDC=False):
77
lat = TLatex(
78
float(x),
79
float(y),
80
f
"#scale[{scale}]{{#color[{colour}]{{#font[{font}]{{{text}}}}}}}"
,
81
)
82
83
lat.SetNDC(NDC)
84
if
angle != 0.0:
85
lat.SetTextAngle(angle)
86
return
lat
87
88
89
def
getCountLatexes
(vals, xmax):
90
# print vals
91
def
getNclones(runtime_nclones):
92
return
runtime_nclones[1]
93
94
max_nclones = int(max(vals, key=getNclones)[1])
95
96
latexes = []
97
for
i
in
range(1, max_nclones + 1):
98
n_algos = len(filter(
lambda
runtime_nclones: runtime_nclones[1] == i, vals))
99
latexes.append(
getText
(xmax * 1.01, i, n_algos, 0.7, 0, 600, 12))
100
101
label =
getText
(0.95, 0.55,
"Total"
, 0.8, 270, 600, 12,
True
)
102
103
latexes.append(label)
104
105
return
latexes
106
107
108
def
doPlot
(logfilename):
109
global
NEventsInFlight
110
global
NThreads
111
vals =
parseLog
(logfilename)
112
graph =
createGraph
(vals)
113
nalgorithms = len(vals)
114
115
canvas = TCanvas(
"Clones"
,
"Clones"
, 1024, 768)
116
canvas.cd()
117
canvas.SetGrid()
118
graph.Draw(
"AP"
)
119
120
# Latex
121
122
countLatexes =
getCountLatexes
(vals, graph.GetXaxis().GetXmax())
123
map(
lambda
latex: latex.Draw(), countLatexes)
124
evtsIf =
getText
(
125
0.6,
126
0.365,
127
f
"#splitline{{#splitline{{{NEventsInFlight} Simultaneous Events}}{{{NThreads} Threads}}}}{{{nalgorithms} Algorithms}}"
,
128
0.8,
129
0,
130
2,
131
12,
132
True
,
133
)
134
evtsIf.Draw()
135
136
input(
"press enter to continue"
)
137
canvas.Print(
"PlotClones.png"
)
138
139
140
if
__name__ ==
"__main__"
:
141
argc = len(sys.argv)
142
if
argc != 2:
143
print(
"Usage: plotClonesPyRoot.py logfilename"
)
144
sys.exit(1)
145
doPlot
(sys.argv[1])
plotClonesPyRoot.createGraph
createGraph(vals)
Definition
plotClonesPyRoot.py:60
plotClonesPyRoot.parseLog
parseLog(logfilename)
Definition
plotClonesPyRoot.py:32
plotClonesPyRoot.getText
getText(x, y, text, scale, angle, colour, font, NDC=False)
Definition
plotClonesPyRoot.py:76
plotClonesPyRoot.doPlot
doPlot(logfilename)
Definition
plotClonesPyRoot.py:108
plotClonesPyRoot.getCountLatexes
getCountLatexes(vals, xmax)
Definition
plotClonesPyRoot.py:89
GaudiHive
profiling
plotClonesPyRoot.py
Generated on
for The Gaudi Framework by
1.17.0