与类似的东西:
def time_this(func):
@functools.wraps(func)
def what_time_is_it(*args, **kwargs):
start_time = time.clock()
print 'STARTING TIME: %f' % start_time
result = func(*args, **kwargs)
end_time = time.clock()
print 'ENDING TIME: %f' % end_time
print 'TOTAL TIME: %f' % (end_time - start_time)
return result
return what_time_is_it
我这么问是因为编写这样的描述符对我来说似乎更容易、更清晰。我认识到 profile/cprofile 尝试估计字节码编译时间等(并从运行时间中减去这些时间),所以更具体地说。
我想知道:
- a) 编译时间什么时候变得足够重要 差异重要吗?
- b) 我该如何编写自己的分析器来考虑 帐户编译时间?
最佳答案
Profile 比 cProfile 慢,但支持线程。
cProfile 速度要快得多,但据我所知,它不会分析线程(仅分析主线程,其他线程将被忽略)。
关于python - 使用 Profile 或 cProfile 我能得到什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7130718/