-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
prof.py
41 lines (36 loc) · 1.57 KB
/
prof.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import argparse
import pickle
import cupy_prof
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--plot', action='store_true')
parser.add_argument('-c', '--csv', action='store_true')
parser.add_argument('-d', '--dump-pickle', type=str, default=None)
parser.add_argument(
'-r', '--repo', nargs='+', type=str, default=None, required=False)
parser.add_argument(
'-cm', '--commits', nargs='+', type=str, default=None, required=False)
args, paths = parser.parse_known_args()
if args.repo is None and args.commits is None:
collector = cupy_prof.Collector()
collector.collect(paths)
dfs = {}
for bench_class in collector.benchmarks:
bench = bench_class()
df = cupy_prof.Measure(bench).measure(csv=args.csv, plot=args.plot)
if args.dump_pickle is not None:
dfs[bench_class.__name__] = df
if args.dump_pickle is not None:
with open(args.dump_pickle, 'wb') as handle:
pickle.dump(dfs, handle)
elif ((args.repo != args.commits)
and (args.repo is None or args.commits is None)):
raise ValueError('--repo and --commits need to be specified together')
else:
if len(args.repo) != 1 and len(args.repo) != len(args.commits):
raise ValueError(
'--repo must be a single repository or one per commit')
comparer = cupy_prof.Comparer(args.commits, args.repo, paths)
comparer.compare(csv=args.csv, plot=args.plot)
if __name__ == '__main__':
main()