Skip to content

Add benchmark: governance-voting vote-cast gas cost #44

Description

@christabel888

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 governance-voting contract's vote-cast path

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:

  1. 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.
  2. Benchmark the specific governance-voting call path named in this issue in isolation -- set up state once, then measure only the call itself, not the setup.
  3. 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.
  4. 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:

  • Benchmark added and runs via cargo bench (uses the workspace [profile.bench], opt-level 3)
  • Baseline cost recorded in the PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions