pprofile + matplotlib = Python program profiled as an awesome heatmap!

Overview

pyheat

pypiv pyv Build Status Coverage Status Licence Thanks

Profilers are extremely helpful tools. They help us dig deep into code, find and understand performance bottlenecks. But sometimes we just want to lay back, relax and still get a gist of the hot zones in our code.

A picture is worth a thousand words.

So, instead of presenting the data in tabular form, if presented as a heatmap visualization, it makes comprehending the time distribution in the given program much easier and quicker. That is exactly what is being done here !

Demo

Demo

Scroll Demo

ScrollDemo

Features

  • Simple CLI interface.
  • No complicated setup.
  • Heatmap visualization to view hot zones in code.
  • Ability to export the heatmap as an image file.
  • Ability to scroll, to help view heatmap of large py files.

Setup

Using pip

pip install py-heat

Directly from the repository

git clone https://github.com/csurfer/pyheat.git
python pyheat/setup.py install

Usage

As a command

# To view the heatmap.
pyheat <path_to_python_file>
# To output the heatmap as a file.
pyheat <path_to_python_file> --out image_file.png
pyheat --help

As a module

from pyheat import PyHeat
ph = PyHeat(<file_path>)
ph.create_heatmap()
# To view the heatmap.
ph.show_heatmap()
# To output the heatmap as a file.
ph.show_heatmap('image_file.png')

Contributing

Bug Reports and Feature Requests

Please use issue tracker for reporting bugs or feature requests.

Development

Pull requests are most welcome.

Buy the developer a cup of coffee!

If you found the utility helpful you can buy me a cup of coffee using

Donate

