(module, profiler, backend, passed_args=[])
| 1256 | |
| 1257 | |
| 1258 | def run_module_with_profiler(module, profiler, backend, passed_args=[]): |
| 1259 | from runpy import run_module |
| 1260 | builtins.__dict__['profile'] = profiler |
| 1261 | ns = dict(_CLEAN_GLOBALS, profile=profiler) |
| 1262 | _backend = choose_backend(backend) |
| 1263 | sys.argv = [module] + passed_args |
| 1264 | if _backend == 'tracemalloc' and has_tracemalloc: |
| 1265 | tracemalloc.start() |
| 1266 | try: |
| 1267 | run_module(module, run_name="__main__", init_globals=ns) |
| 1268 | finally: |
| 1269 | if has_tracemalloc and tracemalloc.is_tracing(): |
| 1270 | tracemalloc.stop() |
| 1271 | |
| 1272 | |
| 1273 | class LogFile(object): |
no test coverage detected