| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

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