| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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