Repository navigation
feat: Add a performance benchmark suite with CI regression checks - #56
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Closes #53
What does this change?
Adds a performance benchmark suite and a CI gate on allocation regressions. ResXLocalization had no
performance numbers until now. Nothing caught a change that made lookups slower or allocate more, and
consumers had no way to see what the library costs their app.
Refs #53. The spec is the OpenSpec change
openspec/changes/add-benchmarks/(proposal, design, delta spec, tasks).Benchmarks (
benchmarks/, BenchmarkDotNet, .NET 10, JIT only). Each one is compared with the code anapplication would write without the library: the
.resxdesigner class and hand-written code over it.ResXLocalization.Core.Benchmarks:Localizer.Current.Getwith typed, scoped, search-all and enum keys;search-all across 1, 5 or 20 resource managers;
MessageArguments(FromValues,FromTuples,FromObject) againststring.Format; and ICU MessageFormat against calling the library directly.ResXLocalization.Avalonia.Benchmarks(headless) andResXLocalization.WPF.Benchmarks(Windows only):{l:Localize},{l:Localize}with<l:Argument>children and{l:LocalizeEnum}, measured on 100 elements, against{x:Static}.{x:Static}.TranslationSourceindexer.
Shared/is compiled into all three suites. Each class first checks that every benchmark produces theexpected text, then measures.
CI (
.github/workflows/ci.yml)mainthatchange code. A
benchmark-changesjob skips them for every other change.benchmark-reportmerges the results (scripts/convert-benchmark-results.ps1) and compares them withmainusingbenchmark-action/github-action-benchmark, pinned by SHA:main's bytes, or allocating anything wheremainallocated nothing,fails the check.
mainis an alert only, shown in the job summary and as a PR comment.accept-allocation-increaseturns the allocation failure into an alert.main, results are pushed to a newbenchmark-databranch: the history of the last 200 commits, plusthe latest reports.
deploy-docscopies that branch into the Pages site underbenchmarks/latest/andbenchmarks/history/.contents: writeandpull-requests: write.Docs
docs/guides/benchmarks.md, with an entry indocs/toc.yml.CONTRIBUTING.md.benchmarks/in theAGENTS.mdlayout table.CHANGELOG.mdentry under[Unreleased].No shipped package, public API or runtime behaviour changes.
BenchmarkDotNetis referenced only by thebenchmark projects.
Checklist
Always
pwsh -File scripts/pre-commit-gate.ps1passes.<type>/issue-<number>-<slug>:feature/issue-53-add-benchmarks.If the change adds behaviour or fixes a bug
Does not apply: no runtime behaviour changes. The benchmarks check themselves before they measure.
CHANGELOG.mdhas an entry anyway, because the results page is user-facing.If the change touches one UI package
Does not apply:
src/is untouched. The Avalonia and WPF benchmark suites mirror each other.If the change touches resource lookup, the generated keys, or the packaging that carries them
Does not apply: the only new dependency (
BenchmarkDotNet) is referenced by the benchmark projects only, sono package's dependencies change.
If the change touches the public API
Does not apply.
After merging
accept-allocation-increaselabel if it does not exist yet.maincreates thebenchmark-databranch with the first entry.benchmarks/latest/andbenchmarks/history/.