Skip to content

Commit 44d7e10

Browse files
committed
feat: update CLI
1 parent 9ba0f1b commit 44d7e10

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

aoc_run.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import inspect
55
from importlib import import_module
66
from pathlib import Path
7-
from traceback import print_exc
8-
from time import perf_counter
97
from timeit import timeit
108
from functools import wraps
119

@@ -16,11 +14,9 @@
1614
def perf(f):
1715
@wraps(f)
1816
def wrapper(*args, **kwds):
19-
start_time = perf_counter()
2017
output = f(*args, **kwds)
21-
time = perf_counter() - start_time
2218
tit = timeit('f(*args, **kwds)', number=10**2, globals=locals())
23-
return output, tit, time
19+
return output, tit
2420
return wrapper
2521

2622

@@ -67,15 +63,17 @@ def handle(self):
6763
continue
6864
with open(input_file) as f:
6965
input_data = cast_func(f.read())
66+
print(' '*2 + f'part-{part}')
7067
for _, func in list(filter(lambda x: x[0].endswith(f'part{part}'), funcs)):
71-
print(' '*2 + f'{day_module.__name__}.{func.__name__}: ', end='')
68+
output, tit = None, -1
7269
try:
73-
output, tit, time = self._run(func, input_data)
74-
print(output)
75-
print(' '*4 + '\033[90m'+f'(100, 1): ({tit:f} sec, {time:f} sec)', '\033[0m')
76-
except BaseException:
77-
print_exc()
78-
print()
70+
output, tit = self._run(func, input_data)
71+
except BaseException as e:
72+
output = e
73+
print(' '*4+f'ƒ {func.__name__}',)
74+
print(' '*6+'\033[90m'+f'{tit:f}'+'\033[0m', output)
75+
76+
print()
7977

8078
@perf
8179
def _run(self, module, input_data):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy