14 from ROOT
import TCanvas, TGraph, TLatex, kBlue, kFullStar
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.
25 MarkerStyle = kFullStar
33 global NEventsInFlight
35 ifile = open(logfilename,
"r")
36 lines = ifile.readlines()
39 if "Summary: name=" in line:
40 runtime_nclones =
map(
43 ".* avg_runtime= ([0-9]*.[0-9]*|[0-9]*.[0-9]*e-[0-9]*) n_clones= ([0-9]).*",
47 vals.append(runtime_nclones)
48 elif "Running with" in line:
49 NEventsInFlight, NThreads =
map(
52 ".* Running with ([0-9]*) parallel events.*algorithms, ([0-9]*) threads",
61 graph = TGraph(len(vals))
63 for runtime, nclones
in vals:
64 graph.SetPoint(counter, runtime, nclones)
67 graph.SetMarkerStyle(MarkerStyle)
68 graph.SetMarkerSize(MarkerSize)
69 graph.SetMarkerColor(Color)
71 "GaudiHive Speedup (Brunel, 100 evts);Algorithm Runtime [s];Number of Clones"
76 def getText(x, y, text, scale, angle, colour, font, NDC=False):
80 "#scale[%s]{#color[%s]{#font[%s]{%s}}}" % (scale, colour, font, text),
85 lat.SetTextAngle(angle)
91 def getNclones(runtime_nclones):
92 return runtime_nclones[1]
94 max_nclones = int(max(vals, key=getNclones)[1])
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))
101 label =
getText(0.95, 0.55,
"Total", 0.8, 270, 600, 12,
True)
103 latexes.append(label)
109 global NEventsInFlight
113 nalgorithms = len(vals)
115 canvas = TCanvas(
"Clones",
"Clones", 1024, 768)
123 map(
lambda latex: latex.Draw(), countLatexes)
127 "#splitline{#splitline{%s Simultaneous Events}{%s Threads}}{%s Algorithms}"
128 % (NEventsInFlight, NThreads, nalgorithms),
137 input(
"press enter to continue")
138 canvas.Print(
"PlotClones.png")
141 if __name__ ==
"__main__":
144 print(
"Usage: plotClonesPyRoot.py logfilename")