Files
Julian Lechner f5d8f6f11b
CI / CI configuration security checks (push) Successful in 3s
CI / Capabilities and shell quality (push) Successful in 14s
CI / Python tests and compilation (push) Successful in 26s
CI / QMD unit tests (push) Successful in 5s
CI / Build and inspect generated packages (push) Successful in 14s
CI / PowerShell tests on Ubuntu (push) Successful in 1m4s
CI / Installed client configuration smoke tests (push) Successful in 33s
CI / Bash integration and installation guards (push) Successful in 1m1s
feat(skills): reworked skills and rules
2026-11-18 14:17:49 +01:00

61 lines
4.4 KiB
Markdown

---
name: performance-measure
description: Use when a performance claim, optimization, or regression needs measured before/after numbers on .NET, web, or SQL Server. Diff-only reasoning is performance-review.
---
# Performance Measure
Measure before and after a change instead of guessing. Load the matching performance rules (`rules-csharp-performance`, `rules-typescript-performance`, `rules-angular-performance`) and apply `technical-research` before relying on tool behavior.
## 1. Define the question
State the scenario, the metric (latency percentile, throughput, allocations, logical reads, LCP, INP), the representative data size, and the threshold that counts as a real change (for example 5% or a Core Web Vitals boundary). Without a threshold, no result can be called better or worse.
## 2. Fix the environment
- Measure Release builds without a debugger, started from the CLI. Debug builds can be many times slower.
- Before and after run on the same machine, runtime, data, and cache state (warm or cold, stated). Close heavy processes, use a plugged-in machine with the high-performance power plan, and do not generalize results to another runtime or OS.
- Store each run's raw output in its own folder, tagged with the commit.
## 3. Take the baseline
Warm up, run enough iterations for a stable spread, and record the median plus p95 (or p75 for web field data) and the spread. Never compare single runs or averages alone.
## 4. Find the limiter while it runs
Use active benchmarking: watch the system during the run and name the limiting resource with the number. Check utilization, saturation, and errors (USE) with counters first, then profile only the confirmed hot path. Avoid the anti-methods: running familiar tools without a question, changing things at random, or blaming another component without evidence.
## 5. Change one variable, then repeat
Apply one change, rerun the identical protocol, and compare against the threshold. Check side metrics too: allocations and GC counts, logical reads, layout shift. A faster median with a worse p95 or more allocations is not automatically a win.
## Tools by stack
| Stack | Measure | Notes |
| --- | --- | --- |
| .NET code paths | BenchmarkDotNet with `[MemoryDiagnoser]`, `[Params]` for input sizes, a `Baseline = true` method, `--statisticalTest 5%` | Return or consume results so the JIT cannot remove the code. ShortRun only for quick checks. |
| .NET running app | `dotnet-counters monitor --showDeltas` first, then `dotnet-trace collect`; `dotnet-gcdump` for heap growth | Keep the `.nettrace`; Speedscope and Chromium conversions lose detail. |
| ASP.NET Core under load | Grafana: Prometheus percentiles and Tempo traces for the same window before and after | Compare p95/p99, not means. |
| WPF and MAUI | Visual Studio Performance Profiler or PerfView on Windows; `dotnet-trace` with `dsrouter` for Android and iOS | Measure on the slowest target device class. |
| Web and Angular | Field data (web-vitals, CrUX) at p75 decides: good is LCP ≤ 2.5 s, INP ≤ 200 ms, CLS ≤ 0.1. In the lab, DevTools Performance in a clean profile with 4x CPU throttling, and Lighthouse | Lighthouse cannot measure INP; use Total Blocking Time as its lab proxy. Angular DevTools Profiler runs on development builds only: use it for relative comparison, never absolute numbers. |
| SQL Server | Actual execution plans, `SET STATISTICS IO, TIME ON`, Query Store (regressed queries, wait categories), wait stats, statistics staleness | Logical reads are the stable metric; elapsed time varies. Test typical and skewed parameter values for parameter sniffing. Cold-cache tests (`CHECKPOINT`, `DBCC DROPCLEANBUFFERS`) only on a test server and only with the user's go-ahead. |
Measurements against shared or production systems follow the remote-system rules (`rules-microsoft`): read-only queries only, no load tests or cache flushes without an explicit request.
## Report
```text
Question: <scenario, metric, threshold>
Environment: <machine, build, runtime, data size, cache state, commits before/after>
Method: <tool, warmup, iterations>
| Metric | Before (median / p95, spread) | After | Delta | Significant? |
| --- | --- | --- | --- | --- |
Limiter: <resource and evidence>
Side effects: <allocations, reads, layout shift>
Verdict: <meets threshold or not>; not measured: <gaps>
```
Never claim a speedup without numbers from this protocol; label estimates as estimates.