Skip to content

test: add benchmarks for opt-in utilities #19

Description

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 decodingdecode_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 Latindetect_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions