From b05da894d8957bf2b5c95b67906b58e6a7ce5013 Mon Sep 17 00:00:00 2001 From: Hendrik Makait Date: Wed, 23 Oct 2024 14:31:58 +0200 Subject: [PATCH] Minor --- tests/conftest.py | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 57737b6445..0f8652484e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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", @@ -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