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