Repository navigation
Tool: benchmark-gate compare command (#29) - #37
Merged
Merged
Conversation
Implements #29: wires BenchmarkComparisonEngine and the #28 comparison reporters into a real `benchmark-gate compare` command, alongside a doc-only update to CheckCommand. CompareCommand supports --format console|json|markdown (default console) and --output <path>. --output is required for json/markdown (those reporters only know how to write to a path) but optional for console (defaults to stdout) -- a conditional requirement System.CommandLine's per-option Required flag can't express, so it's validated explicitly as InvalidArguments before any I/O is attempted. --quiet controls terminal output only; it never suppresses an explicitly requested --output file. Console-to-file output renders to a StringWriter first, then writes via AtomicFileWriter -- matching JsonComparisonReporter/MarkdownComparisonReporter's atomicity guarantee (and MarkdownReporter/JunitReporter's established pattern for a text-rendered report), not a one-off raw StreamWriter that could leave a partially-written file on a mid-write failure. compare always exits Passed (0) once it successfully produces a comparison -- a regression, an added/removed benchmark, or a missing metric are comparison results, not process failures. It reuses InvalidBaselineOrPolicy (3) for a baseline load failure even though compare has no policy, matching the issue's own exit-code table. CheckCommand required no functional refactor for this issue -- its orchestration (Parse -> load baseline -> load policy -> BenchmarkComparisonEngine.Compare -> RegressionEvaluator.Evaluate -> report -> exit code) was already the real, permanent shape as of #27's compile-fix, not a stopgap. This commit only updates its doc comments to state that explicitly and to mention CompareCommand shares the same Compare step, so a reviewer doesn't assume the refactor was accidentally omitted. CompareCommandTests covers the full acceptance-criteria list: argument validation (invalid format, --output required for json/markdown), the format/output/quiet matrix (WriteReport made internal specifically for this, tested directly against a hand-built ComparisonResult), and -- via a real trimmed BenchmarkDotNet full-report JSON fixture (Fixtures/sample-results.json, 3 genuine benchmarks from an actual run, not invented) parsed by the real BenchmarkDotNetResultParser -- valid comparison, each --format option, added/removed benchmarks, and nonexistent baseline/results paths, all through Run() end to end. Baselines for these tests are built via the real BaselineFile.WriteCandidate from real parsed observations, avoiding any guessing at the parser's Identity.Job mapping or the baseline JSON schema. README.md, docs/ARCHITECTURE.md (pipeline diagram now shows compare branching directly off Compare, bypassing Check), and docs/EXIT-CODES.md updated per the issue's docs scope. Resolves #29
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires BenchmarkComparisonEngine (#26) and the comparison reporters (#28)
into a real
benchmark-gate comparecommand:benchmark-gate compare --results --baseline [--format console|json|markdown] [--output ] [--quiet]
No --policy, no --fail-on-warning, no JUnit output, no threshold
arguments -- compare is deliberately policy-free.
Also includes a doc-only update to CheckCommand (see Design notes) and
the README/ARCHITECTURE/EXIT-CODES updates this issue's scope requires.
Design notes
(defaults to stdout). This is a conditional argument requirement
System.CommandLine can't express declaratively, so it's validated
explicitly as InvalidArguments (2) before any parsing/I/O is attempted.
--output file is always written regardless of --quiet.
written via AtomicFileWriter, matching every other text-report reporter
in this codebase rather than a one-off raw StreamWriter.
severity verdict. Reuses InvalidBaselineOrPolicy (3) for baseline
failures even though compare has no policy, per the issue's exit-code
table.
matched this issue's required shape as of Core: Refactor RegressionEvaluator onto ComparisonResult #27's compile-fix. This PR
only makes that explicit in its doc comments -- flagging so this isn't
mistaken for an omitted refactor.
internal(notprivate) specifically so itsformat/output/quiet matrix is unit-testable directly, independent of
Run()'s parsing/baseline steps.
Files
trimmed BenchmarkDotNet output)
copy-to-output)
paragraph)
Testing checklist
json/markdown, console-without-output passes validation)
and nonexistent baseline/results paths all covered end-to-end
through Run() against the real fixture