| The Gaudi Framework v29r1 (5cd95fa2)

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

- File List
- File Members

plotSpeedup.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2
3 """
4 Script that fetches all the logfiles from disk and reads the timings.
5 Parameters can be changed according to the working points considered.
6 Some parameters of the plots are hardcoded.
7 """
8
9 from ROOT import *
10
11 n_algos_in_flight_l = [1, 2, 5, 7, 10, 16, 20, 22]
12 n_evts_in_flight_l = [1, 2, 4, 6, 7, 8, 9, 11, 13, 14, 15]
13 colour_l = [kRed, kBlue, kOrange, kGreen, kMagenta, kCyan] * 2
14 line_style_l = [1] * 6 + [2] * 6
15 cloneFlag_l = [True, False]
16
17 '''
18 To be filled with files on disk of the form
19 timing_measurement_BrunelScenario_n150_eif2_aif20_nthreads24_cFalse_dqFalse.log
20 '''
21 filename_scheleton = "timing_measurement_BrunelScenario_n150_eif%s_aif%s_nthreads24_c%s_dqFalse.log"
22
23
24 def getRuntime(n_algos_in_flight, n_evts_in_flight, cloneFlag):
25 filename = filename_scheleton % (
26 n_evts_in_flight, n_algos_in_flight, cloneFlag)
27 print filename
28 rt = 0.
29 for line in open(filename, "r").readlines():
30 rt = float(line[:-1])
31 # print filename
32 # print rt
33 return rt
34
35
36 '''
37 Dictionary with
38 o Key = [n_algos_in_flight, n_evts_in_flight, cloneFlag]
39 o Val = Runtime
40 '''
41
42
43 def getRuntimes():
44 runtimes = {}
45 for n_algos_in_flight in n_algos_in_flight_l:
46 for n_evts_in_flight in n_evts_in_flight_l:
47 for cloneFlag in cloneFlag_l:
48 rt = getRuntime(n_algos_in_flight,
49 n_evts_in_flight, cloneFlag)
50 runtimes[n_algos_in_flight, n_evts_in_flight, cloneFlag] = rt
51 return runtimes
52
53
54 def getGraphPoints(n_evts_in_flight, cloneFlag, runtimes):
55 points = []
56 for key, rt in runtimes.items():
57 this_n_algos_in_flight, this_n_evts_in_flight, this_cloneFlag = key
58 if this_n_evts_in_flight == n_evts_in_flight and \
59 this_cloneFlag == cloneFlag:
60 points.append((this_n_algos_in_flight, rt))
61 return sorted(points)
62
63
64 def getSingleGraph(n_evts_in_flight, cloneFlag, runtimes, colour, style):
65 points = getGraphPoints(n_evts_in_flight, cloneFlag, runtimes)
66 graph = TGraph(len(points))
67 graph.GetXaxis().SetTitle("Maximum # in flight algos")
68 graph.GetXaxis().SetRangeUser(0, 23)
69 graph.GetYaxis().SetTitle("Runtime [s]")
70 graph.GetYaxis().SetTitleOffset(1.45)
71 graph.GetYaxis().SetRangeUser(0.1, 275)
72 graph.GetYaxis().SetNdivisions(12, 5, 1)
73 graph.SetLineWidth(3)
74 graph.SetLineColor(colour)
75 graph.SetMarkerColor(colour)
76 graph.SetLineStyle(style)
77 graph.SetFillColor(kWhite)
78 point_n = 0
79 # print points
80 for x, y in points:
81 graph.SetPoint(point_n, x, y)
82 point_n += 1
83 return graph
84
85
86 def make_plot(runtimes, cloneFlag):
87 title = "Brunel 150 events"
88 clone_string = ""
89 if cloneFlag:
90 clone_string = "_clone"
91 title += " (Cloning)"
92 plotname = "runtime%s.pdf" % clone_string
93
94 canvas = TCanvas(plotname, "plot", 500, 400)
95 canvas.SetGrid()
96 canvas.cd()
97
98 graphs = []
99 first = True
100 for colour, n_evts_in_flight, line_style in zip(colour_l, n_evts_in_flight_l, line_style_l):
101 print n_evts_in_flight
102 graph = getSingleGraph(n_evts_in_flight, cloneFlag,
103 runtimes, colour, line_style)
104 opts = "LSame"
105 if first:
106 opts = "AL"
107 first = False
108 graph.SetTitle(title)
109 graph.Draw(opts)
110 graphs.append(graph)
111
112 # Make Legend
113 legend = TLegend(.499, .45, .9, .9, "# Parallel Events")
114 legend.SetTextSize(0.04)
115 legend.SetFillColor(kWhite)
116 # evil
117 for graph, n in zip(graphs, n_evts_in_flight_l):
118 legend.AddEntry(graph, "%s" % n)
119 legend.Draw()
120
121 # Add some text
122 l = TLatex(.13, .16, "#font[12]{#scale[.8]{24 Threads}}")
123 l.SetNDC()
124 l.Draw()
125
126 dummy = raw_input("Press enter to save...")
127 canvas.Print(plotname)
128
129
130 #-------------------------------------------------------------------------------
131 runtimes = getRuntimes()
132
133 make_plot(runtimes, True)
134
135 make_plot(runtimes, False)
plotSpeedup.getRuntimes
def getRuntimes()
Definition: plotSpeedup.py:43
plotSpeedup.getGraphPoints
def getGraphPoints(n_evts_in_flight, cloneFlag, runtimes)
Definition: plotSpeedup.py:54
plotSpeedup.make_plot
def make_plot(runtimes, cloneFlag)
Definition: plotSpeedup.py:86
plotSpeedup.getRuntime
def getRuntime(n_algos_in_flight, n_evts_in_flight, cloneFlag)
Definition: plotSpeedup.py:24
plotSpeedup.getSingleGraph
def getSingleGraph(n_evts_in_flight, cloneFlag, runtimes, colour, style)
Definition: plotSpeedup.py:64