GitHoox.Bench (GitHoox v0.4.1)

Copy Markdown View Source

Benchmark each hook in the resolved configuration over N runs.

Bench.run/2 attaches a :telemetry handler on [:git_hoox, :hook, :stop], dispatches GitHoox.Runner.run(stage) the requested number of times, and aggregates per-module durations into a summary list sorted by total time. Useful for deciding whether a hook is cheap enough for pre_commit or belongs on pre_push.

Hook exceptions are collected too, since :exception events carry a duration as well. They are reported in a separate :errors count so the caller can spot hooks that crashed during the run.

Summary

Types

Aggregated stats for one hook module, all durations in milliseconds.

Functions

Sample Runner.run(stage) runs times and return a per-module summary.

Types

summary()

@type summary() :: %{
  module: module(),
  runs: non_neg_integer(),
  errors: non_neg_integer(),
  p50_ms: number(),
  p95_ms: number(),
  max_ms: number(),
  mean_ms: number(),
  total_ms: number()
}

Aggregated stats for one hook module, all durations in milliseconds.

Functions

run(stage, runs)

@spec run(GitHoox.stage(), pos_integer()) :: [summary()]

Sample Runner.run(stage) runs times and return a per-module summary.