# Instruction-counted benchmarks, measured by tak (https://github.com/jdx/tak).
#
# Everything here is pure CPU against no input but hk's own command tree: no
# network, no repository state, no pkl. Hermeticity was checked by running each
# with the proxy pointed at a dead port; all succeed unchanged, and `hk usage`
# is byte-identical run to run.
#
# `--version` is deliberately absent. It measures clap rather than hk, and a
# subject that can reach the network retires a different number of instructions
# depending on conditions unrelated to the code under test.

# The fixed cost of any invocation: process start, dynamic linking, and building
# the clap command tree. Every other benchmark here pays it too, so reading them
# against this one separates "hk got slower to start" from "this command's path
# got slower".
[bench.builtins]
cmd = ["./target/release/hk", "builtins"]

# The whole command tree, walked and serialised to ~42KB of KDL. A subcommand
# added with an expensive default shows up here first, and it is the largest
# pure-CPU path hk has that needs no configuration to run.
[bench.usage]
cmd  = ["./target/release/hk", "usage"]
runs = 10

# Warm Pkl evaluation and configuration validation. `env` immediately execs hk
# in the same process, so cachegrind continues measuring the actual binary
# without adding a shell process.
[bench.validate]
cmd = [
  "env",
  "HK_CACHE_DIR=target/tak-cache",
  "HK_CONFIG_DIR=target/tak-config",
  "HK_FILE=benchmark/pgo/hk.pkl",
  "HK_STATE_DIR=target/tak-state",
  "./target/release/hk",
  "validate",
  "--quiet",
]
runs = 10

# Representative all-files hook planning and execution: Git status, file walk,
# overlapping glob filters, batching, file locks, Tokio scheduling, and small
# subprocesses. Stashing is disabled to keep the committed fixture read-only.
[bench.check]
cmd = [
  "env",
  "HK_CACHE_DIR=target/tak-cache",
  "HK_CONFIG_DIR=target/tak-config",
  "HK_FILE=benchmark/pgo/hk.pkl",
  "HK_STATE_DIR=target/tak-state",
  "HK_STASH=false",
  "HK_STASH_UNTRACKED=false",
  "./target/release/hk",
  "check",
  "--all",
  "--quiet",
]
runs = 10
