下面的最小工作示例
from pycallgraph2 import PyCallGraph
from pycallgraph2.output import GraphvizOutput
with PyCallGraph(output=GraphvizOutput()):
None产生这个输出:

Why does PyCallGraph2 describe itself while profiling "Hello, World"?显示,我们可以通过命令行排除名称空间中的某些内容。现在我想在脚本中做这件事。
发布于 2022-10-18 19:59:21
我在拟定问题时找到了答案。pycallgraph的旧文档展示了如何进行过滤。如果我们做了一些必要的更改,例如引用pycallgraph2而不是pycallgraph,那么我们有:
from pycallgraph2 import PyCallGraph
from pycallgraph2 import Config
from pycallgraph2 import GlobbingFilter
from pycallgraph2.output import GraphvizOutput
config = Config()
config.trace_filter = GlobbingFilter(exclude=[
'pycallgraph2.*'
])
with PyCallGraph(output=GraphvizOutput(), config=config):
None这就产生了预期的结果:

https://stackoverflow.com/questions/74116810
复制相似问题