Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmakait committed Oct 23, 2024
1 parent 7c48b5c commit b05da89
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 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 @@ -881,22 +887,23 @@ def memray_profile(
yield
elif memray_option != "scheduler":
raise ValueError(f"Unhandled value for --memray: {memray_option}")
else:

@contextlib.contextmanager
def _memray_profile(client):
profiles_path = tmp_path / "profiles"
profiles_path.mkdir()
try:
with memray.memray_scheduler(directory=profiles_path):
yield
finally:
archive = tmp_path / "memray.tar.gz"
with tarfile.open(archive, mode="w:gz") as tar:
for item in profiles_path.iterdir():
tar.add(item, arcname=item.name)
test_run_benchmark.memray_profiles_url = str(
s3_performance_url / "memray.tar.gz"
)
s3.put(archive, s3_performance_url)

yield _memray_profile
@contextlib.contextmanager
def _memray_profile(client):
profiles_path = tmp_path / "profiles"
profiles_path.mkdir()
try:
with memray.memray_scheduler(directory=profiles_path):
yield
finally:
archive = tmp_path / "memray.tar.gz"
with tarfile.open(archive, mode="w:gz") as tar:
for item in profiles_path.iterdir():
tar.add(item, arcname=item.name)
test_run_benchmark.memray_profiles_url = (
f"{s3_performance_url}/{archive.name}"
)
s3.put(archive, s3_performance_url)

yield _memray_profile

0 comments on commit b05da89

Please sign in to comment.