-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimeall.py
More file actions
30 lines (26 loc) · 702 Bytes
/
timeall.py
File metadata and controls
30 lines (26 loc) · 702 Bytes
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
from time import perf_counter
def profiler(method):
def profiler_method(*arg, **kw):
t = perf_counter()
ret = method(*arg, **kw)
print(f'{method.__name__} method took : {perf_counter()-t:.4f} sec')
return ret
return profiler_method
@profiler
def timeall():
times = {}
for i in range(25):
name = f'day{i+1:02d}.day{i+1:02d}'
try:
day = __import__(name, fromlist=[''])
except ModuleNotFoundError:
continue
t = perf_counter()
day.solve()
times[perf_counter()-t] = name
if not times:
return
max_time = max(times.keys())
print(f'{times[max_time]} is the slowest, it took : {max_time:,.4f} sec')
if __name__ == "__main__":
timeall()