def setup_tracking(project): heapmonitor.track_object(project) heapmonitor.track_class(Module) heapmonitor.track_class(Class) heapmonitor.track_class(Function) heapmonitor.track_class(Method) heapmonitor.track_class(CodeTree) heapmonitor.create_snapshot() # Finally call the real inspector. inspect_project_statically(project)
def benchmark_project_memory_usage(): # Take the argument to this script and inject it as an argument to # pythoscope's --init. application_path = sys.argv[1] sys.argv = ["pythoscope", "--init", application_path] # Inject a setup function before performing an inspection. pythoscope.inspect_project_statically = setup_tracking # Invoke pythoscope --init. pythoscope.main() # Show statistics. heapmonitor.create_snapshot() heapmonitor.print_stats(detailed=False)