Skip to content

Commit

Permalink
Merge pull request #402 from OpenTrafficCam/refactor-benchmarks
Browse files Browse the repository at this point in the history
Refactor benchmarks
  • Loading branch information
randy-seng authored Nov 13, 2023
2 parents 9eaf899 + dc4266a commit b2306fa
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions tests/benchmark_otanalytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class TestBenchmarkTrackParser:
ITERATIONS = 1
WARMUP_ROUNDS = 0

def test_load_15min_with_python_parser(
def test_load_15min(
self,
benchmark: BenchmarkFixture,
python_track_parser: TrackParser,
Expand All @@ -261,21 +261,7 @@ def test_load_15min_with_python_parser(
warmup_rounds=self.WARMUP_ROUNDS,
)

def test_load_15min_with_pandas_parser(
self,
benchmark: BenchmarkFixture,
pandas_track_parser: TrackParser,
track_file_15min: Path,
) -> None:
benchmark.pedantic(
pandas_track_parser.parse,
args=(track_file_15min,),
rounds=self.ROUNDS,
iterations=self.ITERATIONS,
warmup_rounds=self.WARMUP_ROUNDS,
)

def test_load_2hour_with_python_parser(
def test_load_2hours(
self,
benchmark: BenchmarkFixture,
python_track_parser: TrackParser,
Expand All @@ -296,6 +282,22 @@ def _parse_2hours(parser: TrackParser, ottrk_files: list[Path]) -> None:
warmup_rounds=self.WARMUP_ROUNDS,
)

@pytest.mark.skip
def test_load_15min_with_pandas_parser(
self,
benchmark: BenchmarkFixture,
pandas_track_parser: TrackParser,
track_file_15min: Path,
) -> None:
benchmark.pedantic(
pandas_track_parser.parse,
args=(track_file_15min,),
rounds=self.ROUNDS,
iterations=self.ITERATIONS,
warmup_rounds=self.WARMUP_ROUNDS,
)

@pytest.mark.skip
def test_load_2hour_with_pandas_parser(
self,
benchmark: BenchmarkFixture,
Expand Down Expand Up @@ -323,7 +325,7 @@ class TestBenchmarkTracksIntersectingSections:
ITERATIONS = 1
WARMUP_ROUNDS = 0

def test_python_15min(
def test_15min(
self,
benchmark: BenchmarkFixture,
python_track_repo_15min: tuple[TrackRepository, DetectionMetadata],
Expand All @@ -341,18 +343,16 @@ def test_python_15min(
warmup_rounds=self.WARMUP_ROUNDS,
)

def test_pandas_15min(
def test_2hours(
self,
benchmark: BenchmarkFixture,
pandas_track_repo_15min: tuple[TrackRepository, DetectionMetadata],
python_track_repo_2hours: tuple[TrackRepository, DetectionMetadata],
section_flow_repo_setup: tuple[SectionRepository, FlowRepository],
) -> None:
track_repository, _ = pandas_track_repo_15min
track_repository, _ = python_track_repo_2hours
section_repository, flow_repository = section_flow_repo_setup
use_case = _build_tracks_intersecting_sections(track_repository)

use_case(section_repository.get_all())

benchmark.pedantic(
use_case,
args=(section_repository.get_all(),),
Expand All @@ -361,16 +361,19 @@ def test_pandas_15min(
warmup_rounds=self.WARMUP_ROUNDS,
)

def test_python_2hours(
@pytest.mark.skip
def test_pandas_15min(
self,
benchmark: BenchmarkFixture,
python_track_repo_2hours: tuple[TrackRepository, DetectionMetadata],
pandas_track_repo_15min: tuple[TrackRepository, DetectionMetadata],
section_flow_repo_setup: tuple[SectionRepository, FlowRepository],
) -> None:
track_repository, _ = python_track_repo_2hours
track_repository, _ = pandas_track_repo_15min
section_repository, flow_repository = section_flow_repo_setup
use_case = _build_tracks_intersecting_sections(track_repository)

use_case(section_repository.get_all())

benchmark.pedantic(
use_case,
args=(section_repository.get_all(),),
Expand All @@ -379,6 +382,7 @@ def test_python_2hours(
warmup_rounds=self.WARMUP_ROUNDS,
)

@pytest.mark.skip
def test_pandas_2hours(
self,
benchmark: BenchmarkFixture,
Expand All @@ -403,7 +407,7 @@ class TestBenchmarkCreateEvents:
ITERATIONS = 1
WARMUP_ROUNDS = 0

def test_python_15min(
def test_15min(
self,
benchmark: BenchmarkFixture,
python_track_repo_15min: tuple[TrackRepository, DetectionMetadata],
Expand All @@ -424,7 +428,7 @@ def test_python_15min(
warmup_rounds=self.WARMUP_ROUNDS,
)

def test_python_2hours(
def test_2hours(
self,
benchmark: BenchmarkFixture,
python_track_repo_2hours: tuple[TrackRepository, DetectionMetadata],
Expand All @@ -445,6 +449,7 @@ def test_python_2hours(
warmup_rounds=self.WARMUP_ROUNDS,
)

@pytest.mark.skip
def test_pandas_15min(
self,
benchmark: BenchmarkFixture,
Expand All @@ -466,6 +471,7 @@ def test_pandas_15min(
warmup_rounds=self.WARMUP_ROUNDS,
)

@pytest.mark.skip
def test_pandas_2hours(
self,
benchmark: BenchmarkFixture,
Expand Down

0 comments on commit b2306fa

Please sign in to comment.