Summary
Benchmarks exist for clean() and walk() in tests/test_benchmark.py, but the three opt-in utilities (decode_evasion, detect_scripts, is_mixed_script) have no performance baselines.
What to do
Add two benchmark classes to tests/test_benchmark.py:
TestDecodeBenchmarks
- Single-layer URL decoding —
decode_evasion("%48%65%6C%6C%6F")
- Triple-nested decoding — URL-encode 3 levels deep (default max_depth=5)
- Clean text (no-op) —
decode_evasion("Hello world")
TestScriptDetectionBenchmarks
- Pure Latin —
detect_scripts("Hello world")
- Mixed script (phishing-like) — text with Cyrillic + Latin
- CJK-heavy text — paragraph of CJK characters
is_mixed_script on mixed input — verify it runs quickly
Follow the existing benchmark patterns in the file — use benchmark() for small inputs and benchmark.pedantic() for large ones (100KB+).
Files
tests/test_benchmark.py — add new classes
Hints
- Look at existing benchmarks for style:
TestCleanBenchmarks, TestWalkBenchmarks
- The opt-in imports:
from navi_sanitize import decode_evasion, detect_scripts, is_mixed_script
- Run benchmarks with:
uv run pytest tests/test_benchmark.py -v
- Regular test runs skip benchmarks:
--benchmark-disable
Summary
Benchmarks exist for
clean()andwalk()intests/test_benchmark.py, but the three opt-in utilities (decode_evasion,detect_scripts,is_mixed_script) have no performance baselines.What to do
Add two benchmark classes to
tests/test_benchmark.py:TestDecodeBenchmarksdecode_evasion("%48%65%6C%6C%6F")decode_evasion("Hello world")TestScriptDetectionBenchmarksdetect_scripts("Hello world")is_mixed_scripton mixed input — verify it runs quicklyFollow the existing benchmark patterns in the file — use
benchmark()for small inputs andbenchmark.pedantic()for large ones (100KB+).Files
tests/test_benchmark.py— add new classesHints
TestCleanBenchmarks,TestWalkBenchmarksfrom navi_sanitize import decode_evasion, detect_scripts, is_mixed_scriptuv run pytest tests/test_benchmark.py -v--benchmark-disable