Skip to main content

No project description provided

Project description

pfhm (Python Function HeatMap tool)

Mini line-by-line timing tool made for debugging functions in Python.

This is not designed to be used as a large scale profiling tool - rather as a quick debugging of small functions.

Supports doc-strings, and multiline function definitions.

Usage

Install via python setup.py install.

See example.py for a full example.

Either use as a decorator,

from pfhm import profile_func


@profile_func
def func(*args, **kwargs):
	...

Where the output will be written to out.html, or inline,

profile_func(func, out_file='custom_location.html')(*args, **kwargs).

Example

As in example.py, we call the function

@profile_func
def func(x):
	list = []
	for i in range(100):
		x += 2
		list.append([4] * 500)
		x += 3
		list.append([4] * 10000)
		x += 7
	return x

And receive the output:

Example output

Custom callbacks

You can also pass a custom callback function to profile_func for per line timing functions. For example, for PyTorch you could profile the time spent in the GPU by passing the following callback:

profile_func(func, callback=torch.cuda.synchronize)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pfhm-0.3.tar.gz (92.3 kB view hashes)

Uploaded Source

Built Distribution

pfhm-0.3-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page