Skip to content

Commit

Permalink
Allow collection of performance reports for geospatial benchmarks (#1569
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hendrikmakait authored Oct 24, 2024
1 parent 2f9350c commit b727c8e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
36 changes: 36 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def pytest_addoption(parser):
"--benchmark", action="store_true", help="Collect benchmarking data for tests"
)

parser.addoption(
"--performance-report",
action="store_true",
help="Collect performance report for tests",
)

parser.addoption(
"--memray",
action="store",
Expand Down Expand Up @@ -910,3 +916,33 @@ def _memray_profile(client):
s3.put(archive, s3_performance_url)

yield _memray_profile


@pytest.fixture
def performance_report(
pytestconfig,
s3,
s3_performance_url,
s3_storage_options,
test_run_benchmark,
tmp_path,
):
if not test_run_benchmark:
yield
else:
if not pytestconfig.getoption("--performance-report"):
yield contextlib.nullcontext
else:

@contextlib.contextmanager
def _performance_report():
try:
filename = f"{s3_performance_url}/performance_report.html.gz"
with distributed.performance_report(
filename=filename, storage_options=s3_storage_options
):
yield
finally:
test_run_benchmark.performance_report_url = filename

yield _performance_report
8 changes: 6 additions & 2 deletions tests/geospatial/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def cluster_name(request, scale):


@pytest.fixture()
def client_factory(cluster_name, github_cluster_tags, benchmark_all, memray_profile):
def client_factory(
cluster_name, github_cluster_tags, benchmark_all, memray_profile, performance_report
):
import contextlib

@contextlib.contextmanager
Expand All @@ -43,7 +45,9 @@ def _(n_workers, env=None, **cluster_kwargs):
with cluster.get_client() as client:
# FIXME https://github.com/coiled/platform/issues/103
client.wait_for_workers(n_workers)
with memray_profile(client), benchmark_all(client):
with performance_report(), memray_profile(client), benchmark_all(
client
):
yield client

return _

0 comments on commit b727c8e

Please sign in to comment.