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