【发布时间】:2016-10-20 01:46:42
【问题描述】:
我想对我编写的一些函数进行概要分析。我正在查看 cProfile 的文档,但我不明白以下两段代码之间的区别(如果有的话)是:
import cProfile
profile = cProfile.Profile()
result = profile.runcall(func, *args, **kwargs)
profile.dump_stats('profile.stats')
和
import cProfile
profile = cProfile.Profile()
profile.enable()
result = func(*args, **kwargs)
profile.disable()
profile.dump_stats('profile.stats')
这两个块是等价的,还是做些微妙的不同的事情?
【问题讨论】: