This example demonstrates the new in-process #[pg_bench] workflow.
It includes:
- a simple pure-Rust benchmark that exercises a string transform
- a mutating SPI benchmark that uses
setup = prepare_spi_fixtureandtransaction = "subtransaction_per_batch"
Benchmarks live under:
#[cfg(feature = "pg_bench")]
#[pg_schema]
mod benches { ... }The pg_bench feature is intentionally separate so benchmark wrappers and helper
dependencies are not shipped in a normal extension build.
From this directory:
cargo pgrx benchOr choose an explicit Postgres version and group name:
cargo pgrx bench pg16 --group-name initial-runTo compare against a named prior group:
cargo pgrx bench --compare-group initial-runTo print the backend PID and leave time to attach a profiler or debugger:
cargo pgrx bench --wait 10To inspect the SQL-visible wrappers without running them:
cargo pgrx bench --list