Skip to main content

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.2.0):

  • Significant performance improvements for both function and line-by-line profiling.
  • Cached function metadata at decoration time to reduce overhead during execution.
  • Optimized line-by-line tracing using code object identity comparison.
  • Implemented buffered logging for shared logs to minimize frequent file I/O.
  • Improved trace accuracy by properly capturing the final line's execution time.
  • Refactored export logic for more efficient report generation.

Changelog (v.1.1.0):

  • Added support for 2 new export formats: yaml and toml.
  • Exports now include more information: peak memory usage, timestamp, arguments, return value, filepath, line number, and docstring.
  • Added enabled and log_level options to the decorators.
  • Improved export formats for better readability.

Installation

You can install FuncProfiler using pip:

pip install funcprofiler

Supported Python Versions

FuncProfiler supports Python 3.6 and later.

Features

  • Function Profiling: Monitor a function's memory usage and execution time.
  • Line-by-Line Profiling: Get execution time and memory usage for each line of a function.
  • Shared Logging: Log profiler outputs to a .txt file.
  • File Exports: Export profiling data in various formats.
  • New Options:
    • enabled: A boolean to enable or disable profiling.
    • log_level: Set the logging level to "info" or "debug".

Export Formats

Format function_profile line_by_line_profile
txt ✅ ❌
json ✅ ✅
csv ✅ ✅
html ✅ ✅
xml ✅ ✅
md ✅ ✅
yaml ✅ ✅
toml ✅ ✅

Usage

Function Profiling

from funcprofiler import function_profile

@function_profile(export_format="html", shared_log=True, log_level="debug")
def some_function():
    return "Hello World."

message = some_function()

Line-by-Line Profiling

from funcprofiler import line_by_line_profile

@line_by_line_profile(shared_log=True, enabled=True)
def some_complicated_function(n):
    total = 0
    for i in range(n):
        for j in range(i):
            total += (i * j) ** 0.5
    return total

total = some_complicated_function(1000)

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

FuncProfiler is released under the MIT License (Modified). See the LICENSE file for details.

Metadata

Release files for funcprofiler 1.2.0

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

Source distribution (sdist)

Source distribution for funcprofiler 1.2.0
File Size Uploaded Provenance Actions
funcprofiler-1.2.0.tar.gz 9.3 kB Without provenance Details for funcprofiler-1.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 17.5 kB

Release files / funcprofiler-1.2.0.tar.gz

Download URL funcprofiler-1.2.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0d38ad91637cd901a09f2cddd5ae1464bde0e23e4319dd1be28cc1e4a28db3a1
BLAKE2b-256 checksum
How to use checksums
95797d24615cdf4feb3a016b6d9e4befee417c3a055b649ad7a1fb4d9cd8ef7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / funcprofiler-1.2.0-py3-none-any.whl

Download URL funcprofiler-1.2.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8d79df03dccf9f95d40c89a35ca31d65a3fe6f4770f07eb2dabbff6daf7d4cd
BLAKE2b-256 checksum
How to use checksums
65760be42cb78ed27ae29159578e13579e97ccc09a744d277ecd445628c4be82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for funcprofiler 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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