Add PerfLab counter threshold and direction metadata - #5293
Draft
DrewScoggins wants to merge 2 commits into
Draft
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Reporting “PerfLab” JSON contract to support optional per-counter regression thresholds and to represent an explicitly unknown counter direction (while keeping legacy higherIsBetter compatibility), and adds stricter validation of test/counter invariants during serialization and reporting JSON generation.
Changes:
- Added
CounterDirectionplus nullableRegressionThreshold, and introduced explicit handling for “unknown direction” viahigherIsBetter: null. - Enforced counter/test validity (exactly one default counter; default must also be top; unique counter names; known direction and nonblank units for monitored counters) via validation hooks and
Reporter.GetJson()validation. - Expanded unit tests to cover legacy JSON compatibility, new threshold serialization, unknown-direction behavior, and validation failures.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/tools/Reporting/Reporting/Test.cs | Adds counter/test validation and runs it on serialize/deserialize; tightens default/top counter invariants. |
| src/tools/Reporting/Reporting/Reporter.cs | Validates tests when constructing from JSON and before emitting JSON; improves result-table width handling when metric name can be null. |
| src/tools/Reporting/Reporting/Counter.cs | Adds direction/threshold metadata and validation; preserves legacy JSON via higherIsBetter handling (including null for unknown). |
| src/tools/Reporting/Reporting.Tests/ReporterTests.cs | Adds/updates tests for legacy compatibility, thresholds, unknown direction, and new validation rules. |
Suppressed comments (2)
src/tools/Reporting/Reporting/Test.cs:34
- The exception message includes an extra '$' before the counter name (it will render as a literal '$' in output). Remove the stray '$' so the message reports the actual name cleanly.
This issue also appears on line 65 of the same file.
if (counter.DefaultCounter && Counters.Any(c => c.DefaultCounter))
{
throw new Exception($"Duplicate default counter, name: ${counter.Name}");
}
src/tools/Reporting/Reporting/Test.cs:69
- The duplicate-counter-name validation message includes an extra '$' before the name, which will show up as a literal '$' in logs/errors. Remove the stray '$'.
var duplicateCounter = Counters.GroupBy(c => c.Name).FirstOrDefault(group => group.Count() > 1);
if (duplicateCounter is not null)
{
throw new InvalidOperationException($"Duplicate counter name, name: ${duplicateCounter.Key}");
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+52
to
+54
| internal void Validate() | ||
| { | ||
| var defaultCounters = Counters.Where(c => c.DefaultCounter).ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation