From f443b41cef429e3901bcf75023b878cac43e93e6 Mon Sep 17 00:00:00 2001 From: Umut Date: Fri, 8 Oct 2021 10:52:29 +0300 Subject: [PATCH] docs(benchmarks): explain the module trick used in the measurement script with comments --- script/progress_tracker_utils/measure.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script/progress_tracker_utils/measure.py b/script/progress_tracker_utils/measure.py index 17d466720..7c88c2cf3 100644 --- a/script/progress_tracker_utils/measure.py +++ b/script/progress_tracker_utils/measure.py @@ -260,10 +260,17 @@ def main(): result = {"machine": machine, "metrics": {}, "targets": {}} scripts = list(base.glob("*.py")) - # Create a directory to store temporary scripts + # Clear the previous temporary scripts directory shutil.rmtree(".benchmarks/scripts", ignore_errors=True) + + # Copy the base directory to the new temporary scripts directory shutil.copytree(base, ".benchmarks/scripts") + # Because we copy the entire base directory to the new temporary scripts directory, + # the modified scripts will have access to helper modules defined within the base directory + # (e.g., we copy `benchmarks/common.py` to `.benchmarks/scripts/common.py` which allows + # the modified `.benchmarks/scripts/x_plus_42.py` to access `common` module`) + # Process each script under the base directory for path in scripts: # Read the script line by line