Skip to content

Fixes #5310. Add ConfigurationManager / Scheme / Theme benchmark baseline#5312

Merged
tig merged 9 commits into
developfrom
copilot/add-benchmark-baseline-config-manager
May 17, 2026
Merged

Fixes #5310. Add ConfigurationManager / Scheme / Theme benchmark baseline#5312
tig merged 9 commits into
developfrom
copilot/add-benchmark-baseline-config-manager

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

Fixes

Adds benchmark baseline for the configuration/theming layer so the follow-up PR adding 12 VisualRole.Code* entries (#5311) can demonstrate no regression mechanically.

Proposed Changes/Todos

Four BenchmarkDotNet benchmarks under Tests/Benchmarks/Configuration/:

  • ConfigurationManagerLoadBenchmarkDisable(true)Enable(LibraryResources)Apply() cold-start path. Reset is performed inside each invocation so every sample is a true cold start (Enable short-circuits when already enabled).
  • ThemeSwitchBenchmarkThemeManager.Theme = "X"; Apply() parametric over all built-in themes via [ParamsSource]. Resets to Default inside each invocation so every sample performs a real theme change.
  • SchemeAttributeBenchmarkGetAttributeForRole() at three derivation depths: Normal (explicit), HotFocus (1-hop), Code (deepest chain)
  • SchemeSerializationBenchmarkJsonSerializer + SchemeJsonConverter serialize/deserialize/round-trip
  • baseline.json — Real baseline numbers from benchmark run on GitHub Actions ubuntu-latest (AMD EPYC 7763, .NET 10.0.5), including all 8 built-in themes (added missing "8-Bit" theme entry)
  • perf-gate.yml — broadened filter to '*Scroll*' '*Config*' '*Scheme*' '*Theme*'; updated job names and summary title
  • README.md — documented Configuration benchmarks, updated CI and baseline-update references; fixed --filter syntax to use space-separated globs (not pipe-separated)
# Run the new benchmarks
dotnet run --project Tests/Benchmarks -c Release -- --filter '*Config*' '*Scheme*' '*Theme*'

Baseline Results

Benchmark Mean
ConfigurationManagerLoadBenchmark.LoadAndApply 3.19 ms
ThemeSwitchBenchmark.SwitchTheme ~750–810 µs per theme
SchemeAttributeBenchmark.GetNormal 36 ns
SchemeAttributeBenchmark.GetHotFocus 92 ns
SchemeAttributeBenchmark.GetCode 438 ns
SchemeSerializationBenchmark.Serialize 360 ns
SchemeSerializationBenchmark.Deserialize 1.08 µs
SchemeSerializationBenchmark.RoundTrip 1.60 µs

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

Copilot AI assigned Copilot and tig May 15, 2026
Copilot AI linked an issue May 15, 2026 that may be closed by this pull request
5 tasks
Copilot AI and others added 2 commits May 15, 2026 18:47
Adds four BenchmarkDotNet benchmarks under Tests/Benchmarks/Configuration/:
- ConfigurationManagerLoadBenchmark: cold-start config load + apply
- ThemeSwitchBenchmark: parametric theme switching over all built-in themes
- SchemeAttributeBenchmark: GetAttributeForRole at different derivation depths
- SchemeSerializationBenchmark: JSON serialize/deserialize round-trip

Updates baseline.json with placeholder entries, broadens perf-gate.yml filter
to include the new benchmarks, and documents them in README.md.

Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/2c601698-792a-447a-889f-2818e993485b

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ConfigurationManager, Scheme, and Theme benchmark baseline Fixes #5310. Add ConfigurationManager / Scheme / Theme benchmark baseline May 15, 2026
Copilot finished work on behalf of tig May 15, 2026 18:48
Copilot AI requested a review from tig May 15, 2026 18:48
@tig tig marked this pull request as ready for review May 15, 2026 19:11
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c099fb31f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .gitignore Outdated
Comment thread Tests/Benchmarks/Configuration/ConfigurationManagerLoadBenchmark.cs Outdated
Comment thread Tests/Benchmarks/Configuration/ThemeSwitchBenchmark.cs Outdated
@tig
Copy link
Copy Markdown
Member

tig commented May 15, 2026

@copilot ci cd is failing.

Reverts the accidental removal of local_packages/ directory and
the .gitignore addition that caused LocalPackagesTests to fail.

Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/8b9c42d7-30b6-4dc2-96ed-15c5f157582c

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 15, 2026

@copilot ci cd is failing.

The CI failures were caused by my second commit accidentally removing the local_packages/ directory and adding it to .gitignore, which broke the LocalPackagesTests (NupkgFilesExist, SnupkgFilesExist, LocalPackagesFolderExists). Fixed in 0ae15fe by restoring both local_packages/ and .gitignore to their original state.

Copilot finished work on behalf of tig May 15, 2026 19:22
@tig
Copy link
Copy Markdown
Member

tig commented May 16, 2026

@copilot addrss CR Feedback

Copilot AI and others added 2 commits May 16, 2026 22:32
Move ConfigurationManager.Disable(true) into the LoadAndApply benchmark
method so every invocation is a true cold start (Enable short-circuits
when already enabled). Move theme reset into SwitchTheme so every
invocation performs a real theme change instead of redundantly reapplying.

Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/26cdfc29-ec96-446a-b9fb-da0dcadc6136

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 16, 2026

@copilot addrss CR Feedback

Addressed both CR items in 7d1e9f6:

  1. ConfigurationManagerLoadBenchmark: Moved Disable(true) into the LoadAndApply() benchmark method itself so every invocation is a true cold start (since Enable() short-circuits when already enabled).
  2. ThemeSwitchBenchmark: Removed [IterationSetup] and moved the reset-to-Default logic into SwitchTheme() so every invocation performs an actual theme change rather than redundantly reapplying.

Also removed accidentally committed 1.0.0 nupkg build artifacts in f0f2b54.

Copilot finished work on behalf of tig May 16, 2026 22:33
@tig
Copy link
Copy Markdown
Member

tig commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 16, 2026

@copilot why does this workflow get skipped? https://github.com/gui-cs/Terminal.Gui/actions/runs/25974725214/job/76353177797?pr=5312

The "Benchmarks (Linux, ShortRun)" job is skipped by design — line 69 of perf-gate.yml has if: github.event_name == 'push', so it only runs on pushes to main/develop, not on PRs. This was intentional to avoid blocking PRs with the ~30–60s BenchmarkDotNet run. The "Performance Smoke Tests" job did run and passed.

If you'd like benchmarks to also run on PRs, I can remove that condition.

Copilot finished work on behalf of tig May 16, 2026 23:12
@tig
Copy link
Copy Markdown
Member

tig commented May 16, 2026

@copilot why does this workflow get skipped? https://github.com/gui-cs/Terminal.Gui/actions/runs/25974725214/job/76353177797?pr=5312

The "Benchmarks (Linux, ShortRun)" job is skipped by design — line 69 of perf-gate.yml has if: github.event_name == 'push', so it only runs on pushes to main/develop, not on PRs. This was intentional to avoid blocking PRs with the ~30–60s BenchmarkDotNet run. The "Performance Smoke Tests" job did run and passed.

If you'd like benchmarks to also run on PRs, I can remove that condition.

@copilot I don't want to change it tor un on PRs in general, but I need confidence that for THIS Pr it runs fine. We need to actually generate the baseline with this PR.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 16, 2026

@copilot why does this workflow get skipped? https://github.com/gui-cs/Terminal.Gui/actions/runs/25974725214/job/76353177797?pr=5312

The "Benchmarks (Linux, ShortRun)" job is skipped by des...

Ran all 15 Configuration benchmarks locally on the same GitHub Actions runner hardware (AMD EPYC 7763, .NET 10.0.5) and updated baseline.json with real measured numbers in 7cf0489. Also added the missing "8-Bit" theme entry that wasn't in the original placeholders. Key results:

  • ConfigurationManagerLoadBenchmark.LoadAndApply: 3.19 ms
  • ThemeSwitchBenchmark.SwitchTheme: ~750–810 µs per theme
  • SchemeAttributeBenchmark: 36 ns (Normal), 92 ns (HotFocus), 438 ns (Code)
  • SchemeSerializationBenchmark: 360 ns (Serialize), 1.08 µs (Deserialize), 1.60 µs (RoundTrip)

The benchmarks job in CI will still be skipped on PRs (by design), but when this merges to develop via push, it will run and compare against these real baselines.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a BenchmarkDotNet baseline for the ConfigurationManager/Theme/Scheme subsystems so the upcoming VisualRole.Code* expansion (#5311) can be measured against a fixed reference. The perf-gate workflow and baseline data are widened to include these new benchmarks alongside the existing Scrolling suite.

Changes:

  • New benchmarks under Tests/Benchmarks/Configuration/ for cold-start config load, theme switching (parametric over all built-in themes), per-role attribute lookup at varying derivation depths, and Scheme JSON serialize/deserialize/round-trip.
  • baseline.json extended with measured means captured on ubuntu-latest (EPYC 7763, .NET 10.0.5).
  • perf-gate.yml filter and labels broadened from "Scrolling" to general "Performance Gate"; README documents the new benchmarks and updated commands.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Tests/Benchmarks/Configuration/ConfigurationManagerLoadBenchmark.cs Cold-start Disable→Enable→Apply benchmark for embedded library config.
Tests/Benchmarks/Configuration/ThemeSwitchBenchmark.cs Parametric theme-switch benchmark over all built-in theme names.
Tests/Benchmarks/Configuration/SchemeAttributeBenchmark.cs Measures GetAttributeForRole at three derivation depths.
Tests/Benchmarks/Configuration/SchemeSerializationBenchmark.cs Serialize/Deserialize/RoundTrip for a representative Scheme.
Tests/Benchmarks/baseline.json Adds measured baselines for the new benchmarks; updates header comments.
Tests/Benchmarks/README.md Documents the new Configuration benchmarks and updated run commands.
.github/workflows/perf-gate.yml Broadens job name, summary title, and --filter to include Config/Scheme/Theme.

Comment thread Tests/Benchmarks/README.md Outdated
Copilot finished work on behalf of tig May 17, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ConfigurationManager / Scheme / Theme benchmark baseline

4 participants