diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f316c56..e138da5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,11 @@ env: jobs: build-and-test: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -31,12 +35,47 @@ jobs: - name: Build run: dotnet build --no-restore -c Release - - name: Test - run: dotnet test --no-build -c Release --logger "trx" --results-directory ./artifacts/test-results + # Solution-wide: this includes BenchmarkGate.IntegrationTests, which + # packs + installs the real Tool project and invokes it as a real + # subprocess -- not an in-process Command.Run() shortcut. Running on + # all three OSes here is the actual point: BenchmarkGate is installed + # via `dotnet tool install` on all three, so a single-OS CI run + # doesn't prove it's genuinely portable. + - name: Test with coverage + run: > + dotnet test --no-build -c Release + --logger "trx" + --results-directory ./artifacts/test-results + --collect:"XPlat Code Coverage" + --settings coverlet.runsettings - name: Upload test results if: always() uses: actions/upload-artifact@v4 with: - name: test-results + name: test-results-${{ matrix.os }} path: ./artifacts/test-results + + - name: Generate local HTML coverage report + if: matrix.os == 'ubuntu-latest' + run: | + dotnet tool install -g dotnet-reportgenerator-globaltool + reportgenerator \ + -reports:"./artifacts/test-results/**/coverage.cobertura.xml" \ + -targetdir:"./artifacts/coverage-report" \ + -reporttypes:Html + + - name: Upload HTML coverage report + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: coverage-report-html + path: ./artifacts/coverage-report + + - name: Upload coverage to Codecov + if: matrix.os == 'ubuntu-latest' + uses: codecov/codecov-action@v4 + with: + directory: ./artifacts/test-results + fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index e96676c..1ef723e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ A local-first performance contract gate for BenchmarkDotNet and CI. ![build](https://img.shields.io/github/actions/workflow/status/Bijecta/BenchmarkGate/ci.yml?branch=main&style=flat-square&label=build) + [![codecov](https://codecov.io/gh/Bijecta/BenchmarkGate/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/Bijecta/BenchmarkGate) ![nuget](https://img.shields.io/nuget/v/Bijecta.BenchmarkGate.Tool?style=flat-square&label=nuget) ![license](https://img.shields.io/badge/license-Apache--2.0-4B5163?style=flat-square) diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..ba5728b --- /dev/null +++ b/codecov.yml @@ -0,0 +1,46 @@ +codecov: + branch: main + require_ci_to_pass: true + +coverage: + precision: 2 + round: down + range: "70...100" + + status: + # Overall project coverage vs. the base commit (main). Fails (red, + # blocking status check) if coverage drops by more than 1 percentage + # point compared to main -- adjust `threshold` to taste. + project: + default: + target: auto + threshold: 1% + base: auto + if_ci_failed: error + informational: false + + # Diff/"patch" coverage -- only the lines actually added or changed in + # this PR. Fails if fewer than 80% of new/changed lines are covered. + # This is usually the more useful gate day-to-day: it catches + # uncovered new code even on a repo whose overall coverage is already + # high, without demanding 100% everywhere. + patch: + default: + target: 80% + threshold: 0% + if_ci_failed: error + informational: false + +# Posts/updates a PR comment showing overall + diff coverage vs. main. +comment: + layout: "reach, diff, flags, files" + behavior: default + require_changes: false + require_base: true + require_head: true + +# Coverage should measure src/, not the test projects themselves -- +# matches coverlet.runsettings' filter, so Codecov and the local +# HTML report agree on what counts. +ignore: + - "tests/**" diff --git a/coverlet.runsettings b/coverlet.runsettings new file mode 100644 index 0000000..0292ff7 --- /dev/null +++ b/coverlet.runsettings @@ -0,0 +1,23 @@ + + + + + + + cobertura + + [*.Tests]*,[*IntegrationTests]* + Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute + + + + + diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 52a71a7..244bfc9 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -20,30 +20,31 @@ See `PRODUCT-SCOPE.md` for what this tool explicitly is not. ## v0.1.0-alpha.1 — shipped ## v0.2.0-alpha.1 — shipped +## v0.3.0-alpha.1 — Validation — shipped +## v0.4.0-alpha.1 — Comparison — shipped -(see CHANGELOG.md for full detail on both) +(see CHANGELOG.md for full detail on all four) ## v0.2.x — stabilization (before starting v0.3 work) Confirm, not implement — these should already be true; this is a checklist to verify before building on top of them: -- [ ] baseline schema is explicitly versioned (`schemaVersion` — done, v2) -- [ ] benchmark identity is centralized (`BenchmarkIdentity` — done) -- [ ] metric units are normalized (`MetricFormatters` — done) -- [ ] parsing exceptions are separated from domain validation +- [x] baseline schema is explicitly versioned (`schemaVersion` — done, v2) +- [x] benchmark identity is centralized (`BenchmarkIdentity` — done) +- [x] metric units are normalized (`MetricFormatters` — done) +- [x] parsing exceptions are separated from domain validation (`BenchmarkResultParseException` vs. `PolicyFileException`/ `BaselineFileException` — done) -- [ ] commands do not contain evaluation rules (`CheckCommand` orchestrates, +- [x] commands do not contain evaluation rules (`CheckCommand` orchestrates, `RegressionEvaluator` decides — done) -- [ ] public JSON output has snapshot/regression tests -- [ ] `docs/BUILD-TOOL-INTEGRATION.md` exists — plain shell, NUKE, and Cake +- [X] public JSON output has snapshot/regression tests +- [X] `docs/BUILD-TOOL-INTEGRATION.md` exists — plain shell, NUKE, and Cake invocation examples. The tool already installs and runs fine under either build system via a standard local-tool manifest (`dotnet tool restore`) — this is purely a documentation gap, not a functionality gap, and it's cheap to close now rather than leave people guessing. -- [ ] exit-code meanings are documented in one place (currently inline on - `ExitCodes` — consider a standalone `EXIT-CODES.md`) +- [x] exit-code meanings are documented in one place (`docs/EXIT-CODES.md`) ## net8.0 multi-targeting (parallel track, not version-gated) @@ -51,65 +52,27 @@ Widen the install floor from net10.0-only to net8.0+net10.0. Small, mechanical, no design risk — do whenever convenient, doesn't block anything below. -## v0.3.0 — Validation - -New command: `benchmark-gate validate` - -Validates, without running the full check pipeline: -- a policy file -- a baseline/snapshot file -- BenchmarkDotNet input -- (later) a comparison report - -Core additions: -- `ValidationResult`, `ValidationDiagnostic`, `DiagnosticSeverity`, - `DiagnosticCode` -- `PolicyValidator`, `SnapshotValidator`, `ObservationValidator` - -Diagnostic codes, namespaced so they're greppable and stable: -``` -BGV101 warningPercent must be lower than failurePercent -BGV203 Duplicate benchmark identity -BGV302 Mean cannot be negative -BGV401 Unsupported snapshot schema version -``` - -Goal: make invalid data explicit before Compare/History add more surface -that could silently misbehave on bad input. - -Not yet: history aggregation, signatures, Merkle trees, profiling, plugin -loading. - -## v0.4.0 — Comparison - -New command: `benchmark-gate compare --baseline --current ` - -The architectural change this version exists for: - -``` -Before: baseline + current + policy → evaluation -After: baseline + current → comparison → (+ policy) → evaluation -``` - -`check` is refactored to consume `ComparisonResult` rather than compute -deltas itself. This is the load-bearing change of the whole roadmap — -everything from here on (history, explain, later) depends on "what -changed" being a first-class, independently-producible artifact instead -of something baked into the evaluator. - -Core additions: -- `BenchmarkComparisonEngine`, `ComparisonResult`, `BenchmarkComparison`, - `MetricComparison` -- `PercentDeltaCalculator` -- `MetricCatalog`, `MetricDescriptor`, `OptimizationDirection` - -Comparison statuses: `Comparable`, `Added`, `Removed`, -`MissingReferenceMetric`, `MissingCandidateMetric`, `UnitMismatch`, -`InvalidValue` - -Important: `compare` succeeds even when results are slower — it describes -change, it doesn't judge it. `check` applies policy on top of the same -`ComparisonResult`. +## v0.4.x — stabilization (before starting v0.5 work) + +Same purpose as the v0.2.x checklist above: confirm, not implement. +v0.5.0 (History) builds directly on `ComparisonResult` being trustworthy +and the CLI surface being solid across platforms — worth locking that +down explicitly before adding a new command surface on top of it. + +- [X] Code coverage is measured in CI, not just asserted by test count +- [X] CI runs the full test suite on Windows, Linux, and macOS — + BenchmarkGate is installed via `dotnet tool install` on all + three; a Linux-only CI run doesn't actually prove that +- [X] End-to-end tests exist that install the real packed tool (not an + in-process `Command.Run()` call) and invoke it as a subprocess — + proves the packed artifact people actually install works, not + just the code that builds it +- [x] Tag-driven release pipeline confirmed working end-to-end + (see `.github/workflows/release.yml`: pack, smoke-test the + installed package, publish to NuGet.org via Trusted Publishing, + auto-generate the GitHub release) +- [X] A coverage badge is visible in the README, not just collected + silently in CI ## v0.5.0 — Filesystem history @@ -297,4 +260,4 @@ platform": - Diagnostic comparison and explanation engine See the architecture notes (`docs/architecture/`) for the fuller sketch of -where these could go — not committed, not scheduled. +where these could go — not committed, not scheduled. \ No newline at end of file diff --git a/tests/BenchmarkGate.IntegrationTests/BenchmarkGate.IntegrationTests.csproj b/tests/BenchmarkGate.IntegrationTests/BenchmarkGate.IntegrationTests.csproj index 052343c..28d3ca9 100644 --- a/tests/BenchmarkGate.IntegrationTests/BenchmarkGate.IntegrationTests.csproj +++ b/tests/BenchmarkGate.IntegrationTests/BenchmarkGate.IntegrationTests.csproj @@ -14,4 +14,10 @@ + + + PreserveNewest + + + diff --git a/tests/BenchmarkGate.IntegrationTests/EndToEndTests.cs b/tests/BenchmarkGate.IntegrationTests/EndToEndTests.cs new file mode 100644 index 0000000..7f9bcc9 --- /dev/null +++ b/tests/BenchmarkGate.IntegrationTests/EndToEndTests.cs @@ -0,0 +1,165 @@ +using FluentAssertions; +using Xunit; + +namespace Bijecta.BenchmarkGate.IntegrationTests; + +/// +/// True black-box end-to-end tests: every test here invokes the real, +/// packed, installed benchmark-gate executable as a subprocess via +/// -- never an in-process +/// Command.Run() call. This is what proves the actual artifact +/// people install with dotnet tool install works, not just the code +/// that builds it. +/// +[Collection(ToolInstallCollection.Name)] +public class EndToEndTests +{ + private readonly ToolInstallFixture _tool; + + public EndToEndTests(ToolInstallFixture tool) => _tool = tool; + + private static string FixturePath(string fileName) => + Path.Combine(AppContext.BaseDirectory, "Fixtures", fileName); + + private const string SamplePolicyJson = """ + { + "schemaVersion": 1, + "stability": { "minimumMeasurements": 1, "maximumCoefficientOfVariation": 1.0 }, + "metrics": { + "meanNanoseconds": { "direction": "lower-is-better", "warningPercent": 50, "failurePercent": 90, "minimumAbsoluteChange": 0 } + } + } + """; + + [Fact] + public async Task version_flag_prints_a_version_and_exits_zero() + { + var result = await _tool.RunAsync("--version"); + + result.ExitCode.Should().Be(0); + result.StandardOutput.Should().NotBeNullOrWhiteSpace(); + } + + [Fact] + public async Task help_flag_lists_every_known_command() + { + var result = await _tool.RunAsync("--help"); + + result.ExitCode.Should().Be(0); + result.StandardOutput.Should().Contain("check"); + result.StandardOutput.Should().Contain("compare"); + result.StandardOutput.Should().Contain("capture"); + result.StandardOutput.Should().Contain("validate"); + } + + [Fact] + public async Task capture_then_compare_against_the_same_results_exits_zero() + { + // Full real pipeline: real `capture` writes a real baseline file + // to disk, then real `compare` reads it back -- two separate + // subprocess invocations, no shared in-process state. + var resultsPath = FixturePath("sample-results.json"); + var baselinePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-baseline.json"); + + try + { + var captureResult = await _tool.RunAsync( + $"capture --results \"{resultsPath}\" --output \"{baselinePath}\" --suite e2e-suite"); + captureResult.ExitCode.Should().Be(0, captureResult.StandardError); + File.Exists(baselinePath).Should().BeTrue(); + + var compareResult = await _tool.RunAsync( + $"compare --results \"{resultsPath}\" --baseline \"{baselinePath}\""); + + compareResult.ExitCode.Should().Be(0, compareResult.StandardError); + compareResult.StandardOutput.Should().Contain("Comparable"); + } + finally + { + File.Delete(baselinePath); + } + } + + [Fact] + public async Task capture_then_check_with_a_permissive_policy_passes() + { + var resultsPath = FixturePath("sample-results.json"); + var baselinePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-baseline.json"); + var policyPath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-policy.json"); + + try + { + await File.WriteAllTextAsync(policyPath, SamplePolicyJson, TestContext.Current.CancellationToken); + + var captureResult = await _tool.RunAsync( + $"capture --results \"{resultsPath}\" --output \"{baselinePath}\" --suite e2e-suite"); + captureResult.ExitCode.Should().Be(0, captureResult.StandardError); + + var checkResult = await _tool.RunAsync( + $"check --results \"{resultsPath}\" --baseline \"{baselinePath}\" --policy \"{policyPath}\""); + + checkResult.ExitCode.Should().Be(0, checkResult.StandardError); + } + finally + { + File.Delete(baselinePath); + File.Delete(policyPath); + } + } + + [Fact] + public async Task compare_json_format_writes_a_real_file_with_full_precision() + { + var resultsPath = FixturePath("sample-results.json"); + var baselinePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-baseline.json"); + var outputPath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-compare.json"); + + try + { + var captureResult = await _tool.RunAsync( + $"capture --results \"{resultsPath}\" --output \"{baselinePath}\" --suite e2e-suite"); + captureResult.ExitCode.Should().Be(0, captureResult.StandardError); + + var compareResult = await _tool.RunAsync( + $"compare --results \"{resultsPath}\" --baseline \"{baselinePath}\" --format json --output \"{outputPath}\""); + + compareResult.ExitCode.Should().Be(0, compareResult.StandardError); + File.Exists(outputPath).Should().BeTrue(); + (await File.ReadAllTextAsync(outputPath, TestContext.Current.CancellationToken)).Should().Contain("\"schemaVersion\""); + } + finally + { + File.Delete(baselinePath); + File.Delete(outputPath); + } + } + + [Fact] + public async Task validate_against_an_incomplete_policy_returns_validation_failed() + { + var policyPath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-bad-policy.json"); + await File.WriteAllTextAsync(policyPath, "{ \"schemaVersion\": 1 }", TestContext.Current.CancellationToken); + + try + { + var result = await _tool.RunAsync($"validate --policy \"{policyPath}\""); + + result.ExitCode.Should().Be(12); // ExitCodes.ValidationFailed + } + finally + { + File.Delete(policyPath); + } + } + + [Fact] + public async Task check_against_a_nonexistent_results_path_returns_unsupported_schema() + { + var result = await _tool.RunAsync( + $"check --results \"{Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-missing.json")}\" " + + $"--baseline \"{Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-missing.json")}\" " + + $"--policy \"{Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-missing.json")}\""); + + result.ExitCode.Should().Be(8); // ExitCodes.UnsupportedSchema + } +} \ No newline at end of file diff --git a/tests/BenchmarkGate.IntegrationTests/Fixtures/sample-results.json b/tests/BenchmarkGate.IntegrationTests/Fixtures/sample-results.json new file mode 100644 index 0000000..2d924aa --- /dev/null +++ b/tests/BenchmarkGate.IntegrationTests/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 diff --git a/tests/BenchmarkGate.IntegrationTests/ToolInstallFixture.cs b/tests/BenchmarkGate.IntegrationTests/ToolInstallFixture.cs new file mode 100644 index 0000000..6b02dbc --- /dev/null +++ b/tests/BenchmarkGate.IntegrationTests/ToolInstallFixture.cs @@ -0,0 +1,159 @@ +using System.Diagnostics; +using Xunit; + +namespace Bijecta.BenchmarkGate.IntegrationTests; + +/// +/// The result of running the real installed benchmark-gate +/// executable as a subprocess. +/// +public sealed record ToolProcessResult(int ExitCode, string StandardOutput, string StandardError); + +/// +/// Builds and packs the real BenchmarkGate.Tool project, installs it +/// as a real dotnet tool into an isolated --tool-path directory, and +/// exposes a way to run the actual installed executable/shim as a +/// subprocess -- not an in-process Command.Run() call. Runs once per +/// test collection (a real pack + install is too expensive to repeat per +/// test). Self-contained: works identically locally (dotnet test) +/// and in CI, no bespoke CI-side pack step required. +/// +public sealed class ToolInstallFixture : IAsyncLifetime +{ + private const string TestPackageVersion = "0.0.0-e2e"; + + public string ExecutablePath { get; private set; } = string.Empty; + + private string _toolPathDirectory = string.Empty; + private string _packageSourceDirectory = string.Empty; + + public async ValueTask InitializeAsync() + { + var repoRoot = FindRepoRoot(); + _packageSourceDirectory = Path.Combine(Path.GetTempPath(), $"bg-e2e-source-{Guid.NewGuid()}"); + _toolPathDirectory = Path.Combine(Path.GetTempPath(), $"bg-e2e-install-{Guid.NewGuid()}"); + Directory.CreateDirectory(_packageSourceDirectory); + Directory.CreateDirectory(_toolPathDirectory); + + var toolProjectPath = Path.Combine(repoRoot, "src", "BenchmarkGate.Tool", "BenchmarkGate.Tool.csproj"); + + await RunProcessAsync("dotnet", + $"pack \"{toolProjectPath}\" -c Release -o \"{_packageSourceDirectory}\" /p:Version={TestPackageVersion}"); + + await RunProcessAsync("dotnet", + $"tool install --tool-path \"{_toolPathDirectory}\" " + + $"--add-source \"{_packageSourceDirectory}\" " + + $"--version {TestPackageVersion} " + + "Bijecta.BenchmarkGate.Tool"); + + var executableName = OperatingSystem.IsWindows() ? "benchmark-gate.exe" : "benchmark-gate"; + ExecutablePath = Path.Combine(_toolPathDirectory, executableName); + + if (!File.Exists(ExecutablePath)) + { + throw new InvalidOperationException( + $"Expected installed tool executable at '{ExecutablePath}' but it does not exist. " + + "Pack/install may have failed silently -- check the process output captured above."); + } + } + + public ValueTask DisposeAsync() + { + TryDeleteDirectory(_toolPathDirectory); + TryDeleteDirectory(_packageSourceDirectory); + return ValueTask.CompletedTask; + } + + /// + /// Runs the real installed executable with the given raw argument + /// string, capturing exit code and both output streams. + /// + public async Task RunAsync(string arguments) + { + var startInfo = new ProcessStartInfo(ExecutablePath, arguments) + { + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + }; + + using var process = Process.Start(startInfo) + ?? throw new InvalidOperationException($"Failed to start '{ExecutablePath}'."); + + var stdoutTask = process.StandardOutput.ReadToEndAsync(); + var stderrTask = process.StandardError.ReadToEndAsync(); + await process.WaitForExitAsync(); + + return new ToolProcessResult(process.ExitCode, await stdoutTask, await stderrTask); + } + + private static void TryDeleteDirectory(string path) + { + try + { + if (Directory.Exists(path)) + { + Directory.Delete(path, recursive: true); + } + } + catch (IOException) + { + // Best-effort cleanup -- e.g. a locked file from antivirus + // scanning the freshly-installed executable on Windows + // shouldn't fail the whole test run. + } + catch (UnauthorizedAccessException) + { + // Same reasoning as above. + } + } + + private static string FindRepoRoot() + { + var dir = new DirectoryInfo(AppContext.BaseDirectory); + while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "BenchmarkGate.slnx"))) + { + dir = dir.Parent; + } + + return dir?.FullName + ?? throw new InvalidOperationException( + "Could not locate BenchmarkGate.sln walking up from the test output directory " + + $"('{AppContext.BaseDirectory}'). This fixture assumes it's running from within the repo."); + } + + private static async Task RunProcessAsync(string fileName, string arguments) + { + var startInfo = new ProcessStartInfo(fileName, arguments) + { + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + }; + + using var process = Process.Start(startInfo) + ?? throw new InvalidOperationException($"Failed to start process '{fileName}'."); + + var stdoutTask = process.StandardOutput.ReadToEndAsync(); + var stderrTask = process.StandardError.ReadToEndAsync(); + await process.WaitForExitAsync(); + + var stdout = await stdoutTask; + var stderr = await stderrTask; + + if (process.ExitCode != 0) + { + throw new InvalidOperationException( + $"'{fileName} {arguments}' exited with code {process.ExitCode}.\n" + + $"stdout:\n{stdout}\nstderr:\n{stderr}"); + } + } +} + +[CollectionDefinition(Name)] +[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix", + Justification = "\"Collection\" is xUnit's own naming idiom for a CollectionDefinition marker class, not a BCL collection type.")] +public sealed class ToolInstallCollection : ICollectionFixture +{ + public const string Name = "Tool Install"; +} \ No newline at end of file