Skip to content

Commit

Permalink
⚡️ Speed up method Timer.finish by 40% in PR #45415 (`tolik0/airbyt…
Browse files Browse the repository at this point in the history
…e-cdk/perpartition-with-global-regression-tests`)

Here's a more optimized version of the program.
  • Loading branch information
codeflash-ai[bot] authored Sep 17, 2024
1 parent 69a84b5 commit e71dc49
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import threading
import time
from typing import Any, Iterable, Mapping, Optional, TypeVar, Union
from typing import Any, Iterable, Mapping, Optional, Union, TypeVar

from airbyte_cdk.sources.declarative.incremental.datetime_based_cursor import DatetimeBasedCursor
from airbyte_cdk.sources.declarative.incremental.declarative_cursor import DeclarativeCursor
Expand Down Expand Up @@ -54,8 +54,8 @@ def start(self) -> None:
self._start = time.perf_counter_ns()

def finish(self) -> int:
if self._start:
return ((time.perf_counter_ns() - self._start) / 1e9).__ceil__()
if self._start is not None:
return (time.perf_counter_ns() - self._start + 999_999_999) // 1_000_000_000
else:
raise RuntimeError("Global substream cursor timer not started")

Expand Down

0 comments on commit e71dc49

Please sign in to comment.