diff --git a/Week06/timer_anil_guler.py b/Week06/timer_anil_guler.py new file mode 100644 index 00000000..94d46b1a --- /dev/null +++ b/Week06/timer_anil_guler.py @@ -0,0 +1,15 @@ +import time + +class Timer: + def __init__(self): + self.start_time = None + self.end_time = None + + def __enter__(self): + self.start_time = time.perf_counter() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.end_time = time.perf_counter() + execution_time = self.end_time - self.start_time + print(f"Block executed in {execution_time:.4f} seconds")