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
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.
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
, orhtml
formats.
[!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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file funcprofiler-1.0.1.tar.gz
.
File metadata
- Download URL: funcprofiler-1.0.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 823e4f30202361444dd284d64a29e7d7525b42af2f22cd92138a3fc0d1cd6db0 |
|
MD5 | b08344f02a754f46bf4aafd961097e5b |
|
BLAKE2b-256 | 8bd2f0a7d8eb185062076b9bf7e839f91e2a09d48528f00d7b442884adf1a683 |
File details
Details for the file funcprofiler-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: funcprofiler-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aab95007a846586c912edf7e26cc08ea4b88214eb9a4c10474c478c80e00459b |
|
MD5 | 210d19cd931b5badbeb04ff708eda0b0 |
|
BLAKE2b-256 | ac61d629c536dfd29a97887ba3b7c76e940eacdcee5ce7333c1d88ed99ad90b0 |