MCPcopy Index your code
hub / github.com/python/mypy / run_benchmark

Function run_benchmark

misc/perf_compare.py:83–112  ·  view source on GitHub ↗
(
    compiled_dir: str, check_dir: str, *, incremental: bool, code: str | None, foreign: bool | None
)

Source from the content-addressed store, hash-verified

81
82
83def run_benchmark(
84 compiled_dir: str, check_dir: str, *, incremental: bool, code: str | None, foreign: bool | None
85) -> float:
86 cache_dir = os.path.join(compiled_dir, ".mypy_cache")
87 if os.path.isdir(cache_dir) and not incremental:
88 shutil.rmtree(cache_dir)
89 env = os.environ.copy()
90 env["PYTHONPATH"] = os.path.abspath(compiled_dir)
91 env["PYTHONHASHSEED"] = "1"
92 abschk = os.path.abspath(check_dir)
93 cmd = [sys.executable, "-m", "mypy"]
94 if code:
95 cmd += ["-c", code]
96 elif foreign:
97 pass
98 else:
99 cmd += ["--config-file", os.path.join(abschk, "mypy_self_check.ini")]
100 cmd += glob.glob(os.path.join(abschk, "mypy/*.py"))
101 cmd += glob.glob(os.path.join(abschk, "mypy/*/*.py"))
102 if incremental:
103 # Update a few files to force non-trivial incremental run
104 edit_python_file(os.path.join(abschk, "mypy/__main__.py"))
105 edit_python_file(os.path.join(abschk, "mypy/test/testcheck.py"))
106 t0 = time.time()
107 # Ignore errors, since some commits being measured may generate additional errors.
108 if foreign:
109 subprocess.run(cmd, cwd=check_dir, env=env)
110 else:
111 subprocess.run(cmd, cwd=compiled_dir, env=env)
112 return time.time() - t0
113
114
115def main() -> None:

Callers 1

mainFunction · 0.85

Calls 5

edit_python_fileFunction · 0.85
joinMethod · 0.45
isdirMethod · 0.45
copyMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…