https://github.com/eldaduzman/python-perf-unit
Decorators and utilities for python performance unit testing
https://github.com/eldaduzman/python-perf-unit
Last synced: 6 months ago
JSON representation
Decorators and utilities for python performance unit testing
- Host: GitHub
- URL: https://github.com/eldaduzman/python-perf-unit
- Owner: eldaduzman
- Created: 2023-12-12T08:28:46.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-12T08:24:28.000Z (over 1 year ago)
- Last Synced: 2025-04-15T00:54:27.840Z (6 months ago)
- Language: Python
- Size: 599 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# python-perf-unit
[](https://pypi.python.org/pypi/python-perf-unit)


[](https://opensource.org/licenses/MIT)
## `python-perf-unit` is a Python package designed to enhance unit testing with performance metrics. By integrating with Python's unittest framework, it enables the execution of test methods with performance analysis.
## Features
- **Performance Testing**: Automatically times unittest test methods.
- **Median Execution Time Assertion**: Asserts median execution time of test methods is below a specified threshold.
- **Parallel Execution**: Runs tests in parallel using multithreading.
- **Percentile Reporting**: Detailed percentile reports for test execution times.## Installation
```bash
pip install python-perf-unit
```## Usage
Decorate your unittest class with `@perf_unit_test_class` to turn standard unit tests into performance tests.```python
from perf_unit import perf_unit_test_class
import unittest@perf_unit_test_class
class MyTestCase(unittest.TestCase):def test_example1(self):
# Your test code here
passdef test_example2(self):
# Another test code
passif __name__ == '__main__':
unittest.main()```
## Code styling
### `black` used for auto-formatting code [read](https://pypi.org/project/black/),
### `pylint` used for code linting and pep8 compliance [read](https://pypi.org/project/pylint/),
### `mypy` used for type hinting [read](https://pypi.org/project/mypy/),