Compare test execution times from JUnit XML reports.
Project description
junit-time-diff
junit-time-diff compares test execution times from JUnit XML reports and highlights meaningful slowdowns, speedups, new tests, and removed tests.
It works especially well with pytest's built-in --junit-xml output and can compare either single runs or averages computed from multiple XML files.
Installation
pip install junit-time-diff
For local development from this repository:
pip install -e .
This installs the junit-time-diff command.
Quick Start
Single Run Comparison
pytest --junit-xml=baseline.xml
# make changes
pytest --junit-xml=current.xml
junit-time-diff baseline.xml current.xml
Averaged Comparison Across Multiple Runs
for i in {1..5}; do pytest --junit-xml=baseline$i.xml; done
# make changes
for i in {1..5}; do pytest --junit-xml=current$i.xml; done
junit-time-diff "baseline*.xml" "current*.xml"
Quoting the glob pattern is recommended so the tool receives the pattern and expands it consistently.
CLI Usage
junit-time-diff --help
usage: junit-time-diff [-h] [--threshold THRESHOLD] [--min-diff MIN_DIFF]
baseline current
Arguments:
baseline: Baseline JUnit XML file or glob pattern such asbaseline.xmlorbaseline*.xmlcurrent: Current JUnit XML file or glob pattern such ascurrent.xmlorcurrent*.xml
Options:
--threshold: Ratio threshold for reporting changes, default1.10--min-diff: Minimum absolute duration change in seconds, default0.01
Example Output
================================================================================
TEST TIMING COMPARISON REPORT
================================================================================
SUMMARY
--------------------------------------------------------------------------------
Baseline: 9 tests, 3.64s total
Current: 9 tests, 3.69s total
Difference: +0.05s (+1.3%)
New tests: 1, Removed tests: 1
The report then includes any significant slower tests, faster tests, new tests, removed tests, and a final verdict.
Typical Workflows
Compare Python Versions
python3.11 -m pytest --junit-xml=py311.xml
python3.12 -m pytest --junit-xml=py312.xml
junit-time-diff py311.xml py312.xml
Compare a Specific Test Subset
pytest tests/test_api.py --junit-xml=baseline_api.xml
# make changes
pytest tests/test_api.py --junit-xml=current_api.xml
junit-time-diff baseline_api.xml current_api.xml
Use a Stricter Threshold
junit-time-diff baseline.xml current.xml --threshold 1.05
Tips
- Run several repetitions and compare averages to reduce noise.
- Compare results on the same machine when possible.
- Keep the selected test set consistent between baseline and current runs.
- Ignore tiny changes unless they are part of a repeated pattern.
Development
Build the package:
python3 -m build
Run tests:
pytest
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file junit_time_diff-0.1.0.tar.gz.
File metadata
- Download URL: junit_time_diff-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c4f507ed671bbf0e5121071a6e1f5dde9b1bc094732ba8e1724b2e88dd2fbca
|
|
| MD5 |
a0eceffd6d1646c0ddf8997edcca83eb
|
|
| BLAKE2b-256 |
f29508e38e9444657f3004ff0673de0d5dd17d5aa428125f5542fb13c09cbcca
|
File details
Details for the file junit_time_diff-0.1.0-py3-none-any.whl.
File metadata
- Download URL: junit_time_diff-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7baa52469dd6daf7dcbfabe2d3b18fb5a8e7b107eaddc8867c583997c6c25781
|
|
| MD5 |
1e4731349ba216607eba8ed3f41da19a
|
|
| BLAKE2b-256 |
46b218d3dfae3eaacb554c84eff39ea831f4ef8c0fdc09dbf7c1ca0b13383442
|