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.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.

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.1.0.tar.gz (7.6 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.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: funcprofiler-1.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for funcprofiler-1.1.0.tar.gz
Algorithm Hash digest
SHA256 0ed3d9f29a916bc37027dc3cc873c9842b7abba64c9667d2b7aeaddb572afe83
MD5 471218c1521c4843af39fb7ca3ff0889
BLAKE2b-256 7e435c991daa3d4e8537a0ba6ebf511ab90a4b0c7b16cc186d32ec072f9602a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: funcprofiler-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for funcprofiler-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3b8ca5d9678a4fc157166b95de931900e08dd23f4060c8a700bd3755228d660
MD5 1017c273fc9602065cb5fa201363d8a6
BLAKE2b-256 17aaee741f3d200b5c41fb09cf01b600fd16379948e6a084aa1f94c21b07c2d5

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