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