| The Gaudi Framework v32r1 (f65d50dc)

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