美文网首页
Python:使用 pyheat 对 python 程序代码进行

Python:使用 pyheat 对 python 程序代码进行

作者: dex0423 | 来源:发表于2020-07-07 22:09 被阅读0次

    1. pyheat

    • pyheat 是一个可视化分析工具,用于分析 python 程序中执行各行代码所花费的时间;
    • pyheat 启动运行 python 程序,在程序执行结束后,基于 matplotlib 绘制出 热力图
    • 项目网站: https://pypi.org/project/py-heat/
    • 热力图样例如下:
    image.png

    2. 安装

    pip install py-heat
    

    3. 使用

    • 在命令行终端使用:
    # 查看热力图
    pyheat xxx.py
    # 导出热力图
    pyheat xxx.py --out image_file.png
    # 帮助工具
    pyheat --help
    
    • 以程序文件方式使用:
    from pyheat import PyHeat
    file_path = "xxx.py"
    ph = PyHeat(file_path)
    ph.create_heatmap()
    # 查看热力图
    ph.show_heatmap()
    # 导出热力图
    ph.show_heatmap('image_file.png')
    

    相关文章

      网友评论

          本文标题:Python:使用 pyheat 对 python 程序代码进行

          本文链接:https://www.haomeiwen.com/subject/rpctcktx.html