visualize.py 1.65 KB
Newer Older
1
#!/usr/bin/env python3
2
import argparse, sys, pprint, itertools
Ralf Jung's avatar
Ralf Jung committed
3
import matplotlib.pyplot as plt
4 5
import parse_log

6 7
markers = itertools.cycle([(3, 0), (3, 0, 180), (4, 0), (4, 0, 45), (8, 0)])

8 9 10 11 12 13 14
# read command-line arguments
parser = argparse.ArgumentParser(description='Visualize iris-coq build times')
parser.add_argument("-f", "--file",
                    dest="file", required=True,
                    help="Filename to get the data from.")
parser.add_argument("-t", "--timings", nargs='+',
                    dest="timings",
15
                    help="The names of the Coq files (with or without the extension) whose timings should be extracted")
16 17 18
parser.add_argument("-c", "--commits",
                    dest="commits",
                    help="Restrict the graph to the given commits.")
19 20 21 22
args = parser.parse_args()
pp = pprint.PrettyPrinter()
log_file = sys.stdin if args.file == "-" else open(args.file, "r")

23 24 25 26 27
results = parse_log.parse(log_file, parse_times = True)
if args.commits:
    commits = set(parse_log.parse_git_commits(args.commits))
    results = filter(lambda r: r.commit in commits, results)
results = list(results)
Ralf Jung's avatar
Ralf Jung committed
28

29
timings = list(map(lambda t: t[:-2] if t.endswith(".v") else t, args.timings))
30 31
for timing in timings:
    plt.plot(list(map(lambda r: r.times.get(timing), results)), marker=next(markers), markersize=8)
32
plt.legend(timings, loc = 'upper left', bbox_to_anchor=(1.05, 1.0))
Ralf Jung's avatar
Ralf Jung committed
33
plt.xticks(range(len(results)), list(map(lambda r: r.commit[:7], results)), rotation=70)
34
plt.subplots_adjust(bottom=0.2, right=0.7) # more space for the commit labels and legend
Ralf Jung's avatar
Ralf Jung committed
35 36 37 38 39 40

plt.xlabel('Commit')
plt.ylabel('Time (s)')
plt.title('Time to compile files')
plt.grid(True)
plt.show()