An introduction to Heartrate library

An introduction to Heartrate library
This library offers a simple real time visualisation of the execution of a Python program

Simple real time visualisation of the execution of a Python program.

This library offers a simple real time visualisation of the execution of a Python program:

The numbers on the left are how many times each line has been hit. The bars show the lines that have been hit recently - longer bars mean more hits, lighter colours mean more recent.

Calls that are currently being executed are highlighted thanks to the executing library.

It also shows a live stacktrace:

Installation

pip install --user heartrate

Supports Python 3.5+.

Usage

import heartrate; heartrate.trace(browser=True)

This will:

In the file view, the stacktrace is at the bottom. In the stacktrace, you can click on stack entries for files that are being traced to open the visualisation for that file at that line.

trace only traces the thread where it is called. To trace multiple threads, you must call it in each thread, with a different port each time.

Options

from heartrate import trace, files
trace(files=files.path_contains('my_app', 'my_library'))
  1. In the stacktrace, click on stack entries for files that are being traced. This will open the page and jump to the line in that stack entry.
  2. Go to the index page at http://localhost:9999/ (you can click on the logo in the top left corner) to see a list of traced files.

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Further reading about Python

Complete Python Bootcamp: Go from zero to hero in Python 3

Machine Learning A-Z™: Hands-On Python & R In Data Science

Python and Django Full Stack Web Developer Bootcamp

Complete Python Masterclass

Python Tutorial - Python GUI Programming - Python GUI Examples (Tkinter Tutorial)

Computer Vision Using OpenCV

OpenCV Python Tutorial - Computer Vision With OpenCV In Python

Python Tutorial: Image processing with Python (Using OpenCV)

A guide to Face Detection in Python