Skip to main content

An open-source Python library for finding bottlenecks in code. Includes function profiling, data exports, logging, and even line-by-line profiling, for more control.

Project description

FuncProfiler

Python Version Code Size Downloads License Compliance PyPI Version

An open-source Python library for identifying bottlenecks in code. It includes function profiling, data exports, logging, and line-by-line profiling for more granular control.

Changelog (v.1.0.2):

  • Added support for 2 new export formats: xml and md in both function profiling, and line-by-line profiling.

Installation

You can install FuncProfiler using pip:

pip install funcprofiler

Supported Python Versions

FuncProfiler supports the following Python versions:

  • Python 3.6
  • Python 3.7
  • Python 3.8
  • Python 3.9
  • Python 3.10
  • Python 3.11 and later (preferred)

Please ensure that you have one of these Python versions installed. FuncProfiler may not function as expected on earlier versions.

Features

  • Function Profiling: Monitor a function's memory usage and execution time to identify performance issues.
  • Line-by-Line Profiling: Return execution time and memory usage for each line of any given function.
  • Shared Logging: Log outputs of functions triggered by the line-by-line and function profilers, storing results in a .txt file.
  • File Exports: Export profiling data from functions in csv, json, html, xml and md formats, for both line-by-line profiling and function profiling.

[!NOTE] View more export types in the official documentation.

Usage

Function Profiling

from funcprofiler import function_profile

# Exporting as `html` with logging enabled
@function_profile(export_format="html", shared_log=True)
def some_function():
    return "Hello World."

# Call the function
message = some_function()

Line-by-Line Profiling

from funcprofiler import line_by_line_profile

# Logging enabled without exports
@line_by_line_profile(shared_log=True)
def some_complicated_function(n):
    total = 0
    for i in range(n):
        for j in range(i):
            total += (i * j) ** 0.5  # Square root calculation
    return total

# Call the function
total = some_complicated_function(1000)

[!NOTE] FuncProfiler can be added to any function using the callable format: @funcprofiler_function_name(expected_arguments).

Contributing

Contributions are welcome! If you encounter issues, have suggestions, or wish to contribute to FuncProfiler, please open an issue or submit a pull request on GitHub.

License

FuncProfiler is released under the terms of the MIT License (Modified). Please see the LICENSE file for the full text.

Modified License Clause: The modified license clause allows users to create derivative works based on the FuncProfiler software. However, it requires that any substantial changes to the software be clearly distinguished from the original work and distributed under a different name.

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

funcprofiler-1.0.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

funcprofiler-1.0.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file funcprofiler-1.0.2.tar.gz.

File metadata

  • Download URL: funcprofiler-1.0.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for funcprofiler-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5211a1387749414ac127fd063f1f4bb519febd52c1436a22e84df98b9953097b
MD5 ae293f9827b59eeee922fed401b312d3
BLAKE2b-256 44cfd5a5f5c77b849ed139237ba138d2b397ef9690e0e7a20f94ff14fe79559f

See more details on using hashes here.

File details

Details for the file funcprofiler-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: funcprofiler-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for funcprofiler-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2034304629568ae80fe77dfbf48d8a56c9861e5fc93809e9354b06705e5a0212
MD5 6b413eb7e3a7371401fb77eb98e31355
BLAKE2b-256 348c936f6945d3352a45d7923c8429725c888c1939e9e9035fd1bf4e9439e04a

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