Skip to content

Instantly share code, notes, and snippets.

@sizhky
Created December 9, 2023 19:15
Show Gist options
  • Save sizhky/02f3b5e8d01bf7dcb1eafef6d5f7a72f to your computer and use it in GitHub Desktop.
Save sizhky/02f3b5e8d01bf7dcb1eafef6d5f7a72f to your computer and use it in GitHub Desktop.
ticktock timer for time profiling
from time import perf_counter
class Ticker:
def __init__(self):
self.tik = perf_counter()
def __call__(self, arg, info=None, newl=False):
tok = perf_counter()
t = round(tok-self.tik, 3)
if newl: print()
print(f'{arg.upper()}:: {t:.3f}')
if info is not None: print(info)
self.tik = perf_counter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment