Giter Club home page Giter Club logo

pyheat's Introduction

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

pyheat's People

Contributors

aaronrobson avatar csurfer avatar hinnefe2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyheat's Issues

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).

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.

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

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.

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

Developing a web UI update, stuck at updating the project to python3

Hi,

I intended to contribute a web UI feature to your amazing project, but I stuck while running the project in python3. I made some package and script fixes to move on but also, the used heatmap module is too outdated and does not support python3 at all. Since you've stated this project also runs on python3, I also made it my goal to fix these bugs. Do you guys have any workaround to overcome this version problem for the 'heatmap' module? The heatmap class is your main feature here and I don't want to intervene with the main algorithm.

You can check my updates from here and I appreciate any feedback to help my goal to contribute!

My sole dream is to make #17 real.

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.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.