Comments
  • Fix for upstream pprofile changes

    Fix for upstream pprofile changes

    This addresses the bugs from the upstream changes in pprofile identified in #11.

    With these changes, the tests pass:

    Basic test to check pyheat class works end to end. ... ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.272s
    
    opened by hinnefe2 4
  • Feature request: Scrollable heatmap for longer scripts

    Feature request: Scrollable heatmap for longer scripts

    Longer (hundreds LOC) scripts will get squished by this. The solution would be breaking heatmap into manageable chunks and introducing GUI that would let you scroll through. Preferably with a minimap (a la Sublime Text) that shows where you are and overall heatmap of the script.

    enhancement 
    opened by dmitrii-ubskii 4
  • Breaking change upstream in ppfrofile

    Breaking change upstream in ppfrofile

    Hello, thanks for making this neat tool!

    It looks like this commit in pprofile changed the Profile.file_dict value to be a list instead of a single dictionary. This breaks the way pyheat parses the Profile object.

    Running the existing tests gives this failure:

    ======================================================================
    ERROR: test_pyheat_show (tests.pyheat_test.PyHeatTest)
    Basic test to check pyheat class works end to end.
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/hhinnefeld/repos/pyheat-original/tests/pyheat_test.py", line 26, in test_pyheat_show
        self.pyheat.create_heatmap()
      File "/Users/hhinnefeld/repos/pyheat-original/pyheat/pyheat.py", line 48, in create_heatmap
        self.__fetch_heatmap_data_from_profile()
      File "/Users/hhinnefeld/repos/pyheat-original/pyheat/pyheat.py", line 100, in __fetch_heatmap_data_from_profile
        line_profiles = self.__get_line_profile_data()
      File "/Users/hhinnefeld/repos/pyheat-original/pyheat/pyheat.py", line 85, in __get_line_profile_data
        return self.line_profiler.file_dict[self.pyfile.path].line_dict
    AttributeError: 'list' object has no attribute 'line_dict'
    
    ----------------------------------------------------------------------
    

    I'll take a stab at fixing this myself, if that's alright.

    opened by hinnefe2 3
  • Python file to be run should be a mandatory positional argument, not an optional one

    Python file to be run should be a mandatory positional argument, not an optional one

    pyheat --pyfile <path_to_python_file>

    should simply be:

    pyheat <path_to_python_file>

    Additionally, it could be great to support output to a file:

    pyheat --out outpath.png <path_to_python_file>

    enhancement 
    opened by ozroc 2
  • Feature Request: Code text colour inversion

    Feature Request: Code text colour inversion

    When the 'heat' gets too hot, and the highlight goes a dark maroon, black text is hardly visible. There should be some threshold that inverts text colour when the 'heat' goes to high (and thus the highlight gets too dark).

    opened by thundergolfer 2
  • matplotlib warning given when running against `test_program.py`.

    matplotlib warning given when running against `test_program.py`.

    Steps to reproduce:

    git clone https://github.com/csurfer/pyheat.git
    cd pyheat
    python3 setup.py install --user
    pyheat tests/test_program.py
    

    Results in the following warning on the line which calls set_yticklabels:

    /home/aaron/.local/lib/python3.6/site-packages/py_heat-0.0.6-py3.6.egg/pyheat/pyheat.py:158: UserWarning: FixedFormatter should only be used together with FixedLocator
    

    Strangely enough the warning doesn't appear when running the unit tests with:

    python3 setup.py test
    
    opened by AaronRobson 1
  • Installation from pip seems to be broken, tabs found in some of the files.

    Installation from pip seems to be broken, tabs found in some of the files.

    $ python3.6 -m pip install pyheat
    Defaulting to user installation because normal site-packages is not writeable
    Collecting pyheat
      Using cached PyHeat-0.2.tar.gz (66 kB)
      Preparing metadata (setup.py) ... done
    Building wheels for collected packages: pyheat
      Building wheel for pyheat (setup.py) ... done
      Created wheel for pyheat: filename=PyHeat-0.2-py3-none-any.whl size=6085 sha256=57f1673c93432b413832766cb67b8c56bc84870642eebd77343dd7d7dce54fe4
      Stored in directory: /home/james/.cache/pip/wheels/8f/9b/31/73da16b55b6b6e2f78c2d6a821be9c0ad41ce70fd2dd1e81ab
    Successfully built pyheat
    Installing collected packages: pyheat
    Successfully installed pyheat-0.2
    james:aoc$ python3.6 -m pyheat
    Traceback (most recent call last):
      File "/usr/lib64/python3.6/runpy.py", line 183, in _run_module_as_main
        mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
      File "/usr/lib64/python3.6/runpy.py", line 142, in _get_module_details
        return _get_module_details(pkg_main_name, error)
      File "/usr/lib64/python3.6/runpy.py", line 109, in _get_module_details
        __import__(pkg_name)
      File "/home/james/.local/lib/python3.6/site-packages/pyheat/__init__.py", line 1, in <module>
        from pyheat.heatmap import HeatMap
      File "/home/james/.local/lib/python3.6/site-packages/pyheat/heatmap.py", line 88
        glEnableClientState(GL_VERTEX_ARRAY)
                                           ^
    TabError: inconsistent use of tabs and spaces in indentation
    

    Also there are some old style print var (no brackets) statements in there.

    opened by jameskhedley 0
  • LOADING  Module issue - Module not found

    LOADING Module issue - Module not found

    Hi,

    I have a customized module xyz.pyd, on windows 10, which my program loads/executes perfectly as it's in the same directory. But pyheat fails to load it. Does it load the modules only from the site-packages?

    Regards

    Prabhat

    opened by prabhatM 2
  • A simple web based interface for pyheat

    A simple web based interface for pyheat

    I believe a simple web based interface can help visualize larger files better, so instead of showing the matplotlib window it opens the browser and displays a similar heatmap there.

    opened by frankhart2018 0
Owner
Vishwas B Sharma
Philomath
Vishwas B Sharma
Prometheus instrumentation library for Python applications

Prometheus Python Client The official Python 2 and 3 client for Prometheus. Three Step Demo One: Install the client: pip install prometheus-client Tw

Prometheus 3.2k Jan 7, 2023
Automatically monitor the evolving performance of Flask/Python web services.

Flask Monitoring Dashboard A dashboard for automatic monitoring of Flask web-services. Key Features • How to use • Live Demo • Feedback • Documentatio

null 663 Dec 29, 2022
Cross-platform lib for process and system monitoring in Python

