ATLAS Offline Software
Loading...
Searching...
No Matches
plot_tot_times.py
Go to the documentation of this file.
1# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2from plot_times import times
3import pylab as pl
4import sys
5import glob
6from collections import defaultdict
7import itertools
8
9if len(sys.argv) < 3:
10 print('Please supply an input file name stub to glob on the command line, and an output file name')
11 sys.exit(0)
12
13
14stub = sys.argv[1]
15outname = sys.argv[2]
16if not outname.endswith('.pdf'): outname += '.pdf'
17
18fns = glob.glob(stub)
19print('glob found %d files: %s for stub %s' % (len(fns), str(fns), stub))
20if not fns:
21 print('no files found for stub', stub)
22 sys.exit()
23
24def get_tot(fn):
25 print('processing ', fn)
26 t = times(fn)
27 # return sum(t)/float(len(t))
28 return sum(t)
29
30
31def get_nbkgd(fn):
32 print(fn)
33 x = fn.split('.')[0] # remove .log
34 toks = x.split('_')
35 x = [t for t in toks if t.startswith('b')][0]
36 x = x[1:] # remove 'b'
37 print(x)
38 return float(x)
39
40def plot_by_fn_type(fn_list, marker, label):
41 print('plotting', fn_list)
42
43 tot_times = [get_tot(fn) for fn in fn_list]
44 n_bkgd = [get_nbkgd(fn) for fn in fn_list]
45 # pl.plot(n_bkgd, tot_times, marker = marker, label=label)
46 pl.plot(n_bkgd, tot_times, marker, label=label)
47
48fn_types = defaultdict(list)
49
50for fn in fns:
51 key = fn.split('_')
52 key = [k for k in key if k.startswith('j')]
53 key = '_'.join(key)
54 fn_types[key].append(fn)
55
56markers = itertools.cycle(('ro','bo'))
57print()
58print('fn_types:')
59for k, v in fn_types.items():
60 print(k)
61 print(' ', v)
62
63print()
64for k, v in fn_types.items():
65 print(k)
66 print(' ' + str(v))
67 plot_by_fn_type(v, next(markers), label=k)
68
69
70pl.suptitle(outname[:-4])
71pl.xlabel('n background')
72pl.ylabel('tot exec time 1000 events (ns)')
73pl.legend()
74pl.savefig(outname)
75pl.show()
void print(char *figname, TCanvas *c1)
plot_by_fn_type(fn_list, marker, label)