|
1 | 1 | # python-perf-unit |
2 | | -Decorators and utilities for python performance unit testing |
| 2 | + |
| 3 | + |
| 4 | +[](https://pypi.python.org/pypi/python-perf-unit) |
| 5 | +<!--  --> |
| 6 | +<!--  --> |
| 7 | +<!--  --> |
| 8 | + |
| 9 | +[](https://opensource.org/licenses/MIT) |
| 10 | + |
| 11 | +`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. |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- **Performance Testing**: Automatically times unittest test methods. |
| 16 | +- **Median Execution Time Assertion**: Asserts median execution time of test methods is below a specified threshold. |
| 17 | +- **Parallel Execution**: Runs tests in parallel using multithreading. |
| 18 | +- **Percentile Reporting**: Detailed percentile reports for test execution times. |
| 19 | + |
| 20 | +## Installation |
| 21 | + |
| 22 | +```bash |
| 23 | +pip install python-perf-unit |
| 24 | +``` |
| 25 | + |
| 26 | +## Usage |
| 27 | +Decorate your unittest class with `@perf_unit_test_class` to turn standard unit tests into performance tests. |
| 28 | + |
| 29 | +```python |
| 30 | + |
| 31 | +from perf_unit import perf_unit_test_class |
| 32 | +import unittest |
| 33 | + |
| 34 | +@perf_unit_test_class |
| 35 | +class MyTestCase(unittest.TestCase): |
| 36 | + |
| 37 | + def test_example1(self): |
| 38 | + # Your test code here |
| 39 | + |
| 40 | + def test_example2(self): |
| 41 | + # Another test code |
| 42 | + |
| 43 | +if __name__ == '__main__': |
| 44 | + unittest.main() |
| 45 | + |
| 46 | + |
| 47 | +``` |
| 48 | + |
| 49 | +## Code styling |
| 50 | +### `black` used for auto-formatting code [read](https://pypi.org/project/black/), |
| 51 | +### `pylint` used for code linting and pep8 compliance [read](https://pypi.org/project/pylint/), |
| 52 | +### `mypy` used for type hinting [read](https://pypi.org/project/mypy/), |
0 commit comments