Home Install Documentation Download Forum Blog Funding What's new Summary psutil (process and system utilities) is a cross-platform library for retrie

Giampaolo Rodola 9k Jan 2, 2023
Sampling profiler for Python programs

py-spy: Sampling profiler for Python programs py-spy is a sampling profiler for Python programs. It lets you visualize what your Python program is spe

Ben Frederickson 9.5k Jan 8, 2023
Monitor Memory usage of Python code

Memory Profiler This is a python module for monitoring memory consumption of a process as well as line-by-line analysis of memory consumption for pyth

null 3.7k Dec 30, 2022
Yet Another Python Profiler, but this time thread&coroutine&greenlet aware.

Yappi Yet Another Python Profiler, but this time thread&coroutine&greenlet aware. Highlights Fast: Yappi is fast. It is completely written in C and lo

Sümer Cip 1k Jan 1, 2023
Line-by-line profiling for Python

line_profiler and kernprof NOTICE: This is the official line_profiler repository. The most recent version of line-profiler on pypi points to this repo

OpenPyUtils 1.6k Dec 31, 2022
🚴 Call stack profiler for Python. Shows you why your code is slow!

pyinstrument Pyinstrument is a Python profiler. A profiler is a tool to help you 'optimize' your code - make it faster. It sounds obvious, but to get

Joe Rickerby 5k Jan 1, 2023
Visual profiler for Python

vprof vprof is a Python package providing rich and interactive visualizations for various Python program characteristics such as running time and memo

Nick Volynets 3.9k Dec 19, 2022
Scalene: a high-performance, high-precision CPU and memory profiler for Python

scalene: a high-performance CPU and memory profiler for Python by Emery Berger 中文版本 (Chinese version) About Scalene % pip install -U scalene Scalen

Emery Berger 138 Dec 30, 2022
Was an interactive continuous Python profiler.

☠ This project is not maintained anymore. We highly recommend switching to py-spy which provides better performance and usability. Profiling The profi

What! Studio 3k Dec 27, 2022
Monitor Memory usage of Python code

Memory Profiler This is a python module for monitoring memory consumption of a process as well as line-by-line analysis of memory consumption for pyth

Fabian Pedregosa 80 Nov 18, 2022
System monitor - A python-based real-time system monitoring tool

System monitor A python-based real-time system monitoring tool Screenshots Installation Run My project with these commands pip install -r requiremen

Sachit Yadav 4 Feb 11, 2022
Flame Graphs visualize profiled code

Flame Graphs visualize profiled code

Brendan Gregg 14.1k Jan 3, 2023
Sky attention heatmap of submissions to astrometry.net

astroheat Installation Requires Python 3.6+, Tested with Python 3.9.5 Install library dependencies pip install -r requirements.txt The program require

null 4 Jun 20, 2022
A CLI application that downloads your AC submissions from OJ's like Atcoder,Codeforces,CodeChef and distil it into beautiful Submission HeatMap.

Yoda A CLI that takes away the hassle of managing your submission files on different online-judges by automating the entire process of collecting and organizing your code submissions in one single Directory on your Machine also it distils User Submissions into beautiful Submission HeatMap.

Nikhar Manchanda 1 Jul 28, 2022
Sticklog2heatmap - Draw a heatmap of RC sticks from OpenTX logs or USB HID device

sticklog2heatmap Draw a heatmap of RC sticks from OpenTX logs or USB HID device

null 2 Feb 2, 2022
An awesome Python wrapper for an awesome Docker CLI!

An awesome Python wrapper for an awesome Docker CLI!

Gabriel de Marmiesse 303 Jan 3, 2023
Automatic self-diagnosis program (python required)Automatic self-diagnosis program (python required)

auto-self-checker 자동으로 자가진단 해주는 프로그램(python 필요) 중요 이 프로그램이 실행될때에는 절대로 마우스포인터를 움직이거나 키보드를 건드리면 안된다(화면인식, 마우스포인터로 직접 클릭) 사용법 프로그램을 구동할 폴더 내의 cmd창에서 pip

null 1 Dec 30, 2021