AOCDay.run_part(): When in timeit mode, display progress bar

This commit is contained in:
Stefan Harmuth 2023-12-25 12:31:06 +01:00
parent ee3b5ee941
commit 4ce70c8565
2 changed files with 7 additions and 4 deletions

View File

@ -2,4 +2,5 @@ bs4~=0.0.1
beautifulsoup4~=4.12.2
fishhook~=0.2.9
pygame~=2.5.2
requests~=2.31.0
requests~=2.31.0
tqdm~=4.66

View File

@ -9,6 +9,7 @@ from bs4 import BeautifulSoup
from .datafiles import JSONFile
from .stopwatch import StopWatch
from typing import Any, Callable, List, Tuple, Type
from tqdm.auto import tqdm
from .tools import get_script_dir
BASE_PATH = get_script_dir()
@ -55,10 +56,11 @@ class AOCDay:
if not measure_runtime or case_count < len(self.inputs[part]) - 1:
answer = self.part_func[part]()
else:
stopwatch = StopWatch()
for _ in range(timeit_number):
stopwatch = StopWatch(auto_start=False)
for _ in tqdm(range(timeit_number), desc=f"Part {part+1}", leave=False):
stopwatch.start()
answer = self.part_func[part]()
stopwatch.stop()
stopwatch.stop()
exec_time = stopwatch.avg_string(timeit_number)
if solution is None: