Name | pysniffer JSON |
Version |
0.2.0
JSON |
| download |
home_page | https://github.com/DhananjayanOnline/pysniffer |
Summary | A Python package for profiling and measuring function performance. |
upload_time | 2024-08-16 17:46:15 |
maintainer | None |
docs_url | None |
author | Dhananjay Haridas |
requires_python | >=3.6 |
license | # Released under MIT License Copyright (c) 2024 Dhananjayan H. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
profiling
performance
benchmarking
memory usage
cprofile
tracemalloc
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PySniffer
[![pypi](https://img.shields.io/pypi/v/pysniffer.svg)](https://pypi.org/project/pysniffer/)
[![Release](https://img.shields.io/github/release/dhananjayanonline/pysniffer.svg)](https://github.com/dhananjayaonline/pysniffer/releases/latest)
[![Release](https://github.com/dhananjayanonline/pysniffer/actions/workflows/releasebuild.yml/badge.svg)](https://github.com/dhananjayanonline/pysniffer/actions/workflows/releasebuild.yml)
## Overview
PySniffer is a powerful and easy-to-use Python package designed to profile and measure the performance of functions. This tool is invaluable for developers who need to optimize their code by gaining insights into execution time, CPU time, and peak memory usage. The decorator automatically logs detailed profiling data, allowing for easy analysis and debugging.
## Features
- **Execution Time Measurement**: Captures the total wall-clock time taken for the function to execute.
- **CPU Time Measurement**: Records the CPU time consumed during the function execution, identifying CPU-bound operations.
- **Memory Usage Profiling**: Tracks and logs the peak memory usage, providing insights into the memory efficiency of the function.
- **Profiling Statistics**: Utilizes the `cProfile` module to gather detailed statistics on function calls, sorted by various criteria such as cumulative time.
- **Customizable Logging**:
- **Log Level**: Set the verbosity of the logs with different logging levels (`DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`).
- **Log File**: Specify the log file path to store the profiling data.
- **Append or Overwrite**: Choose whether to append to the existing log file or overwrite it with new data.
- **Flexible Output**: Logs can be directed to both the console and a log file, providing flexibility in how the profiling information is consumed and stored.
## Installation
You can install PySniffer from PyPI using pip:
```bash
pip install pysniffer
```
## Usage
To use the benchmarking decorator, simply apply it to any function you want to profile. Customize the behavior using the decorator's parameters to suit your specific needs.
## Quick Usage
```python
from pysniffer import benchmark
@benchmark()
def example_function():
# Function implementation
pass
example_function()
```
### Full Usage Example
For more customization, you can specify parameters as follows:
```python
import logging
from pysniffer import benchmark
@benchmark(sort_by=pstats.SortKey.TIME, lines_to_print=20, log_level=logging.DEBUG, log_file="detailed_profile.log", append_log=False)
def example_function():
# Function implementation
pass
example_function()
```
### Parameters
- **sort_by (pstats.SortKey)**: Sorting key for profiling statistics. Default is `pstats.SortKey.CUMULATIVE`.
- **lines_to_print (int)**: Number of lines of profiling statistics to print. Default is 10.
- **log_level (logging.LEVEL)**: Logging level for profiling data. Default is `logging.INFO`.
- **log_file (str)**: Path to the log file for profiling data. Default is `"profile.log"`.
- **append_log (bool)**: Whether to append profiling data to the log file or overwrite it. Default is `True`.
### Benefits
- **Performance Optimization**: Identify bottlenecks and optimize the performance of your functions.
- **Resource Management**: Monitor and manage memory usage effectively.
- **Detailed Insights**: Gain in-depth understanding of function behavior through detailed profiling statistics.
- **Ease of Use**: Simple integration into existing code with customizable parameters for tailored profiling.
## License
PySniffer is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
## Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
## Acknowledgements
This project leverages Python's `cProfile`, `pstats`, and `tracemalloc` modules for profiling and memory tracking.
## Contact
For any questions or suggestions, please feel free to open an issue on the GitHub repository or contact the project maintainers.
---
Raw data
{
"_id": null,
"home_page": "https://github.com/DhananjayanOnline/pysniffer",
"name": "pysniffer",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "profiling, performance, benchmarking, memory usage, cProfile, tracemalloc",
"author": "Dhananjay Haridas",
"author_email": "Dhananjay Haridas <mail.dhananjayharidas@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/c6/e8/3fa3e50f1cba4c55aad83e48233475d34cc8625f2e6664b3676f81ba6089/pysniffer-0.2.0.tar.gz",
"platform": null,
"description": "# PySniffer\n\n[![pypi](https://img.shields.io/pypi/v/pysniffer.svg)](https://pypi.org/project/pysniffer/)\n[![Release](https://img.shields.io/github/release/dhananjayanonline/pysniffer.svg)](https://github.com/dhananjayaonline/pysniffer/releases/latest)\n[![Release](https://github.com/dhananjayanonline/pysniffer/actions/workflows/releasebuild.yml/badge.svg)](https://github.com/dhananjayanonline/pysniffer/actions/workflows/releasebuild.yml)\n\n## Overview\nPySniffer is a powerful and easy-to-use Python package designed to profile and measure the performance of functions. This tool is invaluable for developers who need to optimize their code by gaining insights into execution time, CPU time, and peak memory usage. The decorator automatically logs detailed profiling data, allowing for easy analysis and debugging.\n\n## Features\n- **Execution Time Measurement**: Captures the total wall-clock time taken for the function to execute.\n- **CPU Time Measurement**: Records the CPU time consumed during the function execution, identifying CPU-bound operations.\n- **Memory Usage Profiling**: Tracks and logs the peak memory usage, providing insights into the memory efficiency of the function.\n- **Profiling Statistics**: Utilizes the `cProfile` module to gather detailed statistics on function calls, sorted by various criteria such as cumulative time.\n- **Customizable Logging**:\n - **Log Level**: Set the verbosity of the logs with different logging levels (`DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`).\n - **Log File**: Specify the log file path to store the profiling data.\n - **Append or Overwrite**: Choose whether to append to the existing log file or overwrite it with new data.\n- **Flexible Output**: Logs can be directed to both the console and a log file, providing flexibility in how the profiling information is consumed and stored.\n\n## Installation\nYou can install PySniffer from PyPI using pip:\n\n```bash\npip install pysniffer\n```\n\n## Usage\nTo use the benchmarking decorator, simply apply it to any function you want to profile. Customize the behavior using the decorator's parameters to suit your specific needs.\n\n## Quick Usage\n```python\nfrom pysniffer import benchmark\n\n@benchmark()\ndef example_function():\n # Function implementation\n pass\n\nexample_function()\n```\n\n### Full Usage Example\nFor more customization, you can specify parameters as follows:\n```python\nimport logging\nfrom pysniffer import benchmark\n\n@benchmark(sort_by=pstats.SortKey.TIME, lines_to_print=20, log_level=logging.DEBUG, log_file=\"detailed_profile.log\", append_log=False)\ndef example_function():\n # Function implementation\n pass\n\nexample_function()\n```\n\n### Parameters\n- **sort_by (pstats.SortKey)**: Sorting key for profiling statistics. Default is `pstats.SortKey.CUMULATIVE`.\n- **lines_to_print (int)**: Number of lines of profiling statistics to print. Default is 10.\n- **log_level (logging.LEVEL)**: Logging level for profiling data. Default is `logging.INFO`.\n- **log_file (str)**: Path to the log file for profiling data. Default is `\"profile.log\"`.\n- **append_log (bool)**: Whether to append profiling data to the log file or overwrite it. Default is `True`.\n\n### Benefits\n- **Performance Optimization**: Identify bottlenecks and optimize the performance of your functions.\n- **Resource Management**: Monitor and manage memory usage effectively.\n- **Detailed Insights**: Gain in-depth understanding of function behavior through detailed profiling statistics.\n- **Ease of Use**: Simple integration into existing code with customizable parameters for tailored profiling.\n\n## License\nPySniffer is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.\n\n## Contributing\nContributions are welcome! Please fork the repository and submit a pull request with your changes.\n\n## Acknowledgements\nThis project leverages Python's `cProfile`, `pstats`, and `tracemalloc` modules for profiling and memory tracking.\n\n## Contact\nFor any questions or suggestions, please feel free to open an issue on the GitHub repository or contact the project maintainers.\n\n---\n",
"bugtrack_url": null,
"license": "# Released under MIT License Copyright (c) 2024 Dhananjayan H. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A Python package for profiling and measuring function performance.",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/DhananjayanOnline/pysniffer",
"Repository": "https://github.com/DhananjayanOnline/pysniffer"
},
"split_keywords": [
"profiling",
" performance",
" benchmarking",
" memory usage",
" cprofile",
" tracemalloc"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "72277fbfa934d8e4e1236c9712ad01ce2535633e65a6adbaa8f4ff99d715a2ce",
"md5": "a736728f2be1bee35e37a7198a03300c",
"sha256": "22140f2de93d6edc2bd5007d79dffd29af6ab6dab9cd878b839cf0c101e2912f"
},
"downloads": -1,
"filename": "pysniffer-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a736728f2be1bee35e37a7198a03300c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 7040,
"upload_time": "2024-08-16T17:46:13",
"upload_time_iso_8601": "2024-08-16T17:46:13.750969Z",
"url": "https://files.pythonhosted.org/packages/72/27/7fbfa934d8e4e1236c9712ad01ce2535633e65a6adbaa8f4ff99d715a2ce/pysniffer-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c6e83fa3e50f1cba4c55aad83e48233475d34cc8625f2e6664b3676f81ba6089",
"md5": "50dc983edfc3d733c20b47e2d53a30f6",
"sha256": "f42fbe791ab0700f7c3ac68d78396947ca5ee54ca9d9205e5b051e9d9303363b"
},
"downloads": -1,
"filename": "pysniffer-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "50dc983edfc3d733c20b47e2d53a30f6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 7268,
"upload_time": "2024-08-16T17:46:15",
"upload_time_iso_8601": "2024-08-16T17:46:15.529836Z",
"url": "https://files.pythonhosted.org/packages/c6/e8/3fa3e50f1cba4c55aad83e48233475d34cc8625f2e6664b3676f81ba6089/pysniffer-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-16 17:46:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DhananjayanOnline",
"github_project": "pysniffer",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "pysniffer"
}