diff --git a/Week06/timer_aycaselda_keskin.py b/Week06/timer_aycaselda_keskin.py new file mode 100644 index 00000000..eb937417 --- /dev/null +++ b/Week06/timer_aycaselda_keskin.py @@ -0,0 +1,16 @@ +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:.6f} seconds")