Skip to content

Commit

Permalink
Refactor time measurement in TimeTook class
Browse files Browse the repository at this point in the history
  • Loading branch information
guybartal committed Mar 17, 2024
1 parent 2d19261 commit ed048fc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions rag_experiment_accelerator/utils/timetook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
import time
from .logging import get_logger


Expand All @@ -18,12 +18,11 @@ def __init__(self, description, logger):
self.end = None

def __enter__(self):
self.start = datetime.now()
self.start = time.perf_counter()
self.logger.info(f"Starting {self.description}")

def __exit__(self, type, value, traceback):
self.end = datetime.now()
self.end = time.perf_counter()
self.logger.info(
f"Time took for {self.description}: "
f"{(self.end - self.start).total_seconds()} seconds"
f"Time took for {self.description}: " f"{self.end - self.start} seconds"
)

0 comments on commit ed048fc

Please sign in to comment.