Skip to main content

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)

Metadata

Release files for pfhm 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pfhm 0.3
File Size Uploaded
pfhm-0.3.tar.gz 92.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pfhm 0.3
File Interpreter ABI Platform
pfhm-0.3-py3-none-any.whl Python 3 none any Details

Total release size: 97.6 kB

Release files / pfhm-0.3.tar.gz

Download URL pfhm-0.3.tar.gz
Size 92.3 kB
Tags Source
SHA-256 checksum
How to use checksums
595fe74d6e7413bac35e2bf4fa2dd29b05a03a25672b115ff2e47b9ec1634fc4
BLAKE2b-256 checksum
How to use checksums
98944868b082ef74749a887f78f162a747eca7a2c175b03a5182893b7f5668d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / pfhm-0.3-py3-none-any.whl

Download URL pfhm-0.3-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79c93124c4092ec6314cb944ce6ef6fed7c718a8763701269f1bcb139aca51a1
BLAKE2b-256 checksum
How to use checksums
dee383f0a4df0a0565689ecaf7dc42f63902430d7cab5b36a75d14d70671632c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page