-
Notifications
You must be signed in to change notification settings - Fork 774
Add end-to-end scrolling performance suite and CI performance gate #5295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
37cf686
Initial plan
Copilot 144ef9e
Add scrolling benchmarks, performance smoke tests, and CI performance…
Copilot e646c04
Refactor scrolling benchmarks and tests for code style
tig eb48365
Fix UPPER_CASE constants and increase ListView mid-viewport threshold…
Copilot cb9eae7
Merge branch 'copilot/add-end-to-end-scrolling-benchmarks' of https:/…
tig 9f447dd
Raise TextView perf test threshold to 1000 ms
tig bced649
Restrict performance smoke tests to Ubuntu runner only
Copilot c6470ea
Fix perf tests to skip on non-Linux via Assert.Skip; revert broken --…
Copilot 53f110b
Add blank lines after SkipIfNotLinux() calls (style fix)
Copilot 97cfa6d
Move perf smoke tests to dedicated Tests/PerformanceTests csproj with…
Copilot 2e5ab4f
Fix perf-gate CI: add PerformanceTests to Terminal.sln so dotnet rest…
Copilot 423fb9c
Fix race condition: add [Collection("Application Tests")] to Applicat…
Copilot f4c56ec
Fix: use ContentView.FrameToScreen() in PopoverMenu overlap test for …
Copilot 79fd154
Merge branch 'develop' into copilot/add-end-to-end-scrolling-benchmarks
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| name: Scrolling Performance Gate | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, develop ] | ||
| paths-ignore: | ||
| - '**.md' | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
| paths-ignore: | ||
| - '**.md' | ||
|
|
||
| # Only run on Linux to keep results comparable across runs. | ||
| # Windows/macOS times vary too much to use as a performance baseline. | ||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| perf-smoke-tests: | ||
| name: Performance Smoke Tests (Linux) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| env: | ||
| DisableRealDriverIO: "1" | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 # GitVersion needs full history | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 10.x | ||
| dotnet-quality: 'ga' | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
|
|
||
| - name: Build (Release) | ||
| run: dotnet build --configuration Release --no-restore -property:NoWarn=0618%3B0612 | ||
|
|
||
| - name: Build Tests (Debug — smoke tests run in Debug to match CI unit tests) | ||
| run: dotnet build Tests/PerformanceTests --no-restore -property:NoWarn=0618%3B0612 | ||
|
|
||
| - name: Run performance smoke tests (Layer 1 gate) | ||
| id: smoke_tests | ||
| run: | | ||
| dotnet test \ | ||
| --project Tests/PerformanceTests \ | ||
| --no-build \ | ||
| --verbosity normal | ||
|
|
||
| - name: Upload smoke test logs | ||
| if: always() | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: perf-smoke-test-logs | ||
| path: | | ||
| TestResults/ | ||
| if-no-files-found: ignore | ||
| retention-days: 7 | ||
|
|
||
| perf-benchmarks: | ||
| name: Scrolling Benchmarks (Linux, ShortRun) | ||
| runs-on: ubuntu-latest | ||
| # Only run on pushes to develop/main, not on every PR (slow and not blocking). | ||
| if: github.event_name == 'push' | ||
| timeout-minutes: 30 | ||
| env: | ||
| DisableRealDriverIO: "1" | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 10.x | ||
| dotnet-quality: 'ga' | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
|
|
||
| - name: Build Release | ||
| run: dotnet build --configuration Release --no-restore -property:NoWarn=0618%3B0612 | ||
|
|
||
| - name: Run scrolling benchmarks (ShortRun ≈ 30–60 s) | ||
| id: run_benchmarks | ||
| run: | | ||
| dotnet run \ | ||
| --project Tests/Benchmarks \ | ||
| --configuration Release \ | ||
| --no-build \ | ||
| -- \ | ||
| --filter '*Scroll*' \ | ||
| --job short \ | ||
| --exporters json \ | ||
| --artifacts ./BenchmarkResults | ||
| continue-on-error: true # Don't block the workflow; comparison step decides outcome | ||
|
|
||
| - name: Compare results to baseline | ||
| id: compare | ||
| run: | | ||
| python3 - << 'PYEOF' | ||
| import json, os, sys, glob | ||
|
|
||
| REGRESSION_FACTOR = 3.0 # Fail if any benchmark is >3× baseline | ||
| IMPROVEMENT_FACTOR = 0.8 # Celebrate 🎉 if any benchmark drops below 0.8× baseline | ||
|
|
||
| baseline_path = "Tests/Benchmarks/baseline.json" | ||
| results_dir = "BenchmarkResults" | ||
|
|
||
| # --- Load baseline --- | ||
| try: | ||
| with open(baseline_path) as f: | ||
| baseline_data = json.load(f) | ||
| baseline = { | ||
| f"{b['type']}/{b['method']}/{b['params']}": b["meanNs"] | ||
| for b in baseline_data["benchmarks"] | ||
| } | ||
| except FileNotFoundError: | ||
| print("::warning::baseline.json not found — skipping comparison") | ||
| sys.exit(0) | ||
|
|
||
| # --- Find BenchmarkDotNet JSON results --- | ||
| result_files = glob.glob(f"{results_dir}/**/*.json", recursive=True) | ||
| result_files = [f for f in result_files if "results" in f.lower() or "report" in f.lower()] | ||
| if not result_files: | ||
| print("::warning::No BenchmarkDotNet result files found — skipping comparison") | ||
| sys.exit(0) | ||
|
|
||
| # --- Parse results --- | ||
| results = {} | ||
| for fpath in result_files: | ||
| try: | ||
| with open(fpath) as f: | ||
| data = json.load(f) | ||
| for bm in data.get("Benchmarks", []): | ||
| key = f"{bm['Type']}/{bm['Method']}/{bm.get('Parameters', '')}" | ||
| results[key] = bm.get("Statistics", {}).get("Mean", None) | ||
| except Exception as e: | ||
| print(f"::warning::Could not parse {fpath}: {e}") | ||
|
|
||
| # --- Build comparison table --- | ||
| rows = [] | ||
| regressions = [] | ||
| improvements = [] | ||
|
|
||
| for key, base_ns in baseline.items(): | ||
| if base_ns <= 0: | ||
| continue | ||
| cur_ns = results.get(key) | ||
| if cur_ns is None: | ||
| rows.append(f"| {key} | {base_ns/1000:.1f} µs | — (not measured) | — |") | ||
| continue | ||
|
|
||
| ratio = cur_ns / base_ns | ||
| emoji = "✅" | ||
| if ratio >= REGRESSION_FACTOR: | ||
| emoji = "❌" | ||
| regressions.append((key, base_ns, cur_ns, ratio)) | ||
| elif ratio <= IMPROVEMENT_FACTOR: | ||
| emoji = "🎉" | ||
| improvements.append((key, base_ns, cur_ns, ratio)) | ||
| rows.append( | ||
| f"| {key} | {base_ns/1000:.1f} µs | {cur_ns/1000:.1f} µs | {ratio:.2f}× {emoji} |" | ||
| ) | ||
|
|
||
| # --- Write step summary --- | ||
| summary = "## 📊 Scrolling Benchmark Comparison\n\n" | ||
| summary += "| Benchmark | Baseline | Current | Ratio |\n" | ||
| summary += "|-----------|----------|---------|-------|\n" | ||
| summary += "\n".join(rows) + "\n\n" | ||
|
|
||
| if improvements: | ||
| summary += "### 🎉 Performance Improvements\n" | ||
| for k, b, c, r in improvements: | ||
| summary += f"- **{k}**: {b/1000:.1f} µs → {c/1000:.1f} µs ({r:.2f}×)\n" | ||
| summary += "\n" | ||
|
|
||
| if regressions: | ||
| summary += "### ❌ Regressions Detected\n" | ||
| for k, b, c, r in regressions: | ||
| summary += f"- **{k}**: {b/1000:.1f} µs → {c/1000:.1f} µs ({r:.2f}×) — exceeds {REGRESSION_FACTOR}× threshold\n" | ||
| summary += "\n" | ||
|
|
||
| with open(os.environ.get("GITHUB_STEP_SUMMARY", "/dev/null"), "a") as f: | ||
| f.write(summary) | ||
|
|
||
| print(summary) | ||
|
|
||
| if regressions: | ||
| print(f"::error::Performance regressions detected: {len(regressions)} benchmark(s) exceeded {REGRESSION_FACTOR}× baseline") | ||
| sys.exit(1) | ||
|
|
||
| if improvements: | ||
| print(f"Performance improvements detected: {len(improvements)} benchmark(s) improved!") | ||
| PYEOF | ||
|
|
||
| - name: Upload benchmark results | ||
| if: always() | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: benchmark-results-${{ github.sha }} | ||
| path: BenchmarkResults/ | ||
| if-no-files-found: ignore | ||
| retention-days: 30 | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.