diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/utils/MiscFeatures.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/argaze/utils/MiscFeatures.py b/src/argaze/utils/MiscFeatures.py index 6fe51d5..9f68a27 100644 --- a/src/argaze/utils/MiscFeatures.py +++ b/src/argaze/utils/MiscFeatures.py @@ -2,7 +2,6 @@ import time -# Print iterations progress def printProgressBar (iteration:int, total:int, prefix:str = '', suffix:str = '', decimals:int = 1, length:int = 100, fill:str = '█', printEnd:str = "\r"): """Print iterations progress. Call in a loop to create terminal progress bar. @@ -24,9 +23,8 @@ def printProgressBar (iteration:int, total:int, prefix:str = '', suffix:str = '' if iteration == total: print() -# Handle exit event class ExitSignalHandler(): - + """Handle exit event""" def __init__(self): import signal @@ -46,20 +44,22 @@ class ExitSignalHandler(): def status(self): return __exit_event.is_set() -# Assess temporal performance class TimeProbe(): + """Assess temporal performance""" def __init__(self): self.start() def start(self): + """Start chronometer.""" self.__last_time = time.perf_counter() self.__lap_counter = 0 self.__elapsed_time = 0 def lap(self): + """Get the last lap time, number of laps and total elapsed time in millisecond.""" lap_time = time.perf_counter() - self.__last_time @@ -67,13 +67,14 @@ class TimeProbe(): self.__lap_counter += 1 self.__elapsed_time += lap_time - return lap_time, self.__lap_counter, self.__elapsed_time + return lap_time * 1e3, self.__lap_counter, self.__elapsed_time * 1e3 def end(self): + """Stop chronometer and get elapsed time in millisecond.""" self.__elapsed_time += time.perf_counter() - self.__last_time - return self.__elapsed_time + return self.__elapsed_time * 1e3, self.__lap_counter def restart(self): |