diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ac96ef..e4e6942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,15 @@ All notable changes to BenchmarkGate are documented here. policy-free comparison. No pass/fail vocabulary in any of the three. - `Reporting.MarkdownBuilder.CodeSpan` — CommonMark-safe backtick-delimited code spans. +- `benchmark-gate compare` command — reports what changed between a + baseline and a set of results (matching, deltas, direction) without + requiring a `policy.json` or producing a pass/fail verdict. Supports + `console` (default), `json`, and `markdown` output via `--format`; + `--output ` writes to a file instead of stdout (required for + `json`/`markdown`, since those reporters only write to a path). Always + exits `Passed` (0) once it successfully produces a comparison — an + added/removed benchmark or a slower metric is a comparison result, not + a process failure. ### Changed - `Core.Comparison.MetricValue.Unit` is now `string?` rather than `string`. @@ -42,6 +51,10 @@ All notable changes to BenchmarkGate are documented here. then `RegressionEvaluator.Evaluate(comparison, policy)`, replacing the deleted `Evaluate(observations, baseline, policy)` overload. Minimal compile-fix only — `CheckCommand`'s full rewrite into pure orchestration is still #29's scope. +- `Tool.Commands.CheckCommand` documentation updated to reflect its actual + orchestration (`BenchmarkComparisonEngine.Compare` then + `RegressionEvaluator.Evaluate`) — no behavior change; the real + refactor happened during #27's compile-fix. ## [0.3.0-alpha.1] - 03/08/2026 diff --git a/README.md b/README.md index 7174ecb..0fff6c9 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,38 @@ Useful flags on `check`: | `--fail-on-warning` | Make a Warning-only suite exit non-zero | | `--quiet` | Suppress console output (reports/exit code still work) | +## Comparing without a policy + +`benchmark-gate compare` reports what changed between a baseline and a set +of results — matching, deltas, direction — without requiring a +`policy.json` or producing a pass/fail verdict. Useful for a quick "what +moved" check, a PR comment, or feeding a dashboard, when you don't want +`check`'s policy machinery in the loop. + +```bash +benchmark-gate compare --results ./BenchmarkDotNet.Artifacts/results --baseline ./benchmarks/baseline.json +``` + +Write a report to a file instead of stdout with `--format` and `--output`: + +```bash +benchmark-gate compare --results ./BenchmarkDotNet.Artifacts/results --baseline ./benchmarks/baseline.json --format json --output ./compare.json +benchmark-gate compare --results ./BenchmarkDotNet.Artifacts/results --baseline ./benchmarks/baseline.json --format markdown --output ./compare.md +``` + +`compare` always exits `0` once it successfully produces a comparison — an +added benchmark, a removed benchmark, or a metric that got slower are +comparison *results*, not process failures. Use `check` when you need a +build to fail on regression. + +Useful flags on `compare`: + +| Flag | Purpose | +|---|---| +| `--format ` | Output format (default: `console`) | +| `--output ` | Write the report to a file instead of stdout. Required for `--format json`/`--format markdown` | +| `--quiet` | Suppress console output (an explicit `--output` file still gets written) | + ## Validating inputs `benchmark-gate validate` checks a policy, baseline, and/or BenchmarkDotNet @@ -118,6 +150,7 @@ independent of `check`'s exit codes, since `validate` answers a different question (“is this file correct?”) than `check` does (“do these results pass the policy?”). + ## What this is not - Not a benchmark execution service — BenchmarkDotNet remains the diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index f0e8bac..b902f9d 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -24,11 +24,12 @@ BenchmarkDotNet, (later: Crank, custom JSON/CSV) ▼ Compare │ - ▼ - Check - │ - ▼ - Report + ┌─────────┴─────────┐ + ▼ ▼ + `compare` reports Check (policy) + │ + ▼ + `check` reports ``` The permanent boundaries, one job each: @@ -50,6 +51,13 @@ exists so the gate's pass/fail contract never depends on best-effort correlation logic — a build fails or doesn't based on Check alone, and Explain adds understanding without ever changing that decision. +Compare and Check are split for the same reason Explain is split from +Check: `compare` describes what changed without requiring a policy; +`check` applies a policy on top of the *same* comparison. Both commands +call the identical Compare step — there is one implementation of "what +changed," consumed two ways, never two implementations that happen to +agree. See ADR-0005 (comparison facts vs. evaluation verdicts) + ## Solution layout ``` diff --git a/docs/EXIT-CODES.md b/docs/EXIT-CODES.md index 0d8578d..956e16b 100644 --- a/docs/EXIT-CODES.md +++ b/docs/EXIT-CODES.md @@ -8,18 +8,18 @@ change without a major version bump. | Code | Name | Meaning | Returned by | |---|---|---|---| -| 0 | `Passed` | The command completed successfully with no failures. | `check`, `capture`, `validate` | +| 0 | `Passed` | The command completed successfully with no failures. | `check`, `compare`, `capture`, `validate` | | 1 | `Regressed` | At least one benchmark regressed past its policy's failure threshold. | `check` | -| 2 | `InvalidArguments` | The command's arguments were invalid or incomplete — e.g. an empty `--suite`, an output path that already exists without `--overwrite`, or `validate` invoked with none of `--policy`/`--baseline`/`--results`. | `check`, `capture`, `validate` | -| 3 | `InvalidBaselineOrPolicy` | The baseline or policy file failed to load — missing, malformed, or fails semantic validation. | `check` | +| 2 | `InvalidArguments` | The command's arguments were invalid or incomplete — e.g. an empty `--suite`, an output path that already exists without `--overwrite`, `compare` invoked with `--format json`/`--format markdown` and no `--output`, or `validate` invoked with none of `--policy`/`--baseline`/`--results`. | `check`, `compare`, `capture`, `validate` | +| 3 | `InvalidBaselineOrPolicy` | The baseline or policy file failed to load — missing, malformed, or fails semantic validation. | `check`, `compare` | | 4 | `IncompleteResultSet` | The baseline contains a benchmark not present in the current results (`Missing` status). | `check` | | 5 | `IncompatibleEnvironment` | Reserved for future functionality — an environment-compatibility evaluator (deferred past v0.1, see ROADMAP.md). Verified: not currently returned by `SuiteDecision.GetExitCode` or any command. | — | | 6 | `UnstableResults` | At least one benchmark failed the stability gate (too few measurements, or coefficient of variation above the policy's threshold). | `check` | | 7 | `UnapprovedNewBenchmarks` | Reserved for future functionality — a `--reject-new`-style gate on benchmarks with no baseline entry. Verified: not currently returned by `SuiteDecision.GetExitCode` or any command. | — | -| 8 | `UnsupportedSchema` | The BenchmarkDotNet results file/directory failed to parse — missing, malformed, unsupported schema, or (for `capture`) parsed to zero observations. | `check`, `capture` | +| 8 | `UnsupportedSchema` | The BenchmarkDotNet results file/directory failed to parse — missing, malformed, unsupported schema, or (for `capture`) parsed to zero observations. | `check`, `compare`, `capture` | | 9 | `Warning` | A Warning-only suite (no Regressed, Missing, or Unstable benchmarks) evaluated with `--fail-on-warning`. | `check` | | 10 | `InternalError` | An unexpected, unhandled exception reached the process boundary — a bug, not an expected failure mode. See `Program.cs`'s top-level catch. | any command | -| 11 | `OutputWriteFailure` | A requested report (Markdown/JSON/JUnit) or baseline candidate could not be written to disk. | `check`, `capture`, `validate` | +| 11 | `OutputWriteFailure` | A requested report (Markdown/JSON/JUnit) or baseline candidate could not be written to disk. | `check`, `compare`, `capture`, `validate` | | 12 | `ValidationFailed` | At least one artifact requested via `validate` has error-level diagnostics, or could not be read/parsed at all. Used uniformly regardless of whether the artifact was a policy, baseline, or results file, and regardless of whether the cause was semantic (a validation rule failed) or syntactic (malformed JSON) — `validate` answers "is this file valid", not "which parser phase rejected it". | `validate` | ## Notes @@ -40,4 +40,12 @@ change without a major version bump. (`IncompleteResultSet`) > `Unstable` (`UnstableResults`) > `Warning`-if-`--fail-on-warning` > `Passed`. A regression always wins over a missing or unstable benchmark, so CI surfaces the most - actionable failure first. \ No newline at end of file + actionable failure first. +- **`compare` has no severity verdict at all.** Unlike `check`, `compare` + always returns `Passed` (0) once it successfully produces a comparison — + a regression, an added/removed benchmark, or a missing metric are + comparison *results*, not process failures. `compare` never returns + `Regressed`, `IncompleteResultSet`, `UnstableResults`, `Warning`, or + `ValidationFailed`; those are `check`-only (or, for `ValidationFailed`, + `validate`-only) outcomes that require a policy or validation rules + `compare` doesn't have. \ No newline at end of file diff --git a/src/BenchmarkGate.Tool/Commands/CheckCommand.cs b/src/BenchmarkGate.Tool/Commands/CheckCommand.cs index 9554bba..d65ea8f 100644 --- a/src/BenchmarkGate.Tool/Commands/CheckCommand.cs +++ b/src/BenchmarkGate.Tool/Commands/CheckCommand.cs @@ -12,14 +12,24 @@ namespace Bijecta.BenchmarkGate.Tool.Commands; /// /// Implements benchmark-gate check. Argument acquisition lives in /// Program.cs (System.CommandLine, per ADR-0002). This type orchestrates: -/// parse -> load baseline -> load policy -> evaluate -> report -> exit code. +/// parse -> load baseline -> load policy -> BenchmarkComparisonEngine.Compare +/// -> RegressionEvaluator.Evaluate -> report -> exit code. /// /// +/// /// Report files are written independently (Markdown, JSON, JUnit are not a /// transaction) — if a later report fails, earlier ones may already exist /// on disk. That's deliberate: these are separate artifacts, not a single /// atomic output, and best-effort sequential writing is the right model /// here rather than a cross-file rollback. +/// +/// +/// This type must not itself match benchmarks, match metrics, check units, +/// calculate deltas, or derive direction — all of that is +/// BenchmarkComparisonEngine's job, called once, from one place, same +/// as CompareCommand. It only calls RegressionEvaluator.Evaluate +/// on top of that shared comparison to apply policy — see ADR-0004. +/// /// internal static class CheckCommand { @@ -68,10 +78,6 @@ public static int Run( return ExitCodes.InvalidBaselineOrPolicy; } - // Minimal #27 compile-fix only: Compare then Evaluate, replacing the - // deleted Evaluate(observations, baseline, policy) overload. This is - // NOT #29's CheckCommand rewrite — no compare subcommand wiring, no - // reporter changes, no docs. That work stays scoped to #29. var comparison = BenchmarkComparisonEngine.Compare(baseline, observations); var decision = RegressionEvaluator.Evaluate(comparison, policy); diff --git a/src/BenchmarkGate.Tool/Commands/CompareCommand.cs b/src/BenchmarkGate.Tool/Commands/CompareCommand.cs new file mode 100644 index 0000000..a8af37b --- /dev/null +++ b/src/BenchmarkGate.Tool/Commands/CompareCommand.cs @@ -0,0 +1,149 @@ +using Bijecta.BenchmarkGate.BenchmarkDotNet.Parsing; +using Bijecta.BenchmarkGate.Core.Baseline; +using Bijecta.BenchmarkGate.Core.Comparison; +using Bijecta.BenchmarkGate.Core.Evaluation; +using Bijecta.BenchmarkGate.Core.Model; +using Bijecta.BenchmarkGate.Reporting; +using Bijecta.BenchmarkGate.Storage.FileSystem; +using Bijecta.BenchmarkGate.Tool.Baseline; + +namespace Bijecta.BenchmarkGate.Tool.Commands; + +/// +/// Implements benchmark-gate compare. Argument acquisition lives in +/// Program.cs (System.CommandLine, per ADR-0002). This type orchestrates: +/// parse -> load baseline -> BenchmarkComparisonEngine.Compare -> report -> +/// exit code. +/// +/// +/// No policy acquisition anywhere in this path — compare is deliberately +/// policy-free. This type must not itself match benchmarks, match metrics, +/// check units, calculate deltas, or derive direction — all of that is +/// BenchmarkComparisonEngine's job, called once, from one place, +/// same as CheckCommand. +/// +internal static class CompareCommand +{ + public static int Run( + string resultsPath, + string baselinePath, + string format, + string? outputPath, + bool quiet, + TextWriter stdout, + TextWriter stderr) + { + if (format is not ("console" or "json" or "markdown")) + { + stderr.WriteLine($"Invalid --format value '{format}'. Expected console, json, or markdown."); + return ExitCodes.InvalidArguments; + } + + // console can go to stdout with no --output; json/markdown + // reporters only know how to write to a path (see #28), so + // --output is required for those two. Validated here, before any + // I/O — nothing has been attempted yet, so this is InvalidArguments, + // not a write failure. This is a conditional requirement + // System.CommandLine's per-option Required flag can't express on + // its own. + if (format is "json" or "markdown" && string.IsNullOrWhiteSpace(outputPath)) + { + stderr.WriteLine($"--output is required when --format is '{format}'."); + return ExitCodes.InvalidArguments; + } + + IReadOnlyList observations; + try + { + observations = BenchmarkDotNetResultParser.ParsePath(resultsPath); + } + catch (BenchmarkResultParseException ex) + { + stderr.WriteLine($"Failed to parse results: {ex.Message}"); + return ExitCodes.UnsupportedSchema; + } + + BenchmarkBaseline baseline; + try + { + baseline = BaselineFile.Load(baselinePath); + } + catch (BaselineFileException ex) + { + stderr.WriteLine($"Failed to load baseline: {ex.Message}"); + return ExitCodes.InvalidBaselineOrPolicy; + } + + var comparison = BenchmarkComparisonEngine.Compare(baseline, observations); + + try + { + WriteReport(comparison, format, outputPath, quiet, stdout); + } + catch (ReportWriteException ex) + { + stderr.WriteLine($"Failed to write report: {ex.Message}"); + return ExitCodes.OutputWriteFailure; + } + + // Comparison completed, regardless of what it found — compare has + // no severity verdict. A regression, an added/removed benchmark, a + // missing metric: none of these are process failures, they're + // comparison results. + return ExitCodes.Passed; + } + + /// + /// --quiet controls terminal output only — it must never suppress an + /// explicitly requested output artifact (a file the user asked for via + /// --output still gets written even under --quiet). + /// + internal static void WriteReport( + ComparisonResult comparison, string format, string? outputPath, bool quiet, TextWriter stdout) + { + switch (format) + { + case "console" when outputPath is not null: + WriteConsoleReportToFile(comparison, outputPath); + break; + + case "console": + if (!quiet) + { + ConsoleComparisonReporter.Write(stdout, comparison); + } + break; + + case "json": + JsonComparisonReporter.Write(outputPath!, comparison); + break; + + case "markdown": + MarkdownComparisonReporter.Write(outputPath!, comparison); + break; + } + } + + /// + /// Renders console-format output to a string first, then writes it via + /// — matching JsonComparisonReporter/ + /// MarkdownComparisonReporter's atomicity guarantee (and + /// MarkdownReporter/JunitReporter's established pattern for + /// a text-rendered report) rather than a one-off raw + /// that could leave a partially-written file on a mid-write failure. + /// + private static void WriteConsoleReportToFile(ComparisonResult comparison, string outputPath) + { + using var stringWriter = new StringWriter(); + ConsoleComparisonReporter.Write(stringWriter, comparison); + + try + { + AtomicFileWriter.Write(outputPath, stringWriter.ToString()); + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) + { + throw new ReportWriteException(outputPath, "Failed to write console-format comparison report.", ex); + } + } +} \ No newline at end of file diff --git a/src/BenchmarkGate.Tool/Program.cs b/src/BenchmarkGate.Tool/Program.cs index fb6cd2c..a8ccf67 100644 --- a/src/BenchmarkGate.Tool/Program.cs +++ b/src/BenchmarkGate.Tool/Program.cs @@ -71,10 +71,31 @@ Console.Out, Console.Error)); +var compareResultsOption = new Option("--results") { Required = true }; +var compareBaselineOption = new Option("--baseline") { Required = true }; +var compareFormatOption = new Option("--format") { DefaultValueFactory = _ => "console" }; +var compareOutputOption = new Option("--output"); +var compareQuietOption = new Option("--quiet"); + +var compareCommand = new Command("compare", "Compare BenchmarkDotNet results against a baseline. Policy-free — no pass/fail verdict.") +{ + compareResultsOption, compareBaselineOption, compareFormatOption, compareOutputOption, compareQuietOption, +}; + +compareCommand.SetAction(parseResult => CompareCommand.Run( + parseResult.GetValue(compareResultsOption)!, + parseResult.GetValue(compareBaselineOption)!, + parseResult.GetValue(compareFormatOption)!, + parseResult.GetValue(compareOutputOption), + parseResult.GetValue(compareQuietOption), + Console.Out, + Console.Error)); + var rootCommand = new RootCommand("BenchmarkGate — a local-first performance regression gate for BenchmarkDotNet.") { checkCommand, + compareCommand, captureCommand, validateCommand, }; diff --git a/tests/BenchmarkGate.Tool.Tests/BenchmarkGate.Tool.Tests.csproj b/tests/BenchmarkGate.Tool.Tests/BenchmarkGate.Tool.Tests.csproj index 764aaa9..e915cb4 100644 --- a/tests/BenchmarkGate.Tool.Tests/BenchmarkGate.Tool.Tests.csproj +++ b/tests/BenchmarkGate.Tool.Tests/BenchmarkGate.Tool.Tests.csproj @@ -15,6 +15,12 @@ + + + PreserveNewest + + + diff --git a/tests/BenchmarkGate.Tool.Tests/Commands/CompareCommandTests.cs b/tests/BenchmarkGate.Tool.Tests/Commands/CompareCommandTests.cs new file mode 100644 index 0000000..4d3031c --- /dev/null +++ b/tests/BenchmarkGate.Tool.Tests/Commands/CompareCommandTests.cs @@ -0,0 +1,433 @@ +using Bijecta.BenchmarkGate.BenchmarkDotNet.Parsing; +using Bijecta.BenchmarkGate.Core.Comparison; +using Bijecta.BenchmarkGate.Core.Evaluation; +using Bijecta.BenchmarkGate.Core.Identity; +using Bijecta.BenchmarkGate.Core.Model; +using Bijecta.BenchmarkGate.Tool.Baseline; +using Bijecta.BenchmarkGate.Tool.Commands; +using FluentAssertions; +using Xunit; + +namespace Bijecta.BenchmarkGate.Tool.Tests.Commands; + +/// +/// NOTE: argument-validation and the WriteReport format/output/quiet +/// matrix are unit-level (bypass Run()'s parsing/baseline steps). The +/// Run()-level tests below use a real, trimmed BenchmarkDotNet full-report +/// JSON fixture (Fixtures/sample-results.json — 3 real benchmarks from an +/// actual run, not invented) parsed by the real BenchmarkDotNetResultParser, +/// with baselines built via the real BaselineFile.WriteCandidate from those +/// real parsed observations — this avoids guessing at the parser's +/// Identity.Job mapping or the baseline JSON schema by hand. +/// +public class CompareCommandTests +{ + private static readonly string FixturesDirectory = Path.Combine(AppContext.BaseDirectory, "Fixtures"); + private static string ResultsFixturePath => Path.Combine(FixturesDirectory, "sample-results.json"); + + private static IReadOnlyList ParseFixtureObservations() => + BenchmarkDotNetResultParser.ParsePath(ResultsFixturePath); + + /// + /// Writes a baseline file from real parsed observations via the real + /// BaselineFile.WriteCandidate — guarantees Identity (including Job) + /// matches exactly what the real parser produces, no hand-guessing. + /// + private static string WriteBaseline(IReadOnlyList observations, string suite = "test-suite") + { + var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-baseline.json"); + BaselineFile.WriteCandidate(path, suite, observations); + return path; + } + + /// + /// A baseline-only observation with an invented identity — safe to + /// fabricate since it's deliberately never meant to match anything in + /// the real results fixture (used for the Removed-benchmark case). + /// + private static BenchmarkObservation InventedObservation() => new( + new BenchmarkIdentity("Fake.Namespace.FakeType", "RemovedMethod", "Ci"), + new Dictionary { [BenchmarkObservation.MeanNanosecondsMetric] = 1000d }, + MeasurementCount: 20, + StandardDeviationNanoseconds: 5.0); + + private static string TempPath(string extension) => + Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.{extension}"); + + + // ============================================================ + // Argument validation — no fixtures needed, checked before any I/O. + // ============================================================ + + [Fact] + public void invalid_format_returns_invalid_arguments() + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + resultsPath: "nonexistent-results.json", + baselinePath: "nonexistent-baseline.json", + format: "xml", + outputPath: null, + quiet: false, + stdout, stderr); + + exitCode.Should().Be(ExitCodes.InvalidArguments); + } + + [Fact] + public void json_format_without_output_returns_invalid_arguments() + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + resultsPath: "nonexistent-results.json", + baselinePath: "nonexistent-baseline.json", + format: "json", + outputPath: null, + quiet: false, + stdout, stderr); + + exitCode.Should().Be(ExitCodes.InvalidArguments); + } + + [Fact] + public void markdown_format_without_output_returns_invalid_arguments() + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + resultsPath: "nonexistent-results.json", + baselinePath: "nonexistent-baseline.json", + format: "markdown", + outputPath: null, + quiet: false, + stdout, stderr); + + exitCode.Should().Be(ExitCodes.InvalidArguments); + } + + [Fact] + public void console_format_without_output_passes_argument_validation() + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + resultsPath: "nonexistent-results.json", + baselinePath: "nonexistent-baseline.json", + format: "console", + outputPath: null, + quiet: false, + stdout, stderr); + + exitCode.Should().Be(ExitCodes.UnsupportedSchema); + } + + // ============================================================ + // Nonexistent path + // ============================================================ + + [Fact] + public void nonexistent_results_path_returns_unsupported_schema() + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + resultsPath: Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-does-not-exist.json"), + baselinePath: "irrelevant.json", + format: "console", + outputPath: null, + quiet: false, + stdout, stderr); + + exitCode.Should().Be(ExitCodes.UnsupportedSchema); + } + + [Fact] + public void nonexistent_baseline_path_returns_invalid_baseline_or_policy() + { + // Now unblocked: results parses successfully (real fixture), so + // Run() actually reaches the baseline-loading step. + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + resultsPath: ResultsFixturePath, + baselinePath: Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-does-not-exist.json"), + format: "console", + outputPath: null, + quiet: true, + stdout, stderr); + + exitCode.Should().Be(ExitCodes.InvalidBaselineOrPolicy); + } + + // ============================================================ + // Valid comparison through Run() — real fixture end to end. + // ============================================================ + + [Fact] + public void valid_comparison_with_a_matching_baseline_returns_passed() + { + var observations = ParseFixtureObservations(); + var baselinePath = WriteBaseline(observations); + try + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + ResultsFixturePath, baselinePath, "console", null, quiet: true, stdout, stderr); + + exitCode.Should().Be(ExitCodes.Passed); + } + finally + { + File.Delete(baselinePath); + } + } + + [Fact] + public void console_format_through_run_writes_stdout() + { + var observations = ParseFixtureObservations(); + var baselinePath = WriteBaseline(observations); + try + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + CompareCommand.Run(ResultsFixturePath, baselinePath, "console", null, quiet: false, stdout, stderr); + + // "BuildDictionaries" is NOT a safe substring here — the + // console table's 40-char name-column width legitimately + // truncates the full canonical identity (type + method + job + + // params) mid-word for this fixture's longer identities. + // "meanNanoseconds" is short enough to never be truncated. + stdout.ToString().Should().Contain("meanNanoseconds"); + } + finally + { + File.Delete(baselinePath); + } + } + + [Fact] + public void json_format_through_run_writes_the_output_file() + { + var observations = ParseFixtureObservations(); + var baselinePath = WriteBaseline(observations); + var outputPath = TempPath("json"); + try + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + ResultsFixturePath, baselinePath, "json", outputPath, quiet: true, stdout, stderr); + + exitCode.Should().Be(ExitCodes.Passed); + File.ReadAllText(outputPath).Should().Contain("BuildDictionaries"); + } + finally + { + File.Delete(baselinePath); + File.Delete(outputPath); + } + } + + [Fact] + public void markdown_format_through_run_writes_the_output_file() + { + var observations = ParseFixtureObservations(); + var baselinePath = WriteBaseline(observations); + var outputPath = TempPath("md"); + try + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + ResultsFixturePath, baselinePath, "markdown", outputPath, quiet: true, stdout, stderr); + + exitCode.Should().Be(ExitCodes.Passed); + File.ReadAllText(outputPath).Should().Contain("BuildDictionaries"); + } + finally + { + File.Delete(baselinePath); + File.Delete(outputPath); + } + } + + // ============================================================ + // Added / Removed through Run() — real fixture, baseline deliberately + // out of sync with it. + // ============================================================ + + [Fact] + public void a_benchmark_absent_from_the_baseline_is_reported_as_added() + { + var observations = ParseFixtureObservations(); + // Drop the last observation from the baseline — it exists in + // results but not baseline, so it becomes Added. + var baselinePath = WriteBaseline(observations.Take(observations.Count - 1).ToList()); + var outputPath = TempPath("json"); + try + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + ResultsFixturePath, baselinePath, "json", outputPath, quiet: true, stdout, stderr); + + exitCode.Should().Be(ExitCodes.Passed); + File.ReadAllText(outputPath).Should().Contain("\"added\": 1"); + } + finally + { + File.Delete(baselinePath); + File.Delete(outputPath); + } + } + + [Fact] + public void a_baseline_entry_absent_from_the_results_is_reported_as_removed() + { + var observations = ParseFixtureObservations(); + var baselinePath = WriteBaseline([.. observations, InventedObservation()]); + var outputPath = TempPath("json"); + try + { + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + var exitCode = CompareCommand.Run( + ResultsFixturePath, baselinePath, "json", outputPath, quiet: true, stdout, stderr); + + exitCode.Should().Be(ExitCodes.Passed); + File.ReadAllText(outputPath).Should().Contain("\"removed\": 1"); + } + finally + { + File.Delete(baselinePath); + File.Delete(outputPath); + } + } + + // ============================================================ + // WriteReport's format/output/quiet matrix — tested directly against + // a hand-built ComparisonResult, since this exercises WriteReport's + // own branching, not parsing/baseline behavior. + // ============================================================ + + private static ComparisonResult SampleComparison() => new( + "nightly", + [ + new BenchmarkComparison( + new BenchmarkIdentity("Ns.Type", "Sort", "Ci"), + BenchmarkComparisonStatus.Comparable, + new BenchmarkStabilityMeasurement(20, 1.0), + [ + new MetricComparison( + "meanNanoseconds", MetricComparisonStatus.Comparable, + new MetricDescriptor("meanNanoseconds", OptimizationDirection.LowerIsBetter, "ns"), + Reference: new MetricValue(1000d, "ns"), Candidate: new MetricValue(1100d, "ns"), + AbsoluteDelta: 100d, PercentDelta: 10d, Direction: ChangeDirection.Degradation), + ]), + ]); + + [Fact] + public void console_with_no_output_and_not_quiet_writes_stdout() + { + using var stdout = new StringWriter(); + + CompareCommand.WriteReport(SampleComparison(), "console", null, quiet: false, stdout); + + stdout.ToString().Should().Contain("nightly"); + } + + [Fact] + public void console_with_no_output_and_quiet_writes_nothing_to_stdout() + { + using var stdout = new StringWriter(); + + CompareCommand.WriteReport(SampleComparison(), "console", null, quiet: true, stdout); + + stdout.ToString().Should().BeEmpty(); + } + + [Fact] + public void console_with_output_writes_the_file_not_stdout_regardless_of_quiet() + { + using var stdout = new StringWriter(); + var path = TempPath("txt"); + try + { + CompareCommand.WriteReport(SampleComparison(), "console", path, quiet: false, stdout); + + stdout.ToString().Should().BeEmpty(); + File.ReadAllText(path).Should().Contain("nightly"); + } + finally + { + File.Delete(path); + } + } + + [Fact] + public void console_with_output_and_quiet_still_writes_the_file() + { + using var stdout = new StringWriter(); + var path = TempPath("txt"); + try + { + CompareCommand.WriteReport(SampleComparison(), "console", path, quiet: true, stdout); + + File.ReadAllText(path).Should().Contain("nightly"); + } + finally + { + File.Delete(path); + } + } + + [Fact] + public void json_format_writes_the_output_file() + { + using var stdout = new StringWriter(); + var path = TempPath("json"); + try + { + CompareCommand.WriteReport(SampleComparison(), "json", path, quiet: false, stdout); + + File.ReadAllText(path).Should().Contain("\"schemaVersion\""); + } + finally + { + File.Delete(path); + } + } + + [Fact] + public void markdown_format_writes_the_output_file() + { + using var stdout = new StringWriter(); + var path = TempPath("md"); + try + { + CompareCommand.WriteReport(SampleComparison(), "markdown", path, quiet: false, stdout); + + File.ReadAllText(path).Should().Contain("Benchmark Compare"); + } + finally + { + File.Delete(path); + } + } +} \ No newline at end of file diff --git a/tests/BenchmarkGate.Tool.Tests/Fixtures/sample-results.json b/tests/BenchmarkGate.Tool.Tests/Fixtures/sample-results.json new file mode 100644 index 0000000..2d924aa --- /dev/null +++ b/tests/BenchmarkGate.Tool.Tests/Fixtures/sample-results.json @@ -0,0 +1,1402 @@ +{ + "Title": "CedarRecon.Tests.Performance.ClassifierPhaseBenchmark-20260724-100412", + "HostEnvironmentInfo": { + "BenchmarkDotNetCaption": "BenchmarkDotNet", + "BenchmarkDotNetVersion": "0.15.8", + "OsVersion": "Windows 11 (10.0.26100.8875/24H2/2024Update/HudsonValley)", + "ProcessorName": "Intel Core Ultra 7 155H", + "PhysicalProcessorCount": 1, + "PhysicalCoreCount": 16, + "LogicalCoreCount": 22, + "RuntimeVersion": ".NET 10.0.10 (10.0.10, 10.0.1026.32716)", + "Architecture": "X64", + "HasAttachedDebugger": false, + "HasRyuJit": true, + "Configuration": "RELEASE", + "DotNetCliVersion": "10.0.302", + "ChronometerFrequency": { + "Hertz": 10000000 + }, + "HardwareTimerKind": "Unknown" + }, + "Benchmarks": [ + { + "DisplayInfo": "ClassifierPhaseBenchmark.BuildDictionaries: Job-ZDAPPP(IterationCount=3, LaunchCount=1, RunStrategy=Throughput, WarmupCount=1) [N=10000]", + "Namespace": "CedarRecon.Tests.Performance", + "Type": "ClassifierPhaseBenchmark", + "Method": "BuildDictionaries", + "MethodTitle": "BuildDictionaries", + "Parameters": "N=10000", + "FullName": "CedarRecon.Tests.Performance.ClassifierPhaseBenchmark.BuildDictionaries(N: 10000)", + "HardwareIntrinsics": "AVX2+BMI1+BMI2+F16C+FMA+LZCNT+MOVBE,AVX,SSE3+SSSE3+SSE4.1+SSE4.2+POPCNT,X86Base+SSE+SSE2,AES+PCLMUL,AvxVnni,SERIALIZE VectorSize=256", + "Statistics": { + "OriginalValues": [ + 5373285.9375, + 5043942.96875, + 4575576.5625 + ], + "N": 3, + "Min": 4575576.5625, + "LowerFence": 4211477.734375, + "Q1": 4809759.765625, + "Median": 5043942.96875, + "Mean": 4997601.822916667, + "Q3": 5208614.453125, + "UpperFence": 5806896.484375, + "Max": 5373285.9375, + "InterquartileRange": 398854.6875, + "LowerOutliers": [], + "UpperOutliers": [], + "AllOutliers": [], + "StandardError": 231441.63273460718, + "Variance": 160695688088.58237, + "StandardDeviation": 400868.66688303585, + "Skewness": -0.11405693869343997, + "Kurtosis": 0.666666666666667, + "ConfidenceInterval": { + "N": 3, + "Mean": 4997601.822916667, + "StandardError": 231441.63273460718, + "Level": 12, + "Margin": 7313336.754447189, + "Lower": -2315734.931530522, + "Upper": 12310938.577363856 + }, + "Percentiles": { + "P0": 4575576.5625, + "P25": 4809759.765625, + "P50": 5043942.96875, + "P67": 5155919.578125, + "P80": 5241548.75, + "P85": 5274483.046875, + "P90": 5307417.34375, + "P95": 5340351.640625, + "P100": 5373285.9375 + } + }, + "Memory": { + "Gen0Collections": 34, + "Gen1Collections": 34, + "Gen2Collections": 34, + "TotalOperations": 128, + "BytesAllocatedPerOperation": 5730018 + }, + "Measurements": [ + { + "IterationMode": "Overhead", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 1, + "Nanoseconds": 173800 + }, + { + "IterationMode": "Workload", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 1, + "Nanoseconds": 5645900 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 16, + "Nanoseconds": 360400 + }, + { + "IterationMode": "Workload", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 16, + "Nanoseconds": 93920700 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 16, + "Nanoseconds": 95104800 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 32, + "Nanoseconds": 188978600 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 64, + "Nanoseconds": 301530500 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 4, + "Operations": 128, + "Nanoseconds": 544204600 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 128, + "Nanoseconds": 1700 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 128, + "Nanoseconds": 1300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 128, + "Nanoseconds": 1400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 4, + "Operations": 128, + "Nanoseconds": 1100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 5, + "Operations": 128, + "Nanoseconds": 800 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 6, + "Operations": 128, + "Nanoseconds": 1000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 7, + "Operations": 128, + "Nanoseconds": 1100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 8, + "Operations": 128, + "Nanoseconds": 1200 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 9, + "Operations": 128, + "Nanoseconds": 1500 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 10, + "Operations": 128, + "Nanoseconds": 1500 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 128, + "Nanoseconds": 1300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 128, + "Nanoseconds": 1300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 128, + "Nanoseconds": 1100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 4, + "Operations": 128, + "Nanoseconds": 1300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 5, + "Operations": 128, + "Nanoseconds": 1000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 6, + "Operations": 128, + "Nanoseconds": 1100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 7, + "Operations": 128, + "Nanoseconds": 900 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 8, + "Operations": 128, + "Nanoseconds": 1400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 9, + "Operations": 128, + "Nanoseconds": 1300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 10, + "Operations": 128, + "Nanoseconds": 1400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 11, + "Operations": 128, + "Nanoseconds": 1100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 12, + "Operations": 128, + "Nanoseconds": 1300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 13, + "Operations": 128, + "Nanoseconds": 1100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 14, + "Operations": 128, + "Nanoseconds": 1100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 15, + "Operations": 128, + "Nanoseconds": 1000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 16, + "Operations": 128, + "Nanoseconds": 1000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 17, + "Operations": 128, + "Nanoseconds": 1000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 18, + "Operations": 128, + "Nanoseconds": 800 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 19, + "Operations": 128, + "Nanoseconds": 900 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 20, + "Operations": 128, + "Nanoseconds": 1000 + }, + { + "IterationMode": "Workload", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 128, + "Nanoseconds": 559112900 + }, + { + "IterationMode": "Workload", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 128, + "Nanoseconds": 687781700 + }, + { + "IterationMode": "Workload", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 128, + "Nanoseconds": 645625800 + }, + { + "IterationMode": "Workload", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 128, + "Nanoseconds": 585674900 + }, + { + "IterationMode": "Workload", + "IterationStage": "Result", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 128, + "Nanoseconds": 687780600 + }, + { + "IterationMode": "Workload", + "IterationStage": "Result", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 128, + "Nanoseconds": 645624700 + }, + { + "IterationMode": "Workload", + "IterationStage": "Result", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 128, + "Nanoseconds": 585673800 + } + ], + "Metrics": [ + { + "Value": 265.625, + "Descriptor": { + "Id": "Gen0Collects", + "DisplayName": "Gen0", + "Legend": "GC Generation 0 collects per 1000 operations", + "NumberFormat": "#0.0000", + "UnitType": 0, + "Unit": "Count", + "TheGreaterTheBetter": false, + "PriorityInCategory": 0 + } + }, + { + "Value": 265.625, + "Descriptor": { + "Id": "Gen1Collects", + "DisplayName": "Gen1", + "Legend": "GC Generation 1 collects per 1000 operations", + "NumberFormat": "#0.0000", + "UnitType": 0, + "Unit": "Count", + "TheGreaterTheBetter": false, + "PriorityInCategory": 1 + } + }, + { + "Value": 265.625, + "Descriptor": { + "Id": "Gen2Collects", + "DisplayName": "Gen2", + "Legend": "GC Generation 2 collects per 1000 operations", + "NumberFormat": "#0.0000", + "UnitType": 0, + "Unit": "Count", + "TheGreaterTheBetter": false, + "PriorityInCategory": 2 + } + }, + { + "Value": 5730018, + "Descriptor": { + "Id": "Allocated Memory", + "DisplayName": "Allocated", + "Legend": "Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)", + "NumberFormat": "0.##", + "UnitType": 2, + "Unit": "B", + "TheGreaterTheBetter": false, + "PriorityInCategory": 3 + } + } + ] + }, + { + "DisplayInfo": "ClassifierPhaseBenchmark.BuildDictionariesFast: Job-ZDAPPP(IterationCount=3, LaunchCount=1, RunStrategy=Throughput, WarmupCount=1) [N=10000]", + "Namespace": "CedarRecon.Tests.Performance", + "Type": "ClassifierPhaseBenchmark", + "Method": "BuildDictionariesFast", + "MethodTitle": "BuildDictionariesFast", + "Parameters": "N=10000", + "FullName": "CedarRecon.Tests.Performance.ClassifierPhaseBenchmark.BuildDictionariesFast(N: 10000)", + "HardwareIntrinsics": "AVX2+BMI1+BMI2+F16C+FMA+LZCNT+MOVBE,AVX,SSE3+SSSE3+SSE4.1+SSE4.2+POPCNT,X86Base+SSE+SSE2,AES+PCLMUL,AvxVnni,SERIALIZE VectorSize=256", + "Statistics": { + "OriginalValues": [ + 1571691.40625, + 1665826.953125, + 1685092.96875 + ], + "N": 3, + "Min": 1571691.40625, + "LowerFence": 1533708.0078125, + "Q1": 1618759.1796875, + "Median": 1665826.953125, + "Mean": 1640870.4427083333, + "Q3": 1675459.9609375, + "UpperFence": 1760511.1328125, + "Max": 1685092.96875, + "InterquartileRange": 56700.78125, + "LowerOutliers": [], + "UpperOutliers": [], + "AllOutliers": [], + "StandardError": 35033.7891826983, + "Variance": 3682099153.4932456, + "StandardDeviation": 60680.30284609039, + "Skewness": -0.34171079246858826, + "Kurtosis": 0.6666666666666649, + "ConfidenceInterval": { + "N": 3, + "Mean": 1640870.4427083333, + "StandardError": 35033.7891826983, + "Level": 12, + "Margin": 1107034.6119238662, + "Lower": 533835.830784467, + "Upper": 2747905.0546321995 + }, + "Percentiles": { + "P0": 1571691.40625, + "P25": 1618759.1796875, + "P50": 1665826.953125, + "P67": 1672377.3984375, + "P80": 1677386.5625, + "P85": 1679313.1640625, + "P90": 1681239.765625, + "P95": 1683166.3671875, + "P100": 1685092.96875 + } + }, + "Memory": { + "Gen0Collections": 69, + "Gen1Collections": 69, + "Gen2Collections": 69, + "TotalOperations": 512, + "BytesAllocatedPerOperation": 2514123 + }, + "Measurements": [ + { + "IterationMode": "Overhead", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 1, + "Nanoseconds": 177300 + }, + { + "IterationMode": "Workload", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 1, + "Nanoseconds": 6499300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 16, + "Nanoseconds": 431700 + }, + { + "IterationMode": "Workload", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 16, + "Nanoseconds": 35432800 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 16, + "Nanoseconds": 31541000 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 32, + "Nanoseconds": 53687200 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 64, + "Nanoseconds": 107084200 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 4, + "Operations": 128, + "Nanoseconds": 205239800 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 5, + "Operations": 256, + "Nanoseconds": 397028200 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 6, + "Operations": 512, + "Nanoseconds": 781169500 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 512, + "Nanoseconds": 2600 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 512, + "Nanoseconds": 2200 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 512, + "Nanoseconds": 2300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 4, + "Operations": 512, + "Nanoseconds": 2100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 5, + "Operations": 512, + "Nanoseconds": 2300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 6, + "Operations": 512, + "Nanoseconds": 2600 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 7, + "Operations": 512, + "Nanoseconds": 2400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 512, + "Nanoseconds": 4400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 512, + "Nanoseconds": 2400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 512, + "Nanoseconds": 2100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 4, + "Operations": 512, + "Nanoseconds": 2400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 5, + "Operations": 512, + "Nanoseconds": 2200 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 6, + "Operations": 512, + "Nanoseconds": 2300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 7, + "Operations": 512, + "Nanoseconds": 2100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 8, + "Operations": 512, + "Nanoseconds": 2400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 9, + "Operations": 512, + "Nanoseconds": 1900 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 10, + "Operations": 512, + "Nanoseconds": 2500 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 11, + "Operations": 512, + "Nanoseconds": 2100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 12, + "Operations": 512, + "Nanoseconds": 2300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 13, + "Operations": 512, + "Nanoseconds": 2200 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 14, + "Operations": 512, + "Nanoseconds": 2400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 15, + "Operations": 512, + "Nanoseconds": 2100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 16, + "Operations": 512, + "Nanoseconds": 2400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 17, + "Operations": 512, + "Nanoseconds": 2000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 18, + "Operations": 512, + "Nanoseconds": 2200 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 19, + "Operations": 512, + "Nanoseconds": 2000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 20, + "Operations": 512, + "Nanoseconds": 2100 + }, + { + "IterationMode": "Workload", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 512, + "Nanoseconds": 834994600 + }, + { + "IterationMode": "Workload", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 512, + "Nanoseconds": 804708200 + }, + { + "IterationMode": "Workload", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 512, + "Nanoseconds": 852905600 + }, + { + "IterationMode": "Workload", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 512, + "Nanoseconds": 862769800 + }, + { + "IterationMode": "Workload", + "IterationStage": "Result", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 512, + "Nanoseconds": 804706000 + }, + { + "IterationMode": "Workload", + "IterationStage": "Result", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 512, + "Nanoseconds": 852903400 + }, + { + "IterationMode": "Workload", + "IterationStage": "Result", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 512, + "Nanoseconds": 862767600 + } + ], + "Metrics": [ + { + "Value": 134.765625, + "Descriptor": { + "Id": "Gen0Collects", + "DisplayName": "Gen0", + "Legend": "GC Generation 0 collects per 1000 operations", + "NumberFormat": "#0.0000", + "UnitType": 0, + "Unit": "Count", + "TheGreaterTheBetter": false, + "PriorityInCategory": 0 + } + }, + { + "Value": 134.765625, + "Descriptor": { + "Id": "Gen1Collects", + "DisplayName": "Gen1", + "Legend": "GC Generation 1 collects per 1000 operations", + "NumberFormat": "#0.0000", + "UnitType": 0, + "Unit": "Count", + "TheGreaterTheBetter": false, + "PriorityInCategory": 1 + } + }, + { + "Value": 134.765625, + "Descriptor": { + "Id": "Gen2Collects", + "DisplayName": "Gen2", + "Legend": "GC Generation 2 collects per 1000 operations", + "NumberFormat": "#0.0000", + "UnitType": 0, + "Unit": "Count", + "TheGreaterTheBetter": false, + "PriorityInCategory": 2 + } + }, + { + "Value": 2514123, + "Descriptor": { + "Id": "Allocated Memory", + "DisplayName": "Allocated", + "Legend": "Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)", + "NumberFormat": "0.##", + "UnitType": 2, + "Unit": "B", + "TheGreaterTheBetter": false, + "PriorityInCategory": 3 + } + } + ] + }, + { + "DisplayInfo": "ClassifierPhaseBenchmark.DuplicatePhases: Job-ZDAPPP(IterationCount=3, LaunchCount=1, RunStrategy=Throughput, WarmupCount=1) [N=10000]", + "Namespace": "CedarRecon.Tests.Performance", + "Type": "ClassifierPhaseBenchmark", + "Method": "DuplicatePhases", + "MethodTitle": "DuplicatePhases", + "Parameters": "N=10000", + "FullName": "CedarRecon.Tests.Performance.ClassifierPhaseBenchmark.DuplicatePhases(N: 10000)", + "HardwareIntrinsics": "AVX2+BMI1+BMI2+F16C+FMA+LZCNT+MOVBE,AVX,SSE3+SSSE3+SSE4.1+SSE4.2+POPCNT,X86Base+SSE+SSE2,AES+PCLMUL,AvxVnni,SERIALIZE VectorSize=256", + "Statistics": { + "OriginalValues": [ + 470316.30859375, + 463568.06640625, + 461667.7734375 + ], + "N": 3, + "Min": 461667.7734375, + "LowerFence": 456131.5185546875, + "Q1": 462617.919921875, + "Median": 463568.06640625, + "Mean": 465184.0494791667, + "Q3": 466942.1875, + "UpperFence": 473428.5888671875, + "Max": 470316.30859375, + "InterquartileRange": 4324.267578125, + "LowerOutliers": [], + "UpperOutliers": [], + "AllOutliers": [], + "StandardError": 2624.1088046667037, + "Variance": 20657841.056187946, + "StandardDeviation": 4545.089774271565, + "Skewness": 0.3105996386880843, + "Kurtosis": 0.6666666666666615, + "ConfidenceInterval": { + "N": 3, + "Mean": 465184.0494791667, + "StandardError": 2624.1088046667037, + "Level": 12, + "Margin": 82919.3569976396, + "Lower": 382264.6924815271, + "Upper": 548103.4064768063 + }, + "Percentiles": { + "P0": 461667.7734375, + "P25": 462617.919921875, + "P50": 463568.06640625, + "P67": 465862.46875, + "P80": 467617.01171875, + "P85": 468291.8359375, + "P90": 468966.66015625, + "P95": 469641.484375, + "P100": 470316.30859375 + } + }, + "Memory": { + "Gen0Collections": 132, + "Gen1Collections": 132, + "Gen2Collections": 132, + "TotalOperations": 2048, + "BytesAllocatedPerOperation": 666947 + }, + "Measurements": [ + { + "IterationMode": "Overhead", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 1, + "Nanoseconds": 184500 + }, + { + "IterationMode": "Workload", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 1, + "Nanoseconds": 5703500 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 16, + "Nanoseconds": 377500 + }, + { + "IterationMode": "Workload", + "IterationStage": "Jitting", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 16, + "Nanoseconds": 6536600 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 16, + "Nanoseconds": 5669400 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 32, + "Nanoseconds": 14075400 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 64, + "Nanoseconds": 34861100 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 4, + "Operations": 128, + "Nanoseconds": 63485800 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 5, + "Operations": 256, + "Nanoseconds": 126105500 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 6, + "Operations": 512, + "Nanoseconds": 249903900 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 7, + "Operations": 1024, + "Nanoseconds": 489318200 + }, + { + "IterationMode": "Workload", + "IterationStage": "Pilot", + "LaunchIndex": 1, + "IterationIndex": 8, + "Operations": 2048, + "Nanoseconds": 981338000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 2048, + "Nanoseconds": 5400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 2048, + "Nanoseconds": 7200 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 2048, + "Nanoseconds": 5100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 4, + "Operations": 2048, + "Nanoseconds": 5300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 5, + "Operations": 2048, + "Nanoseconds": 5200 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 2048, + "Nanoseconds": 5000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 2048, + "Nanoseconds": 5000 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 2048, + "Nanoseconds": 13600 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 4, + "Operations": 2048, + "Nanoseconds": 5400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 5, + "Operations": 2048, + "Nanoseconds": 5100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 6, + "Operations": 2048, + "Nanoseconds": 5400 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 7, + "Operations": 2048, + "Nanoseconds": 5100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 8, + "Operations": 2048, + "Nanoseconds": 5500 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 9, + "Operations": 2048, + "Nanoseconds": 5100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 10, + "Operations": 2048, + "Nanoseconds": 5100 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 11, + "Operations": 2048, + "Nanoseconds": 5200 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 12, + "Operations": 2048, + "Nanoseconds": 5300 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 13, + "Operations": 2048, + "Nanoseconds": 5200 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 14, + "Operations": 2048, + "Nanoseconds": 5600 + }, + { + "IterationMode": "Overhead", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 15, + "Operations": 2048, + "Nanoseconds": 5200 + }, + { + "IterationMode": "Workload", + "IterationStage": "Warmup", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 2048, + "Nanoseconds": 979965300 + }, + { + "IterationMode": "Workload", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 2048, + "Nanoseconds": 963213000 + }, + { + "IterationMode": "Workload", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 2048, + "Nanoseconds": 949392600 + }, + { + "IterationMode": "Workload", + "IterationStage": "Actual", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 2048, + "Nanoseconds": 945500800 + }, + { + "IterationMode": "Workload", + "IterationStage": "Result", + "LaunchIndex": 1, + "IterationIndex": 1, + "Operations": 2048, + "Nanoseconds": 963207800 + }, + { + "IterationMode": "Workload", + "IterationStage": "Result", + "LaunchIndex": 1, + "IterationIndex": 2, + "Operations": 2048, + "Nanoseconds": 949387400 + }, + { + "IterationMode": "Workload", + "IterationStage": "Result", + "LaunchIndex": 1, + "IterationIndex": 3, + "Operations": 2048, + "Nanoseconds": 945495600 + } + ], + "Metrics": [ + { + "Value": 64.453125, + "Descriptor": { + "Id": "Gen0Collects", + "DisplayName": "Gen0", + "Legend": "GC Generation 0 collects per 1000 operations", + "NumberFormat": "#0.0000", + "UnitType": 0, + "Unit": "Count", + "TheGreaterTheBetter": false, + "PriorityInCategory": 0 + } + }, + { + "Value": 64.453125, + "Descriptor": { + "Id": "Gen1Collects", + "DisplayName": "Gen1", + "Legend": "GC Generation 1 collects per 1000 operations", + "NumberFormat": "#0.0000", + "UnitType": 0, + "Unit": "Count", + "TheGreaterTheBetter": false, + "PriorityInCategory": 1 + } + }, + { + "Value": 64.453125, + "Descriptor": { + "Id": "Gen2Collects", + "DisplayName": "Gen2", + "Legend": "GC Generation 2 collects per 1000 operations", + "NumberFormat": "#0.0000", + "UnitType": 0, + "Unit": "Count", + "TheGreaterTheBetter": false, + "PriorityInCategory": 2 + } + }, + { + "Value": 666947, + "Descriptor": { + "Id": "Allocated Memory", + "DisplayName": "Allocated", + "Legend": "Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)", + "NumberFormat": "0.##", + "UnitType": 2, + "Unit": "B", + "TheGreaterTheBetter": false, + "PriorityInCategory": 3 + } + } + ] + } + ] +} \ No newline at end of file