The Gaudi Framework  master (37c0b60a)
makePlots.py
Go to the documentation of this file.
1 
11 import os
12 
13 import matplotlib
14 
15 matplotlib.use("PDF")
16 import matplotlib.pyplot as plt
17 
18 
19 def instancesVsTime(filename):
20  logfile = open(filename)
21  nOfInstances = {}
22  runtime = {}
23  # extract all info
24  for line in logfile.readlines():
25  if "I ran" in line:
26  name = line.split("SUCCESS")[0]
27  runtime[name] = float(line.split("runtime of")[1])
28  if name in nOfInstances:
29  number = nOfInstances[name]
30  else:
31  number = 0
32  nOfInstances[name] = number + 1
33  # now sort it
34  x = []
35  y = []
36  for name in runtime:
37  x.append(runtime[name])
38  y.append(nOfInstances[name])
39  fig = plt.figure()
40  ax = fig.add_subplot(111)
41  ax.scatter(x, y)
42  ax.grid(True)
43  plt.xlabel("Runtime (s)")
44  plt.ylabel("# instances")
45  plt.title(
46  "Requested algorithm instances with 10 events and 10 threads in parallel."
47  )
48  plt.savefig("test.pdf")
49 
50 
51 class TimingInfo(object):
52  def __init__(self, name, time):
53  name = name.rstrip(".time")
54  threads, events, algos = name.split("_")[1:]
55  self.threads = int(threads)
56  self.events = int(events)
57  self.algos = int(algos)
58  self.time = float(time)
59 
60 
61 def prepareTimingPlots(config="BrunelScenario", path="../options"):
62  # first read all the timings
63  timings = []
64  for filename in os.listdir(path):
65  if filename.startswith(config) and filename.endswith("time"):
66  ff = open(os.path.join(path, filename))
67  time = ff.read().rstrip("\n")
68  timing = TimingInfo(filename, time)
69  timings.append(timing)
70  # now prepare the various plots:
71  # o parallel algos vs. time (for fixed parallel events)
72  fig = plt.figure()
73  ax = fig.add_subplot(111)
74  times = []
75  algos = []
76  for timing in timings:
77  if timing.events == 1:
78  times.append(timing.time)
79  algos.append(timing.algos)
80  ax.plot(algos, times)
81  plt.xlabel("Max algos in parallel")
82  plt.ylabel("runtime (s)")
83  plt.title("Brunel / CPUCruncher profiling.")
84 
85  plt.savefig("timing.pdf")
86 
87 
88 
89 if __name__ == "__main__":
90  # instancesVsTime("/afs/cern.ch/work/h/hegner/hive/Gaudi/GaudiHive/options/log.log")
makePlots.TimingInfo.events
events
Definition: makePlots.py:56
makePlots.TimingInfo.__init__
def __init__(self, name, time)
Definition: makePlots.py:52
makePlots.TimingInfo.threads
threads
Definition: makePlots.py:55
makePlots.TimingInfo
Definition: makePlots.py:51
makePlots.TimingInfo.time
time
Definition: makePlots.py:58
makePlots.prepareTimingPlots
def prepareTimingPlots(config="BrunelScenario", path="../options")
Definition: makePlots.py:61
makePlots.TimingInfo.algos
algos
Definition: makePlots.py:57
makePlots.instancesVsTime
def instancesVsTime(filename)
Definition: makePlots.py:19