Scripts for measuring pdf-parser correctness, throughput, memory, and external tool comparisons. Build fast artifacts before using timings for parser decisions.
- Build pdf-parser first:
zig build -Doptimize=fast - Install MuPDF:
brew install mupdf(macOS) orapt install mupdf-tools(Linux) - Python 3 with tqdm:
pip install tqdm
Use the product-facing benchmark and eval harness for current work:
zig build benchmark-eval pdf-parser benchmark \ --manifest benchmark/eval/corpus/manifest.tsv \ --suite-id tiny-corpus \ --tools pdf-parser:adaptive,pdf-parser:native \ --thresholds benchmark/eval/thresholds.json \ --output benchmark/eval/outputs/scorecards/tiny-corpus.json \ --jsonl benchmark/eval/outputs/scorecards/tiny-corpus.records.jsonl .venv/bin/python benchmark/eval/compare.py \ --pdf-parser-adaptive \ --tools pdf-parser,pymupdf,pypdfium2,pdfplumber \ --ensure-releasefast \ --manifest benchmark/eval/corpus/manifest.tsv .venv/bin/python benchmark/eval/profile_lanes.py \ --manifest benchmark/eval/large/manifest.tsv \ --lanes native-text,adaptive-artifact-jsonl,adaptive-stream-jsonl,ocr-routed \ --repeat 3 \ --hash-output \ --output benchmark/eval/outputs/profile/large.jsonl python3 benchmark/eval/ocr_form_quality.py \ --parser zig-out/bin/pdf-parser \ --output /tmp/pdf-parser-ocr-form-quality.json
benchmark/eval/corpus is the small checked-in correctness corpus.
The raster-only expenditure form has exact row, date, vendor, amount, and total
truth. ocr_form_quality.py records OCR/rasterizer versions, applies absolute
semantic-token, exact row-tuple, and numeric-match floors, and fails when OCR
tools are unavailable. CI pins its Ubuntu runner and exact Poppler, Tesseract,
and English trained-data package versions specifically for this canonical lane.
benchmark/eval/large describes ignored local performance fixtures for
100-page, 1k-page, image-heavy, object-stream-heavy, encrypted, and table-heavy
PDFs.
Legacy script for testing against 2,907 PDFs from the veraPDF test corpus. Prefer the current benchmark runner above for release and optimization decisions.
cd benchmark
git clone https://github.com/veraPDF/veraPDF-corpus.git verapdfpython3 verapdf_bench.py
Do not treat checked-in prose as the benchmark source of truth. Generate fresh fast scorecards and profile JSONL on the machine and corpus being used for the decision.
Compare character-level accuracy against MuPDF reference output.
PYTHONPATH=../python python3 accuracy.py
Requires pypdfium2: pip install pypdfium2
Check repeated full-document extraction for accuracy-mode memory regressions.
PYTHONPATH=../python python3 memory_guard.py --pdf docs/pdf_reference.pdf
If you want this check in pytest as well, run:
ZPDF_RUN_MEMORY_GUARDS=1 PYTHONPATH=python python3 -m pytest -q python/tests/test_memory_regression.py