V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
DaChuiZi
V2EX  ›  Python

有没有开源的工具对 Python 运行的类或函数 性能时间分析的工具

  •  
  •   DaChuiZi · 2022-12-16 16:25:12 +08:00 · 2415 次点击
    这是一个创建于 488 天前的主题,其中的信息可能已经有所发展或是发生改变。

    由于自己写的程序,部分函数 耗时较长,想统计一下哪些函数比较耗时,如果用 time 模块还得打印 print 也比较耗时,所以有没有开源的工具可以分析啊~

    7 条回复    2022-12-19 11:48:02 +08:00
    zxCoder
        1
    zxCoder  
       2022-12-16 16:27:20 +08:00
    profiler
    line_profiler
    sujin190
        2
    sujin190  
       2022-12-16 17:54:28 +08:00 via Android
    不是有 profile 么,标准支持,生成火焰图可能需要其它库
    ClericPy
        3
    ClericPy  
       2022-12-16 21:00:12 +08:00
    随手一搜不是很多么...

    Python 程序调试分析大杀器 - 知乎 - https://zhuanlan.zhihu.com/p/505344229
    lithiumii
        4
    lithiumii  
       2022-12-16 21:04:24 +08:00
    VizTracer ?
    x02
        5
    x02  
       2022-12-16 22:28:41 +08:00
    python 标准库自带 cprofile, 结果是二进制文件, 可以用自带的 pstats 查看结果.

    ```
    python -m cProfile -o script_stat.prof my_script.py
    python -m pstats script_stat.prof
    ```
    HashV2
        6
    HashV2  
       2022-12-18 10:22:44 +08:00
    penguinWWY
        7
    penguinWWY  
       2022-12-19 11:48:02 +08:00
    个人最喜欢用的是 py-spy
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5119 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 05:41 · PVG 13:41 · LAX 22:41 · JFK 01:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.