-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathanalyze_timing.py
49 lines (40 loc) · 1.47 KB
/
analyze_timing.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
42
43
44
45
46
47
48
49
import re
import datetime
import fileinput
def main() -> None:
total_time = datetime.timedelta(0)
max_time = datetime.timedelta(0)
num_lines = 0
for line in fileinput.input():
tag, seperator, timedelta = line.partition(":")
if re.match("vernac", tag):
# This is a label for how long it took to run the vernac
continue
if re.match("Orig.*", tag):
# This is the time it took to run the original proof
continue
theorem_time = parseTimeDelta(timedelta)
if theorem_time > max_time:
max_time = theorem_time
total_time += theorem_time
num_lines += 1
print(f"Average theorem search time: {total_time/num_lines}")
print(f"Max theorem search time: {max_time}")
def parseTimeDelta(s):
"""Create timedelta object representing time delta
expressed in a string
Takes a string in the format produced by calling str() on
a python timedelta object and returns a timedelta instance
that would produce that string.
Acceptable format is: "HH:MM:SS.MMMMMM".
"""
match = re.match(
r'\s*(?P<hours>\d+):(?P<minutes>\d+):'
r'(?P<seconds>\d+)\.(?P<milliseconds>\d+)',
s)
assert match, f"String {s} didn't match"
d = match.groupdict(0)
return datetime.timedelta(**dict(( (key, int(value))
for key, value in d.items() )))
if __name__ == "__main__":
main()