Skip to main content

xtask_lib/tasks/
bench.rs

1//! `cargo xtask bench` — run benchmarks with the `bench` feature enabled.
2//!
3//! Runs `cargo bench --features bench` for the workspace, activating the
4//! `bench` feature flag that exposes internal module visibility required by
5//! the criterion benchmark targets.
6
7use anyhow::Result;
8use clap::Args;
9
10use super::util::{cmd, workspace};
11
12/// Arguments for `cargo xtask bench`.
13#[derive(Debug, Args)]
14pub struct BenchArgs {}
15
16/// Runs `cargo bench --features bench` from the workspace root.
17///
18/// # Errors
19///
20/// Returns an error if the benchmark process exits non-zero.
21pub fn run(_args: BenchArgs) -> Result<()> {
22    let root = workspace::root()?;
23    cmd::run("cargo", &["bench", "--features", "bench"], &root, &[])
24}