FastPII Docs
Benchmarks

Performance

Latency, throughput, and memory benchmarks for FastPII detection.

Performance

Detection latency

Per-detector latency measured on a single-core workload:

DetectorAvg (ms)Median (ms)Min (ms)
rodne_cislo0.1370.1200.080
ico0.0420.0380.025
dic0.0890.0810.060
pesel0.0950.0880.065
nip0.0580.0520.035
steuer_id0.0630.0580.040
siren0.0450.0400.028
siret0.0480.0430.030
email0.0090.0070.005
phone0.0250.0220.015
postal_code0.0120.0100.007
address0.0980.0900.065
name0.1150.1050.075

Throughput

RegionCharacters/msDocs/sec (avg doc)
CZ625312
PL450225
DE480240
FR420210

Memory footprint

  • Package size: Zero external dependencies
  • Runtime memory: ~50MB with CZ data loaded
  • Cold start: <100ms for engine initialization with one country pack
  • Warm detection: Sub-millisecond per detector per document

Pattern registry performance

The pattern registry uses @lru_cache(maxsize=1) on get_region_loaders() for cached pattern access:

from fastpii.patterns.registry import get_shared_registry

# First call loads patterns
registry = get_shared_registry()

# Subsequent calls return cached result
registry = get_shared_registry()  # cache hit

Data module benchmarking

from fastpii.data.registry import CountryRegistry

cz = CountryRegistry.get("cz")
times = cz.benchmark_import_times()

for name, ms in times.items():
    print(f"{name}: {ms:.1f}ms")

Scaling notes

  • Detection scales linearly with text length and number of registered detectors
  • Validation is O(1) for checksum-based identifiers
  • Memory grows with data module size (CZ full data: ~15MB in memory)
  • Pattern loading is cached after first access

On this page