コード例 #1
0
ファイル: filter.py プロジェクト: zyxue/pycallgraph
def filter_depth():
    config = Config()
    config.max_depth = 1

    run(
        'max_depth',
        config=config,
        comment='Should only show a depth of one.'
    )
コード例 #2
0
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()
コード例 #3
0
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)
コード例 #4
0
ファイル: filter.py プロジェクト: e-alizadeh/pycallgraph
def filter_depth():
    config = Config()
    config.max_depth = 1

    run("max_depth", config=config, comment="Should only show a depth of one.")