Criterion Benchmark Process

Benches and profiling are not part of the regression test suite. They are run manually when investigating performance.

Running benchmarks

prototext-core is a pure Rust library with no pyo3 dependency. Benches can be run without special RUSTFLAGS:

cd /path/to/prototools
cargo bench -p prototext-core --bench <bench_name>

Use -- --list to verify the bench binary links and lists its targets without running measurements:

cargo bench -p prototext-core --bench <bench_name> -- --list

HTML reports from Criterion runs are written to target/criterion/.


Performance profiling

perf record requires perf_event_paranoid ≤ 1. On machines where /proc/sys/kernel/perf_event_paranoid = 2 (the default on many Linux distributions), sampling is blocked for unprivileged users.

Check the current value:

cat /proc/sys/kernel/perf_event_paranoid

If sampling is unavailable, objdump disassembly gives equivalent structural insight for tight inner loops:

# Find the bench binary (hash suffix changes with each build)
ls -t target/release/deps/<bench_name>-* | grep -v '\.d$' | head -1

# Disassemble
objdump -d --no-show-raw-insn -M intel <binary> | less

Useful objdump patterns: