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