Context: There is a single shared benches crate in the workspace (benches/benches/contract_benchmarks.rs), not per-crate bench directories.
Where:
benches/benches/contract_benchmarks.rs -- add a benchmark function for the analytics contract's snapshot submission path (the one with 24 event-publish call sites -- worth knowing what it costs)
What to do:
- Add a Criterion (or existing harness, match what's already in
contract_benchmarks.rs) benchmark measuring CPU/instruction cost for the call above.
- Record a baseline number in the PR description so future gas-regression tooling (see the CI issue in this batch) has something to diff against.
Suggested approach:
- Look at whatever benchmark(s) already exist in
benches/benches/contract_benchmarks.rs for the harness pattern (Criterion or otherwise) before adding a new one.
- Benchmark the specific
analytics call path named in this issue in isolation -- set up state once, then measure only the call itself, not the setup.
- Run it against
main first to get a baseline number, then again on your branch if you're also touching this crate's logic elsewhere, and report both in your PR.
- Use the workspace's
[profile.bench] (opt-level = 3) -- don't benchmark against a debug build, the numbers are meaningless.
Watch out for:
- Soroban's real cost metric is CPU instructions / resource fees, not wall-clock time -- if the existing harness measures wall-clock only, flag that as a limitation rather than presenting it as a gas-cost benchmark.
- Benchmarks that depend on random/varying input sizes need a fixed seed or fixed input, or your baseline comparison is noise.
Definition of done:
Context: There is a single shared
benchescrate in the workspace (benches/benches/contract_benchmarks.rs), not per-crate bench directories.Where:
benches/benches/contract_benchmarks.rs-- add a benchmark function for the analytics contract's snapshot submission path (the one with 24 event-publish call sites -- worth knowing what it costs)What to do:
contract_benchmarks.rs) benchmark measuring CPU/instruction cost for the call above.Suggested approach:
benches/benches/contract_benchmarks.rsfor the harness pattern (Criterion or otherwise) before adding a new one.analyticscall path named in this issue in isolation -- set up state once, then measure only the call itself, not the setup.mainfirst to get a baseline number, then again on your branch if you're also touching this crate's logic elsewhere, and report both in your PR.[profile.bench](opt-level = 3) -- don't benchmark against a debug build, the numbers are meaningless.Watch out for:
Definition of done:
cargo bench(uses the workspace[profile.bench], opt-level 3)