-
Notifications
You must be signed in to change notification settings - Fork 5
V5.0.1/service update #45
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
Changes from 9 commits
d33ceac
2beb2d6
35b42b5
fb7d56c
d927db6
97dd872
e503e4c
a03cb9b
d8fe012
699ee1f
8fbec77
f3896ba
45173de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| --- | ||
| mode: agent | ||
| description: 'Writing Performance Benchmarks' | ||
| --- | ||
|
|
||
| # Benchmark Fixture Prompt (Tuning Benchmarks) | ||
|
|
||
| This prompt defines how to generate performance tests (“benchmarks”) for a project/solution using BenchmarkDotNet. | ||
| Benchmarks are *not* unit tests — they are micro- or component-level performance measurements that belong under the `tuning/` directory and follow strict conventions. | ||
|
|
||
| Copilot must follow these guidelines when generating benchmark fixtures. | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Naming and Placement | ||
|
|
||
| - All benchmark projects live under the `tuning/` folder. | ||
| Examples: | ||
| - `tuning/<ProjectName>.Benchmarks/` | ||
| - `tuning/<ProjectName>.Console.Benchmarks/` | ||
|
|
||
| - **Namespaces must NOT end with `.Benchmarks`.** | ||
| They must mirror the production assembly’s namespace. | ||
|
|
||
| Example: | ||
| If benchmarking a type inside `YourProject.Console`, then: | ||
|
|
||
| ```csharp | ||
| namespace YourProject.Console | ||
| { | ||
| public class Sha512256Benchmark { … } | ||
| } | ||
| ``` | ||
|
|
||
| * **Benchmark class names must end with `Benchmark`.** | ||
| Example: `DateSpanBenchmark`, `FowlerNollVoBenchmark`. | ||
|
|
||
| * Benchmark files should be located in the matching benchmark project | ||
| (e.g., benchmarks for `YourProject.Console` go in `YourProject.Console.Benchmarks.csproj`). | ||
|
|
||
| * In the `.csproj` for each benchmark project, set the root namespace to the production namespace, for example: | ||
|
|
||
| ```xml | ||
| <RootNamespace>YourProject.Console</RootNamespace> | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Attributes and Configuration | ||
|
|
||
| Each benchmark class should use: | ||
|
|
||
| ```csharp | ||
| [MemoryDiagnoser] | ||
| [GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)] | ||
| ``` | ||
|
|
||
| Optional but strongly recommended where meaningful: | ||
|
|
||
| * `[Params(...)]` — define small, medium, large input sizes. | ||
| * `[GlobalSetup]` — deterministic initialization of benchmark data. | ||
| * `[Benchmark(Description = "...")]` — always add descriptions. | ||
| * `[Benchmark(Baseline = true)]` — when comparing two implementations. | ||
|
|
||
| Avoid complex global configs; prefer explicit attributes inside the class. | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Structure and Best Practices | ||
|
|
||
| A benchmark fixture must: | ||
|
|
||
| * Measure a **single logical operation** per benchmark method. | ||
| * Avoid I/O, networking, disk access, logging, or side effects. | ||
| * Avoid expensive setup inside `[Benchmark]` methods. | ||
| * Use deterministic data (e.g., seeded RNG or predefined constants). | ||
| * Use `[GlobalSetup]` to allocate buffers, random payloads, or reusable test data only once. | ||
| * Avoid shared mutable state unless reset per iteration. | ||
|
|
||
| Use representative input sizes such as: | ||
|
|
||
| ```csharp | ||
| [Params(8, 256, 4096)] | ||
| public int Count { get; set; } | ||
| ``` | ||
|
|
||
| BenchmarkDotNet will run each benchmark for each parameter value. | ||
|
|
||
| --- | ||
|
|
||
| ## 4. Method Naming Conventions | ||
|
|
||
| Use descriptive names that communicate intent: | ||
|
|
||
| * `Parse_Short` | ||
| * `Parse_Long` | ||
| * `ComputeHash_Small` | ||
| * `ComputeHash_Large` | ||
| * `Serialize_Optimized` | ||
| * `Serialize_Baseline` | ||
|
|
||
| When comparing approaches, always list them clearly and tag one as the baseline. | ||
|
|
||
| --- | ||
|
|
||
| ## 5. Example Benchmark Fixture | ||
|
|
||
| ```csharp | ||
| using BenchmarkDotNet.Attributes; | ||
| using BenchmarkDotNet.Configs; | ||
|
|
||
| namespace YourProject | ||
| { | ||
| [MemoryDiagnoser] | ||
| [GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)] | ||
| public class SampleOperationBenchmark | ||
| { | ||
| [Params(8, 256, 4096)] | ||
| public int Count { get; set; } | ||
|
|
||
| private byte[] _payload; | ||
|
|
||
| [GlobalSetup] | ||
| public void Setup() | ||
| { | ||
| _payload = new byte[Count]; | ||
| // deterministic initialization | ||
| } | ||
|
|
||
| [Benchmark(Baseline = true, Description = "Operation - baseline")] | ||
| public int Operation_Baseline() => SampleOperation.Process(_payload); | ||
|
|
||
| [Benchmark(Description = "Operation - optimized")] | ||
| public int Operation_Optimized() => SampleOperation.ProcessOptimized(_payload); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 6. Reporting and CI | ||
|
|
||
| * Benchmark projects live exclusively under `tuning/`. They must not affect production builds. | ||
| * Heavy BenchmarkDotNet runs should *not* run in CI unless explicitly configured. | ||
| * Reports are produced by the benchmark runner and stored under the configured artifacts directory. | ||
|
|
||
| --- | ||
|
|
||
| ## 7. Additional Guidelines | ||
|
|
||
| * Keep benchmark fixtures focused and readable. | ||
| * Document non-obvious reasoning in short comments. | ||
| * Prefer realistic but deterministic data sets. | ||
| * When benchmarks reveal regressions or improvements, reference the associated PR or issue in a comment. | ||
| * Shared benchmark helpers belong in `tuning/` projects, not in production code. | ||
|
|
||
| --- | ||
|
|
||
| ## Final Notes | ||
|
|
||
| * Benchmarks are performance tests, not unit tests. | ||
| * Use `[Benchmark]` only for pure performance measurement. | ||
| * Avoid `MethodImplOptions.NoInlining` unless absolutely necessary. | ||
| * Use small sets of meaningful benchmark scenarios — avoid combinatorial explosion. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| --- | ||
| mode: agent | ||
| description: 'Prompt for populating PackageReleaseNotes.txt files under .nuget/**' | ||
| params: | ||
| version: '10.0.0' | ||
| --- | ||
|
|
||
| Purpose: deterministic, low-analysis instructions so automated runs prepend a single, consistent release block. | ||
|
|
||
| Behavior (exact): | ||
| - For every file matching `.nuget/**/PackageReleaseNotes.txt`: | ||
| 1. Read the file and find the first line that starts with `Availability:` (case-sensitive). | ||
| 2. If found, capture the remainder of that line as `previous-tfm` and prepend the exact template shown below (substituting `{{version}}` and `{{previous-tfm}}`). | ||
| 3. If not found within the first 3 lines, do nothing for that file. | ||
| 4. Apply the template exactly as shown, preserving all whitespace and blank lines (including NBSP U+00A0 characters). | ||
| 5. Save the file in-place - do not open PRs or create branches. | ||
| 6. Continue to the next file until all matching files have been processed. | ||
| 7. Do not assume that each file are the same - process each file independently. | ||
|
|
||
| Exact template to prepend (preserve whitespace and trailing NBSP U+00A0 on the blank lines): | ||
| ``` | ||
| Version {{version}} | ||
| Availability: {{previous-tfm}} | ||
|
|
||
| # ALM | ||
| - CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs) | ||
|
|
||
| ``` | ||
gimlichael marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Notes: | ||
| - Do not attempt to infer versions or parse changelogs — use the provided `params.version` value. | ||
| - Keep edits minimal: only prepend the template block; preserve the rest of the file unchanged for human interference. | ||
| - DO NOT REMOVE THE ASCII 0xA0 NBSP CHARACTERS OR RUN ANY SORT OF TRIM on the blank lines in the template! | ||
| - DO NOT RUN ANY SORT OF GIT COMMANDS - once the files are saved, you are done. | ||
|
|
||
| Example run command (agent): | ||
| `run: /nuget version={{version}}` | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,9 @@ | ||||||
| Version 5.0.1 | ||||||
gimlichael marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| Availability: .NET 10 and .NET 9 | ||||||
|
||||||
| Availability: .NET 10 and .NET 9 | |
| Availability: .NET 10 and .NET 9 |
Uh oh!
There was an error while loading. Please reload this page.