| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 plt.savefig("test.pdf")
36
37
38 class TimingInfo(object):
39 def __init__(self, name, time):
40 name = name.rstrip(".time")
41 threads, events, algos = name.split("_")[1:]
42 self.threads = int(threads)
43 self.events = int(events)
44 self.algos = int(algos)
45 self.time = float(time)
46
47
48 def prepareTimingPlots(config="BrunelScenario", path="../options"):
49
50 # first read all the timings
51 timings = []
52 for filename in os.listdir(path):
53 if filename.startswith(config) and filename.endswith("time"):
54 ff = open(os.path.join(path, filename))
55 time = ff.read().rstrip("\n")
56 timing = TimingInfo(filename, time)
57 timings.append(timing)
58 # now prepare the various plots:
59 # o parallel algos vs. time (for fixed parallel events)
60 fig = plt.figure()
61 ax = fig.add_subplot(111)
62 times = []
63 algos = []
64 for timing in timings:
65 if timing.events == 1:
66 times.append(timing.time)
67 algos.append(timing.algos)
68 ax.plot(algos, times)
69 plt.xlabel("Max algos in parallel")
70 plt.ylabel("runtime (s)")
71 plt.title("Brunel / CPUCruncher profiling.")
72
73 plt.savefig("timing.pdf")
74
75
76 ##########################
77 if __name__ == "__main__":
78
79 # instancesVsTime("/afs/cern.ch/work/h/hegner/hive/Gaudi/GaudiHive/options/log.log")
80 prepareTimingPlots()
makePlots.TimingInfo.events
events
Definition: makePlots.py:43
makePlots.TimingInfo.threads
threads
Definition: makePlots.py:42
makePlots.instancesVsTime
def instancesVsTime(filename)
Definition: makePlots.py:7
makePlots.TimingInfo.time
time
Definition: makePlots.py:45
makePlots.TimingInfo.algos
algos
Definition: makePlots.py:44
makePlots.TimingInfo.__init__
def __init__(self, name, time)
Definition: makePlots.py:39
makePlots.prepareTimingPlots
def prepareTimingPlots(config="BrunelScenario", path="../options")
Definition: makePlots.py:48
makePlots.TimingInfo
Definition: makePlots.py:38