Are your org hotfixes truly considered "hotfixes" if they take longer than 15 minutes to go live because of slow tests workflows running on GitHub Actions? To speed up this imagine benchmarking test durations to identify the slow tests when the total number of tests > 500, it seems impractical to run each test individually and manually record their duration times.
Khronos is a Python library that benchmarks the duration of Django tests. It helps identify slow-running tests in your test suite, allowing you to optimize their performance.
Feautres:
1) Benchmark Report: Create benchmark report in the terminal whenever you run your django tests and shows top 10(this no. can be configured) slowest tests.
2) Parallel Test Execution: Works with --parallel
out of the box.
3) Google Sheets Integration: Whole tests benchmark can be automatically uploaded to Google Sheets.
4) CSV Export: Whole tests benchmark can be saved in a CSV.
pip install django-khronos
or build it locallypython -m build
and install in your virtual env.- Add
TEST_RUNNER = "khronos.custom_test_runner.KhronosTestRunner"
in yoursettings.py
- If you want to increase the number of slowest tests displayed on terminal then set
KHRONOS_REPORT_MAX_ROW=
in yoursettings.py
. - If you want to add Google Sheets integration, add:
KHRONOS_SPRAEDSHEET_REPORT_GSHEET_ID = "your-google-sheet-id"
and yourKHRONOS_GSHEET_CREDS_FILE_PATH = "your-gsheet-cred-path" in your
settings.py` . - For saving the khronos benchmark report.
Tested on Django 3.2.14
. Open an issue if it's not supported in your's django version
Thanks go to these wonderful people
Abhinav Prakash |
Annay Paul |