Skip to main content

A simple tool for giving immediate visual feedback on the hotspots in your code.

Project description

HeatProfile

HeatProfile is a Python decorator for profiling the execution time of individual lines within a function. It provides a detailed overview of the function's performance by highlighting each line's cumulative execution time, call count, and average time per call. Additionally, it uses color coding to visually represent the relative time spent on each line, making it easy to spot performance bottlenecks.

Features

  • Line-by-Line Profiling: Detailed execution time analysis for each line within the function.
  • Color-Coded Output: Visual representation using colors to indicate lines with higher execution times.
  • Threshold-Based Coloring: Lines with execution times significantly lower than the maximum are displayed with a white background, ensuring clarity in highlighting performance-critical areas.
  • Dynamic Column Widths: Adjusts column widths based on the length of the source code lines, ensuring readability.

Installation

To use HeatProfile, simply copy the heatprofile.py file to your project directory.

Usage

To profile a function, import heatprofile from heatprofile.py and use it as a decorator:

from heatprofile import heatprofile

@heatprofile
def your_function(args):
    # function implementation
    pass

Run your Python script as usual, and the profiling output will be displayed in the console.

Output Format

  • Function Name: Name of the profiled function.
  • Function Location: File location of the function.
  • Total Function Time: Total execution time of the function.
  • Line: Line number in the source code.
  • Source Code: The actual source code of the line.
  • Cumulative Time(s): Total time spent on this line across all calls.
  • Call Count: Number of times this line was executed.
  • Time/Call(s): Average execution time per call for this line.

Color Coding

  • Red: Lines with higher relative execution times.
  • White: Lines with negligible execution times compared to the maximum.

Compatibility

HeatProfile is compatible with Python 3.x. It has been tested on various platforms with standard Python interpreters.

Contributing

Contributions to HeatProfile are welcome. Please feel free to submit pull requests, report bugs, or suggest features through the GitHub issue tracker.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

heatprofile-0.0.11.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

heatprofile-0.0.11-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file heatprofile-0.0.11.tar.gz.

File metadata

  • Download URL: heatprofile-0.0.11.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for heatprofile-0.0.11.tar.gz
Algorithm Hash digest
SHA256 1eb763a23b61b3ec8803e40121e5b49a17b8eec29a38f8f7a21d7d80a4536354
MD5 8e342d890755ee498dfb14d5447b437c
BLAKE2b-256 9a9b47602d33a927b17004db6a2eab002211237c5806a719dadb117adb09c00a

See more details on using hashes here.

File details

Details for the file heatprofile-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: heatprofile-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for heatprofile-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 51bd27c40b941167ff072b56186d00656a8833e7897dd219023ccdcfc3c8cb37
MD5 8f977a84979cd29f35941db344fff2aa
BLAKE2b-256 a22cafa3346755c404e5e9712b101a83f3edbf6852a9c965b999591cd0f7f0ad

See more details on using hashes here.

Supported by

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