python - 使用 Profile 或 cProfile 我能得到什么

标签 python profiling

与类似的东西:

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/

相关文章:

python - 使用 pandas 和 matplotlib 对股票数据进行回归

c - x86 汇编指令执行计数

java - Play Framework : Server monitoring and performance admin page

x86 - 不支持 perf mem 错误事件 'cpu/mem-stores/P'

python - 在 Numpy 中导出 ISO 日期

python - 函数内列表的各个元素

python - 我如何分析由多个模块和类组成的 python 脚本?

c++ - C LuaJit 分析

python - 在 python 3 中更改 .format 长度

python - openerp刷新页面时Treeview不包含记录?