From 8fa5d4a7579c0d91f0aa0d1d32e8b023c651fcd9 Mon Sep 17 00:00:00 2001 From: sternj Date: Sun, 18 Oct 2020 18:11:13 -0400 Subject: [PATCH] Made file open into benchmark.py relative, renamed `scalene.py` to `entrypoint.py` to avoid naming conflicts --- benchmarks/benchmark.py | 4 ++-- scalene/__main__.py | 6 ++++-- scalene/{scalene.py => entrypoint.py} | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) rename scalene/{scalene.py => entrypoint.py} (99%) diff --git a/benchmarks/benchmark.py b/benchmarks/benchmark.py index a8f8c98e5..7c00fea8e 100644 --- a/benchmarks/benchmark.py +++ b/benchmarks/benchmark.py @@ -6,7 +6,7 @@ import statistics python = "python3" -progname = "/Users/emery/git/scalene/benchmarks/julia1_nopil.py" +progname = os.path.join(os.path.dirname(__file__), "julia1_nopil.py") number_of_runs = 1 # We take the average of this many runs. # Output timing string from the benchmark. @@ -133,7 +133,7 @@ # benchmarks = [(baseline, "baseline", "_original program_"), (pprofile_deterministic, "`pprofile` _(deterministic)_")] # benchmarks = [(baseline, "baseline", "_original program_"), (pprofile_statistical, "pprofile_statistical", "`pprofile` _(statistical)_")] -benchmarks = [(baseline, "baseline", "_original program_"), (py_spy, "py_spy", "`py-spy`")] +benchmarks = [(baseline, "baseline", "_original program_"), (py_spy, "py_spy", "`py-spy`"), (scalene_cpu, "scalene_cpu", "`scalene` _(CPU only)_"), (scalene_cpu_memory, "scalene_cpu_memory", "`scalene` _(CPU + memory)_")] average_time = {} check = ":heavy_check_mark:" diff --git a/scalene/__main__.py b/scalene/__main__.py index aaf44f800..8875d4e5f 100755 --- a/scalene/__main__.py +++ b/scalene/__main__.py @@ -1,12 +1,14 @@ import sys + def main(): try: - from scalene import scalene - scalene.Scalene.main() + from scalene import entrypoint + entrypoint.Scalene.main() except Exception as exc: sys.stderr.write("ERROR: Calling scalene main function failed: %s\n" % exc) sys.exit(1) + if __name__ == "__main__": main() diff --git a/scalene/scalene.py b/scalene/entrypoint.py similarity index 99% rename from scalene/scalene.py rename to scalene/entrypoint.py index f2186f1e8..e6766cc3c 100644 --- a/scalene/scalene.py +++ b/scalene/entrypoint.py @@ -1078,7 +1078,7 @@ def should_trace(filename: str) -> bool: if filename[0] == "<": # Not a real file. return False - if "scalene.py" in filename or "scalene/__main__.py" in filename: + if "entrypoint.py" in filename or "scalene/__main__.py" in filename: # Don't profile the profiler. return False if Scalene.__profile_all: