Skip to content

Commit

Permalink
refactor: add monotonic clock (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
micpst authored May 9, 2024
1 parent adfd479 commit 9b31299
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions benchmark/dbally_benchmark/text2sql/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class _ExecutionResult:

def _run_query(query: str, engine: Engine) -> _ExecutionResult:
with engine.connect() as connection:
start_time = time.time()
start_time = time.monotonic()
rows = connection.execute(text(query)).fetchall()
execution_time = time.time() - start_time
execution_time = time.monotonic() - start_time

return _ExecutionResult(
results=[dict(row._mapping) for row in rows], # pylint: disable=protected-access
Expand Down
8 changes: 4 additions & 4 deletions src/dbally/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async def ask(self, question: str, dry_run: bool = False, return_natural_respons
IQLError: if incorrect IQL was generated `n_retries` amount of times.
ValueError: if incorrect IQL was generated `n_retries` amount of times.
"""
start_time = time.time()
start_time = time.monotonic()

event_tracker = EventTracker.initialize_with_handlers(self._event_handlers)

Expand All @@ -201,15 +201,15 @@ async def ask(self, question: str, dry_run: bool = False, return_natural_respons

view = self.get(selected_view)

start_time_view = time.time()
start_time_view = time.monotonic()
view_result = await view.ask(
query=question,
llm_client=self._llm_client,
event_tracker=event_tracker,
n_retries=self.n_retries,
dry_run=dry_run,
)
end_time_view = time.time()
end_time_view = time.monotonic()

textual_response = None
if not dry_run and return_natural_response:
Expand All @@ -218,7 +218,7 @@ async def ask(self, question: str, dry_run: bool = False, return_natural_respons
result = ExecutionResult(
results=view_result.results,
context=view_result.context,
execution_time=time.time() - start_time,
execution_time=time.monotonic() - start_time,
execution_time_view=end_time_view - start_time_view,
view_name=selected_view,
textual_response=textual_response,
Expand Down

0 comments on commit 9b31299

Please sign in to comment.