()
| 97 | |
| 98 | |
| 99 | def main() -> None: |
| 100 | check_requirements() |
| 101 | |
| 102 | parser = argparse.ArgumentParser( |
| 103 | description="Compile mypy and profile type checking using 'perf' (by default, self check)." |
| 104 | ) |
| 105 | parser.add_argument( |
| 106 | "--multi-file", |
| 107 | action="store_true", |
| 108 | help="compile mypy into one C file per module (to reduce RAM use during compilation)", |
| 109 | ) |
| 110 | parser.add_argument( |
| 111 | "--skip-compile", action="store_true", help="use compiled mypy from previous run" |
| 112 | ) |
| 113 | parser.add_argument( |
| 114 | "-c", |
| 115 | metavar="CODE", |
| 116 | default=None, |
| 117 | type=str, |
| 118 | help="profile type checking Python code fragment instead of mypy self-check", |
| 119 | ) |
| 120 | args = parser.parse_args() |
| 121 | multi_file: bool = args.multi_file |
| 122 | skip_compile: bool = args.skip_compile |
| 123 | code: str | None = args.c |
| 124 | |
| 125 | target_dir = TARGET_DIR |
| 126 | |
| 127 | if not skip_compile: |
| 128 | clone(target_dir, "HEAD") |
| 129 | |
| 130 | print(f"Building mypy in {target_dir}...") |
| 131 | build_mypy(target_dir, multi_file, cflags=CFLAGS) |
| 132 | elif not os.path.isdir(target_dir): |
| 133 | sys.exit("error: Can't find compile mypy from previous run -- can't use --skip-compile") |
| 134 | |
| 135 | profile_type_check(target_dir, code) |
| 136 | |
| 137 | print() |
| 138 | print('NOTE: Compile CPython using CFLAGS="-O2 -g -fno-omit-frame-pointer" for good results') |
| 139 | print() |
| 140 | print("CPU profile collected. You can now analyze the profile:") |
| 141 | print(f" perf report -i {target_dir}/perf.data ") |
| 142 | |
| 143 | |
| 144 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…