def filter_depth(): config = Config() config.max_depth = 1 run( 'max_depth', config=config, comment='Should only show a depth of one.' )
def main(): graphviz = GraphvizOutput() graphviz.output_file = 'basic.png' config = Config() config.max_depth = 5 # 控制最大追踪深度 with PyCallGraph(output=graphviz, config=config): person = Person() for a in range(10): person.add_banana(Banana()) person.eat_bananas()
def run_with_callgraph(main_func, algo_wrapper, args=None, kwargs=None): config = Config() config.trace_filter = GlobbingFilter( exclude=['pyswarms.base.*', 'pyswarms.utils.*', 'numpy.*'], include=[ 'OptimusDem.*', 'RosenWithArgsDigitalTwin.*', 'pyswarms.*optimize', 'pyswarms.backend.*compute_objective_function', 'main', 'scipy.optimize.*basinhopping' ]) config.max_depth = 12 graphviz = GraphvizOutput(output_file='optimus_rosen_trace.png', output_type='png') with PyCallGraph(output=graphviz, config=config): if args is None: main_func(algo_wrapper) else: main_func(algo_wrapper, args, kwargs)
def filter_depth(): config = Config() config.max_depth = 1 run("max_depth", config=config, comment="Should only show a depth of one.")