Skip to content

Commit ea3b1ca

Browse files
fix(benchmarks): harden memory test and ruff test glob
Reset tracemalloc peak before measuring large-file parse, assert non-empty message count, extend E402 per-file-ignores to tests/**, and clarify README that benchmark tests live under tests/benchmarks/.
1 parent c1d3030 commit ea3b1ca

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

benchmarks/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Performance benchmarks
22

3+
Test files live under `tests/benchmarks/`; this directory holds only documentation and the informational `baselines.json` snapshot.
4+
35
Repeatable local measurements for parse, bulk export, and search hot paths.
46

57
## Run locally
@@ -12,7 +14,7 @@ pytest tests/benchmarks/ --benchmark-only -o addopts= -v
1214
## Memory check
1315

1416
```bash
15-
pytest tests/benchmarks/test_parse_memory.py -v
17+
pytest tests/benchmarks/test_parse_memory.py -v -o addopts=
1618
```
1719

1820
The memory test also runs as part of the normal `pytest` suite (timing benchmarks are skipped via `--benchmark-skip` in `pyproject.toml`).

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ combine-as-imports = true
3434
# CLI bootstrap: sys.path must be set before local imports.
3535
"scripts/export.py" = ["E402"]
3636
# Tests mirror the same path bootstrap before importing app/utils.
37-
"tests/*.py" = ["E402"]
37+
"tests/**/*.py" = ["E402"]

tests/benchmarks/test_parse_memory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ def test_large_parse_peak_memory_under_ceiling(parse_large_file: Path) -> None:
1414
ceiling = file_bytes * 10
1515

1616
tracemalloc.start()
17+
tracemalloc.clear_traces()
1718
try:
18-
parse_session(str(path))
19+
result = parse_session(str(path))
20+
assert len(result["messages"]) > 0, "parse_session returned no messages"
1921
_, peak = tracemalloc.get_traced_memory()
2022
finally:
2123
tracemalloc.stop()

tests/benchmarks/test_search_bench.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ def _run() -> object:
1616

1717
resp = benchmark(_run)
1818
assert resp.status_code == 200
19+
assert resp.get_json(), "expected search hits from synthetic searchable tokens"

0 commit comments

Comments
 (0)