use jj_lib::object_id::HexPrefix;
use jj_lib::repo::Repo as _;
use super::CriterionArgs;
use super::run_bench;
use crate::cli_util::CommandHelper;
use crate::command_error::CommandError;
use crate::ui::Ui;
#[derive(clap::Args, Clone, Debug)]
pub struct BenchResolvePrefixArgs {
prefix: String,
#[command(flatten)]
criterion: CriterionArgs,
}
pub async fn cmd_bench_resolve_prefix(
ui: &mut Ui,
command: &CommandHelper,
args: &BenchResolvePrefixArgs,
) -> Result<(), CommandError> {
let workspace_command = command.workspace_helper(ui)?;
let prefix = HexPrefix::try_from_hex(&args.prefix).unwrap();
let index = workspace_command.repo().index();
let routine = || index.resolve_commit_id_prefix(&prefix);
run_bench(
ui,
&format!("resolve-prefix-{}", prefix.hex()),
&args.criterion,
routine,
)?;
Ok(())
}