[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6BXVX116THJ10ADZQQ136XV":3,"skill-same:01M6BXVX116THJ10ADZQQ136XV":101},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":29,"publishedAt":41,"linkOnly":42,"markdownContent":43,"markdownBody":44,"frontMatter":45,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":14,"repositoryHtmlUrl":49,"repositoryHomepageUrl":50,"ownerHtmlUrl":51,"ownerBlogUrl":52,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M6BXVX116THJ10ADZQQ136XV","microbenchmarking","BenchmarkDotNet 性能基准测试","Designs, configures, runs, and reviews BenchmarkDotNet (BDN) benchmarks, including project setup, efficient runs, and side-by-side performance comparisons. Use when BenchmarkDotNet is involved, or a .NET performance question needs measurement and BenchmarkDotNet is the likely tool. Not for profiling or tracing (use profiling or dotnet-trace-collect), production telemetry, or load and stress testing.","设计、配置、运行并评审 BenchmarkDotNet（BDN）基准测试，包括项目搭建、高效运行以及并排的性能对比。当涉及 BenchmarkDotNet，或 .NET 性能问题需要测量且 BenchmarkDotNet 很可能是适用工具时使用。不用于性能剖析或追踪（请使用 profiling 或 dotnet-trace-collect）、生产环境遥测，或负载与压力测试。","Cratis\u002FSpecifications","Cratis","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F16456213?v=4","01M6BXRH290K4C8RS4PTKK3HXQ","01M6BXRH6YXJMJ3140T8TVBSB4",1,"MIT","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking\u002FSKILL.md",[19,24],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8C796JZ1YCTM2B2X7TKEWZZ","性能剖析与优化","SCENARIO","使用场景",[5,30,31,32,33,34,35,36,37,38,39,40],"testing","performance","dotnet","telemetry","setup","stress testing","tracing","collect","Production","tool","trace","2026-11-10 10:12:30",false,"---\nname: microbenchmarking\ndescription: 'Designs, configures, runs, and reviews BenchmarkDotNet (BDN) benchmarks, including project setup, efficient runs, and side-by-side performance comparisons. Use when BenchmarkDotNet is involved, or a .NET performance question needs measurement and BenchmarkDotNet is the likely tool. Not for profiling or tracing (use profiling or dotnet-trace-collect), production telemetry, or load and stress testing.'\nlicense: MIT\n---\n\u003C!-- cratis-ai-managed: skills\u002Fmicrobenchmarking\u002FSKILL.md -->\n\n\u003C!-- Modified by Cratis from dotnet's original (MIT): frontmatter, applicability, navigation and the changes listed in NOTICE. Upstream: https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills (plugins\u002Fdotnet-diag\u002Fskills\u002Fmicrobenchmarking\u002FSKILL.md; see NOTICE) -->\n\n# Benchmark Authoring Guidelines\n\nCratis rules in `.cratis\u002Fai\u002Frules\u002F` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ.\n\nBenchmarkDotNet (BDN) is a .NET library for writing and running microbenchmarks. Throughout this skill, \"BDN\" refers to BenchmarkDotNet.\n\n> **Note:** Evaluations of LLMs writing BenchmarkDotNet benchmarks have revealed common failure patterns caused by outdated assumptions about BDN's behavior — particularly around runtime comparison, job configuration, and execution defaults that have changed in recent versions. The reference files in this skill contain verified, current information. **You MUST read the reference files relevant to the task before writing any code** — your training data likely contains outdated or incorrect BDN patterns.\n\n## Key concepts\n\n- **Job** — describes how to run a benchmark: runtime, iteration counts, launch count, run strategy, and environment settings. Multiple jobs can be configured to run the same benchmarks under different conditions.\n- **Benchmark case** — one method × one parameter combination × one job. The atomic unit BDN measures.\n- **Operation** — the logical unit of work being measured. All BDN output columns (Mean, Error, etc.) report time per operation.\n- **Invocation** — a single call to the benchmark method. By default, 1 invocation = 1 operation. With `OperationsPerInvoke=N`, each invocation counts as N operations.\n- **Iteration** — a timed batch of invocations. BDN measures the total time for all invocations in an iteration, then divides by the total operation count to get per-operation time.\n\n## Benchmarks are comparative instruments\n\nA single benchmark number has limited value — it can confirm the order of magnitude of a measurement, but the exact value changes across machines, operating systems, and runtime configurations. Benchmarks produce the most useful information when compared against something. Before writing benchmarks, identify the **comparison axis** for the current task:\n\n- **Approaches (A vs B)**: comparing alternative implementations side-by-side in the same run.\n- **Runtimes**: comparing the same code across .NET versions (e.g., net8.0 vs net9.0).\n- **Package versions**: comparing different versions of a NuGet dependency.\n- **Builds (before\u002Fafter)**: comparing a saved DLL of the old code against the current source.\n- **Runtime configuration (GC mode, JIT settings)**: understanding how runtime settings affect performance — compared via multiple jobs in a single run.\n- **Scale (N=100 vs N=1000)**: understanding how performance changes as input size grows.\n- **Hardware\u002FOS**: comparing across different machines or operating systems — requires separate runs on each environment.\n- **Earlier measurements**: comparing against measurements recorded previously.\n\nBDN can compare the first six axes side-by-side in a single run, but each requires specific CLI flags or configuration that differ from what you might expect — read [references\u002Fcomparison-strategies.md](references\u002Fcomparison-strategies.md) for the correct approach for each strategy before configuring a comparison.\n\n## Use cases and benchmark lifecycle\n\nThere are four distinct reasons a developer writes a benchmark, and each one changes how the benchmark should be designed and where it should live:\n\n1. **Coverage suite**: Write benchmarks to maximize coverage of real-world usage patterns so that regressions affecting most users are caught. These benchmarks are permanent — they belong in the project's benchmark suite, follow its conventions (directory structure, base classes, naming), and are checked in.\n\n2. **Issue investigation**: Someone has reported a specific performance problem. Write benchmarks to reproduce and diagnose that specific issue. These benchmarks are task-scoped — they persist across the investigation (reproduce → isolate → verify fix) but are not part of the permanent suite.\n\n3. **Change validation**: A developer has a PR or change and wants to understand its performance characteristics before merging. These benchmarks are task-scoped — they persist across the review cycle but are not checked in.\n\n4. **Development feedback**: A developer is actively working on a task and wants to use benchmarks to evaluate approaches and get information early. These benchmarks are task-scoped and throwaway — they persist across the development session but are deleted when the decision is made.\n\nFor use case 1, add to the existing benchmark project following its conventions. For use cases 2–4, create a standalone project in a working directory that persists for the task but is clearly not part of the permanent codebase.\n\nFor **coverage suite** benchmarks, design from the perspective of real callers — what code patterns use this API, what inputs they pass, and what performance characteristics matter to them. Each permanent benchmark should justify its maintenance cost through real-world relevance. For **temporary benchmarks**, keep the case count intentional — each additional test case costs wall-clock time (read [Cost awareness](#cost-awareness)).\n\n## Cost awareness\n\nEach benchmark case (one method × one parameter combination × one job) takes **15–25 seconds** with default settings. `[Params]` creates a Cartesian product: two `[Params]` with 3 and 4 values across 5 methods = 60 cases ≈ 20 minutes. Multiple jobs multiply this further. Before running, estimate the total case count and match the job preset to the situation:\n\n| Preset | Per-case time | When to use |\n|--------|--------------|-------------|\n| `--job Dry` | \u003C1s | Validate correctness — confirms compilation and execution without measurement |\n| `--job Short` | 5–8s | Quick measurements during development or investigation |\n| *(default)* | 15–25s | Final measurements for a coverage suite |\n| `--job Medium` | 33–52s | Higher confidence when results matter |\n| `--job Long` | 3–12 min | High statistical confidence |\n\nIf benchmark runs take longer than expected, results seem unstable, or you need to tune iteration counts or execution settings, read [references\u002Fbdn-internals-and-tuning.md](references\u002Fbdn-internals-and-tuning.md) for detailed information about BDN's execution pipeline and configuration options.\n\n## Entry points and configuration\n\nBDN programs use either **`BenchmarkSwitcher`** (provides interactive benchmark selection for humans, parses CLI arguments) or **`BenchmarkRunner`** (runs specified benchmarks directly). Both support CLI flags like `--filter` and `--runtimes`, but only when `args` is passed through — without it, CLI flags are silently ignored. When using `BenchmarkSwitcher`, always pass `--filter` to avoid hanging on an interactive prompt.\n\nBDN behavior is customized through **attributes**, **config objects**, and **CLI flags**.\n\nRead [references\u002Fproject-setup-and-running.md](references\u002Fproject-setup-and-running.md) for entry point setup, config object patterns, and CLI flags. If you need to collect data beyond wall-clock time — such as memory allocations, hardware counters, or profiling traces — read [references\u002Fdiagnosers-and-exporters.md](references\u002Fdiagnosers-and-exporters.md).\n\n## Running benchmarks\n\nBenchmarkDotNet console output is extremely verbose — hundreds of lines per case showing internal calibration, warmup, and measurement details. Redirect all output to a file to avoid consuming context on verbose iteration output:\n\n```\ndotnet run -c Release -- --filter \"*MethodName\" --noOverwrite > benchmark.log 2>&1\n```\n\nEach benchmark method can take several minutes. Rather than running all benchmarks at once, use `--filter` to run a subset at a time (e.g. one or two methods per invocation), read the results, then run the next subset. This keeps each invocation short — avoiding session or terminal timeouts — and lets you verify results incrementally. Read [references\u002Fproject-setup-and-running.md](references\u002Fproject-setup-and-running.md) for filter syntax, CLI flags, and project setup.\n\nAfter each run, read the Markdown report (`*-report-github.md`) from the results directory for the summary table. Only read `benchmark.log` if you need to investigate errors or unexpected results.\n\n## Writing new benchmarks\n\n### Step 1: Plan the test cases\n\nBefore writing any code, determine:\n- Which use case this benchmark serves (coverage, investigation, change validation, or development feedback).\n- Which comparison axis applies (what will the number be compared against?).\n- What real-world scenarios to benchmark, based on how callers actually use the API.\n\nEach benchmark case should justify its cost. An uncovered scenario is usually more valuable than another parameter combination for one already covered, but when a specific parameter dimension genuinely affects performance characteristics, the depth is warranted.\n\nDecide on the list of test cases. For each test case, think through:\n\n- **How to express variation**: BenchmarkDotNet provides several mechanisms for parameterizing benchmarks — `[Params]` and `[ParamsSource]` for property-level parameters, `[Arguments]` and `[ArgumentsSource]` for method-level arguments, `[ParamsAllValues]` to enumerate all values of a `bool` or enum, and `[GenericTypeArguments]` for varying type parameters on generic benchmark classes. Choose the mechanism that best fits the dimension being varied. Read [references\u002Fwriting-benchmarks.md](references\u002Fwriting-benchmarks.md) for the full set of options and correctness patterns.\n- **Where input data comes from** — consider which sources are appropriate (these can be combined):\n  - Hard-coded values — small, fixed values where the exact input matters (e.g., specific strings, known edge-case sizes). Store in fields or `[Params]` to avoid constant folding.\n  - Asset files — static data that is too large or impractical to embed in source code such as binary blobs.\n  - Programmatically generated via `[ParamsSource]`\u002F`[ArgumentsSource]`\u002F`[GlobalSetup]` — when data shape matters more than specific content, or when input must be parameterized by size.\n- **Whether randomness is appropriate**: If using generated data, use seeded randomness for reproducibility. When generating random data, use a large enough sample that the generated distribution is representative (e.g., 4 random values may cluster in a narrow range, while 1000 will better exercise the full distribution).\n\n### Step 2: Implement the benchmarks\n\nFor **coverage suite** benchmarks, add to the existing benchmark project and follow its conventions. For **temporary benchmarks** (investigation, change validation, development feedback), create a standalone project — read [references\u002Fproject-setup-and-running.md](references\u002Fproject-setup-and-running.md) for project setup and entry point configuration.\n\n**Adding the BenchmarkDotNet package**: In a repository with Central Package Management (`Directory.Packages.props`), use the version already pinned there and add a versionless `\u003CPackageReference>`; otherwise use `dotnet add package BenchmarkDotNet` (no version) — this lets NuGet resolve the latest compatible version. Do NOT manually write a `\u003CPackageReference>` with a version number into the `.csproj`; BDN versions in training data are outdated and may lack support for current .NET runtimes.\n\nWrite the benchmark code. Follow the patterns in [references\u002Fwriting-benchmarks.md](references\u002Fwriting-benchmarks.md) to avoid common measurement errors — in particular:\n- **Return results** from benchmark methods to prevent dead code elimination\n- **Move initialization to `[GlobalSetup]`** — setup inside the benchmark method is measured; use `[IterationSetup]` only when the benchmark mutates state that must be reset between iterations\n- **Do not add manual loops** — BDN controls invocation count automatically\n- **Mark a baseline** when comparing alternatives — use `[Benchmark(Baseline = true)]` for method-level comparisons or `.AsBaseline()` on a job for multi-job comparisons so results show relative ratios\n- **Store inputs in fields or `[Params]`**, not as literals or `const` values — the JIT can fold constant expressions at compile time, making the benchmark measure a precomputed result instead of the actual computation\n\n### Step 3: Validate and run\n\nValidate before committing to a long run:\n\n1. Run with `--job Dry` first to catch compilation errors and runtime exceptions without spending time on measurement.\n2. Run a single representative case with default settings to verify the output looks correct and the numbers are in the expected range.\n3. Only run the full suite after validation passes.\n\nWhen iterating on benchmark design, use `--job Short` until confident, then switch to default for final numbers.\n","\u003C!-- cratis-ai-managed: skills\u002Fmicrobenchmarking\u002FSKILL.md -->\n\n\u003C!-- Modified by Cratis from dotnet's original (MIT): frontmatter, applicability, navigation and the changes listed in NOTICE. Upstream: https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills (plugins\u002Fdotnet-diag\u002Fskills\u002Fmicrobenchmarking\u002FSKILL.md; see NOTICE) -->\n\n# Benchmark Authoring Guidelines\n\nCratis rules in `.cratis\u002Fai\u002Frules\u002F` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ.\n\nBenchmarkDotNet (BDN) is a .NET library for writing and running microbenchmarks. Throughout this skill, \"BDN\" refers to BenchmarkDotNet.\n\n> **Note:** Evaluations of LLMs writing BenchmarkDotNet benchmarks have revealed common failure patterns caused by outdated assumptions about BDN's behavior — particularly around runtime comparison, job configuration, and execution defaults that have changed in recent versions. The reference files in this skill contain verified, current information. **You MUST read the reference files relevant to the task before writing any code** — your training data likely contains outdated or incorrect BDN patterns.\n\n## Key concepts\n\n- **Job** — describes how to run a benchmark: runtime, iteration counts, launch count, run strategy, and environment settings. Multiple jobs can be configured to run the same benchmarks under different conditions.\n- **Benchmark case** — one method × one parameter combination × one job. The atomic unit BDN measures.\n- **Operation** — the logical unit of work being measured. All BDN output columns (Mean, Error, etc.) report time per operation.\n- **Invocation** — a single call to the benchmark method. By default, 1 invocation = 1 operation. With `OperationsPerInvoke=N`, each invocation counts as N operations.\n- **Iteration** — a timed batch of invocations. BDN measures the total time for all invocations in an iteration, then divides by the total operation count to get per-operation time.\n\n## Benchmarks are comparative instruments\n\nA single benchmark number has limited value — it can confirm the order of magnitude of a measurement, but the exact value changes across machines, operating systems, and runtime configurations. Benchmarks produce the most useful information when compared against something. Before writing benchmarks, identify the **comparison axis** for the current task:\n\n- **Approaches (A vs B)**: comparing alternative implementations side-by-side in the same run.\n- **Runtimes**: comparing the same code across .NET versions (e.g., net8.0 vs net9.0).\n- **Package versions**: comparing different versions of a NuGet dependency.\n- **Builds (before\u002Fafter)**: comparing a saved DLL of the old code against the current source.\n- **Runtime configuration (GC mode, JIT settings)**: understanding how runtime settings affect performance — compared via multiple jobs in a single run.\n- **Scale (N=100 vs N=1000)**: understanding how performance changes as input size grows.\n- **Hardware\u002FOS**: comparing across different machines or operating systems — requires separate runs on each environment.\n- **Earlier measurements**: comparing against measurements recorded previously.\n\nBDN can compare the first six axes side-by-side in a single run, but each requires specific CLI flags or configuration that differ from what you might expect — read [references\u002Fcomparison-strategies.md](references\u002Fcomparison-strategies.md) for the correct approach for each strategy before configuring a comparison.\n\n## Use cases and benchmark lifecycle\n\nThere are four distinct reasons a developer writes a benchmark, and each one changes how the benchmark should be designed and where it should live:\n\n1. **Coverage suite**: Write benchmarks to maximize coverage of real-world usage patterns so that regressions affecting most users are caught. These benchmarks are permanent — they belong in the project's benchmark suite, follow its conventions (directory structure, base classes, naming), and are checked in.\n\n2. **Issue investigation**: Someone has reported a specific performance problem. Write benchmarks to reproduce and diagnose that specific issue. These benchmarks are task-scoped — they persist across the investigation (reproduce → isolate → verify fix) but are not part of the permanent suite.\n\n3. **Change validation**: A developer has a PR or change and wants to understand its performance characteristics before merging. These benchmarks are task-scoped — they persist across the review cycle but are not checked in.\n\n4. **Development feedback**: A developer is actively working on a task and wants to use benchmarks to evaluate approaches and get information early. These benchmarks are task-scoped and throwaway — they persist across the development session but are deleted when the decision is made.\n\nFor use case 1, add to the existing benchmark project following its conventions. For use cases 2–4, create a standalone project in a working directory that persists for the task but is clearly not part of the permanent codebase.\n\nFor **coverage suite** benchmarks, design from the perspective of real callers — what code patterns use this API, what inputs they pass, and what performance characteristics matter to them. Each permanent benchmark should justify its maintenance cost through real-world relevance. For **temporary benchmarks**, keep the case count intentional — each additional test case costs wall-clock time (read [Cost awareness](#cost-awareness)).\n\n## Cost awareness\n\nEach benchmark case (one method × one parameter combination × one job) takes **15–25 seconds** with default settings. `[Params]` creates a Cartesian product: two `[Params]` with 3 and 4 values across 5 methods = 60 cases ≈ 20 minutes. Multiple jobs multiply this further. Before running, estimate the total case count and match the job preset to the situation:\n\n| Preset | Per-case time | When to use |\n|--------|--------------|-------------|\n| `--job Dry` | \u003C1s | Validate correctness — confirms compilation and execution without measurement |\n| `--job Short` | 5–8s | Quick measurements during development or investigation |\n| *(default)* | 15–25s | Final measurements for a coverage suite |\n| `--job Medium` | 33–52s | Higher confidence when results matter |\n| `--job Long` | 3–12 min | High statistical confidence |\n\nIf benchmark runs take longer than expected, results seem unstable, or you need to tune iteration counts or execution settings, read [references\u002Fbdn-internals-and-tuning.md](references\u002Fbdn-internals-and-tuning.md) for detailed information about BDN's execution pipeline and configuration options.\n\n## Entry points and configuration\n\nBDN programs use either **`BenchmarkSwitcher`** (provides interactive benchmark selection for humans, parses CLI arguments) or **`BenchmarkRunner`** (runs specified benchmarks directly). Both support CLI flags like `--filter` and `--runtimes`, but only when `args` is passed through — without it, CLI flags are silently ignored. When using `BenchmarkSwitcher`, always pass `--filter` to avoid hanging on an interactive prompt.\n\nBDN behavior is customized through **attributes**, **config objects**, and **CLI flags**.\n\nRead [references\u002Fproject-setup-and-running.md](references\u002Fproject-setup-and-running.md) for entry point setup, config object patterns, and CLI flags. If you need to collect data beyond wall-clock time — such as memory allocations, hardware counters, or profiling traces — read [references\u002Fdiagnosers-and-exporters.md](references\u002Fdiagnosers-and-exporters.md).\n\n## Running benchmarks\n\nBenchmarkDotNet console output is extremely verbose — hundreds of lines per case showing internal calibration, warmup, and measurement details. Redirect all output to a file to avoid consuming context on verbose iteration output:\n\n```\ndotnet run -c Release -- --filter \"*MethodName\" --noOverwrite > benchmark.log 2>&1\n```\n\nEach benchmark method can take several minutes. Rather than running all benchmarks at once, use `--filter` to run a subset at a time (e.g. one or two methods per invocation), read the results, then run the next subset. This keeps each invocation short — avoiding session or terminal timeouts — and lets you verify results incrementally. Read [references\u002Fproject-setup-and-running.md](references\u002Fproject-setup-and-running.md) for filter syntax, CLI flags, and project setup.\n\nAfter each run, read the Markdown report (`*-report-github.md`) from the results directory for the summary table. Only read `benchmark.log` if you need to investigate errors or unexpected results.\n\n## Writing new benchmarks\n\n### Step 1: Plan the test cases\n\nBefore writing any code, determine:\n- Which use case this benchmark serves (coverage, investigation, change validation, or development feedback).\n- Which comparison axis applies (what will the number be compared against?).\n- What real-world scenarios to benchmark, based on how callers actually use the API.\n\nEach benchmark case should justify its cost. An uncovered scenario is usually more valuable than another parameter combination for one already covered, but when a specific parameter dimension genuinely affects performance characteristics, the depth is warranted.\n\nDecide on the list of test cases. For each test case, think through:\n\n- **How to express variation**: BenchmarkDotNet provides several mechanisms for parameterizing benchmarks — `[Params]` and `[ParamsSource]` for property-level parameters, `[Arguments]` and `[ArgumentsSource]` for method-level arguments, `[ParamsAllValues]` to enumerate all values of a `bool` or enum, and `[GenericTypeArguments]` for varying type parameters on generic benchmark classes. Choose the mechanism that best fits the dimension being varied. Read [references\u002Fwriting-benchmarks.md](references\u002Fwriting-benchmarks.md) for the full set of options and correctness patterns.\n- **Where input data comes from** — consider which sources are appropriate (these can be combined):\n  - Hard-coded values — small, fixed values where the exact input matters (e.g., specific strings, known edge-case sizes). Store in fields or `[Params]` to avoid constant folding.\n  - Asset files — static data that is too large or impractical to embed in source code such as binary blobs.\n  - Programmatically generated via `[ParamsSource]`\u002F`[ArgumentsSource]`\u002F`[GlobalSetup]` — when data shape matters more than specific content, or when input must be parameterized by size.\n- **Whether randomness is appropriate**: If using generated data, use seeded randomness for reproducibility. When generating random data, use a large enough sample that the generated distribution is representative (e.g., 4 random values may cluster in a narrow range, while 1000 will better exercise the full distribution).\n\n### Step 2: Implement the benchmarks\n\nFor **coverage suite** benchmarks, add to the existing benchmark project and follow its conventions. For **temporary benchmarks** (investigation, change validation, development feedback), create a standalone project — read [references\u002Fproject-setup-and-running.md](references\u002Fproject-setup-and-running.md) for project setup and entry point configuration.\n\n**Adding the BenchmarkDotNet package**: In a repository with Central Package Management (`Directory.Packages.props`), use the version already pinned there and add a versionless `\u003CPackageReference>`; otherwise use `dotnet add package BenchmarkDotNet` (no version) — this lets NuGet resolve the latest compatible version. Do NOT manually write a `\u003CPackageReference>` with a version number into the `.csproj`; BDN versions in training data are outdated and may lack support for current .NET runtimes.\n\nWrite the benchmark code. Follow the patterns in [references\u002Fwriting-benchmarks.md](references\u002Fwriting-benchmarks.md) to avoid common measurement errors — in particular:\n- **Return results** from benchmark methods to prevent dead code elimination\n- **Move initialization to `[GlobalSetup]`** — setup inside the benchmark method is measured; use `[IterationSetup]` only when the benchmark mutates state that must be reset between iterations\n- **Do not add manual loops** — BDN controls invocation count automatically\n- **Mark a baseline** when comparing alternatives — use `[Benchmark(Baseline = true)]` for method-level comparisons or `.AsBaseline()` on a job for multi-job comparisons so results show relative ratios\n- **Store inputs in fields or `[Params]`**, not as literals or `const` values — the JIT can fold constant expressions at compile time, making the benchmark measure a precomputed result instead of the actual computation\n\n### Step 3: Validate and run\n\nValidate before committing to a long run:\n\n1. Run with `--job Dry` first to catch compilation errors and runtime exceptions without spending time on measurement.\n2. Run a single representative case with default settings to verify the output looks correct and the numbers are in the expected range.\n3. Only run the full suite after validation passes.\n\nWhen iterating on benchmark design, use `--job Short` until confident, then switch to default for final numbers.\n",{"name":5,"license":15,"description":7},"main","c392076c8b3fae3b8b31e7d5684d71f9be75e8bb",".cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications","https:\u002F\u002Fwww.cratis.io\u002Fspecifications\u002F","https:\u002F\u002Fgithub.com\u002FCratis","https:\u002F\u002Fwww.cratis.io","Open-source (MIT) event sourcing and CQRS for .NET and beyond: Chronicle, Arc, Components and Screenplay.","2026-11-14 15:53:54",{"source":9,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add Cratis\u002FSpecifications --skill microbenchmarking",{"tool":61,"command":62},"bunx","bunx skills add Cratis\u002FSpecifications --skill microbenchmarking",{"tool":64,"command":65},"pnpm","pnpm dlx skills add Cratis\u002FSpecifications --skill microbenchmarking","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking\u002FSKILL.md",true,[69,73,79,85,89,93,97],{"path":70,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":16},"LICENSE","许可证",1170,{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"NOTICE","OTHER","其他",1784,"https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking\u002FNOTICE",{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"references\u002Fbdn-internals-and-tuning.md","REFERENCE","参考文档",9913,"https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking\u002Freferences\u002Fbdn-internals-and-tuning.md",{"path":86,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":87,"sourceHtmlUrl":88},"references\u002Fcomparison-strategies.md",9176,"https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking\u002Freferences\u002Fcomparison-strategies.md",{"path":90,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":91,"sourceHtmlUrl":92},"references\u002Fdiagnosers-and-exporters.md",6724,"https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking\u002Freferences\u002Fdiagnosers-and-exporters.md",{"path":94,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":95,"sourceHtmlUrl":96},"references\u002Fproject-setup-and-running.md",9751,"https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking\u002Freferences\u002Fproject-setup-and-running.md",{"path":98,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":99,"sourceHtmlUrl":100},"references\u002Fwriting-benchmarks.md",12631,"https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fmicrobenchmarking\u002Freferences\u002Fwriting-benchmarks.md",[102,121,143,175,196,213],{"skillNo":103,"name":104,"nameZh":105,"description":106,"descriptionZh":107,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":108,"sourceHtmlUrl":109,"categories":110,"keywords":113,"publishedAt":41},"01M6BXWPJZ1W4FTAZ7N0B718XQ","vectorization",".NET SIMD 向量化代码","Designs, implements, optimizes, and reviews SIMD code in .NET: vectorizing scalar loops with TensorPrimitives, Vector64, Vector128, Vector256, Vector512, or hardware intrinsics, and reviewing existing SIMD code, including the generic Vector type, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. Use when a .NET loop or SIMD routine is being written or reviewed. Not for performance work unrelated to SIMD.","设计、实现、优化和审查 .NET 中的 SIMD 代码：使用 TensorPrimitives、Vector64、Vector128、Vector256、Vector512 或硬件内部函数将标量循环向量化，并审查现有 SIMD 代码（包括泛型 Vector 类型）的契约等价性、尾部处理、内存安全性、可移植性、回退方案和实测性能。当正在编写或审查 .NET 循环或 SIMD 例程时使用。不用于与 SIMD 无关的性能工作。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fvectorization\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fvectorization\u002FSKILL.md",[111,112],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},[104,114,115,116,117,118,31,119,120],"loop","Safety","simd","vector","code","memory safety","memory",{"skillNo":122,"name":123,"nameZh":124,"description":125,"descriptionZh":126,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":127,"sourceHtmlUrl":128,"categories":129,"keywords":134,"publishedAt":41},"01M6BXWKDP8VKEXE9WN5R8R1E0","target-authoring","MSBuild自定义目标编写","Canonical patterns for writing custom MSBuild targets: DependsOnTargets versus BeforeTargets and AfterTargets, the Build-to-CoreBuild three-level pattern, and the XxxDependsOn chain-extension pattern. Use when diagnosing or fixing custom-target anti-patterns: Directory.Build.targets redefining SDK targets, targets that replace CompileDependsOn instead of extending it, Outputs versus Returns misuse that returns stale results, missing Inputs\u002FOutputs causing needless rebuilds, or missing FileWrites registration. Not for incremental build tuning or general anti-pattern review (use the msbuild skill), or non-MSBuild build systems.","编写自定义 MSBuild target 的规范模式：DependsOnTargets 与 BeforeTargets、AfterTargets 的区别，Build-to-CoreBuild 三级模式，以及 XxxDependsOn 链式扩展模式。用于诊断或修复自定义 target 的反模式：Directory.Build.targets 重新定义 SDK target、target 替换而非扩展 CompileDependsOn、Outputs 与 Returns 误用导致返回过期结果、缺少 Inputs\u002FOutputs 导致不必要的重新构建，或缺少 FileWrites 注册。不适用于增量构建调优或一般反模式审查（使用 msbuild 技能），也不适用于非 MSBuild 构建系统。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Ftarget-authoring\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Ftarget-authoring\u002FSKILL.md",[130,131],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":132,"categoryName":133,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BSTR9G4A4GZ0VB2DFN9490","开发环境与工具链管理",[135,136,137,138,139,140,141,142],"target authoring","msbuild","tuning","incremental build","sdk","review","directory","writing",{"skillNo":144,"name":145,"nameZh":146,"description":147,"descriptionZh":148,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":149,"sourceHtmlUrl":150,"categories":151,"keywords":158,"publishedAt":41},"01M6BXWG0724RVJDEE4SQBEF8P","run-tests",".NET测试命令执行","Chooses and runs the repository-compatible .NET test command: classic, VSTest, bridged MTP, or native MTP syntax for MSTest, xUnit, NUnit, and TUnit. Use before running .NET tests or answering with a test command or flags: run the tests, one test, class, category, trait or target framework, combined filters, --filter-query, --no-build, --diag, TRX, coverage collection, crash or hang dumps, filter errors, or unrecognized options. Not for platform identification alone (use platform-detection), writing or debugging test code, interpreting a coverage report (use coverage-analysis), CI investigation, migration, or a persistent hot-reload loop.","选择并运行与仓库兼容的 .NET 测试命令：针对 MSTest、xUnit、NUnit 和 TUnit 的 classic、VSTest、bridged MTP 或 native MTP 语法。在运行 .NET 测试或需要给出测试命令\u002F标志时使用：运行全部测试、单个测试、测试类、类别、trait 或目标框架、组合筛选器、--filter-query、--no-build、--diag、TRX、覆盖率收集、崩溃或挂起转储、筛选错误或无法识别的选项。不适用于仅做平台识别（使用 platform-detection）、编写或调试测试代码、解读覆盖率报告（使用 coverage-analysis）、CI 调查、迁移或持续的热重载循环。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Frun-tests\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Frun-tests\u002FSKILL.md",[152,155],{"categoryNo":153,"categoryName":154,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":156,"categoryName":157,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[159,160,161,162,163,164,165,166,118,167,168,169,170,142,171,172,173,114,174],"run tests","run","collection","detection","ci","repository","framework","report","debugging","mtp","mstest","test","analysis","xunit","nunit","investigation",{"skillNo":176,"name":177,"nameZh":178,"description":179,"descriptionZh":180,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":181,"sourceHtmlUrl":182,"categories":183,"keywords":186,"publishedAt":41},"01M6BXWCTS8TECDKSYFJT9C445","profiling",".NET 性能剖析","Uses the free official .NET diagnostics CLI tools for profiling and runtime investigation in a repository: CPU, GC pressure, allocation growth, exception storms, lock contention, and slow code. Use when a .NET application needs performance or runtime profiling. Not for replacing realistic performance or load tests with ad-hoc tracing, production heap collection without a pause-risk plan, crash dumps (use dump-collect), or benchmark design (use microbenchmarking).","使用免费的官方 .NET 诊断 CLI 工具在代码仓库中进行性能剖析和运行时调查：CPU、GC 压力、分配增长、异常风暴、锁竞争和慢代码。当 .NET 应用程序需要性能或运行时剖析时使用。不适用于用临时跟踪替代真实的性能或负载测试、无暂停风险计划的生产堆内存采集、崩溃转储（使用 dump-collect），或基准测试设计（使用 microbenchmarking）。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fprofiling\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fprofiling\u002FSKILL.md",[184,185],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},[177,161,5,187,174,188,31,189,38,164,37,36,190,118,191,192,193,194,195],"plan","Tools","risk","benchmark","diagnostics","official","first","cli","design",{"skillNo":197,"name":198,"nameZh":199,"description":200,"descriptionZh":201,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":202,"sourceHtmlUrl":203,"categories":204,"keywords":207,"publishedAt":41},"01M6BXW9N4G1NTMKNVBECTM2GM","platform-detection",".NET 测试平台识别","Identifies a .NET project's test platform, framework, command mode, and SDK-style versus classic project system, resolving global.json, project, packages.config, Directory.Build.props, and Directory.Packages.props precedence for MSTest, xUnit, NUnit, and TUnit. Use when asking \"which test platform or framework?\", \"VSTest or MTP?\", or \"what runner does this project use?\", including bridge settings, UseVSTest opt-outs, and conflicting VSTest\u002FMTP configuration. Not for running or filtering tests, commands, flags, TRX, dumps, or test-command errors (use run-tests), or for hot-reload or migration requests.","识别 .NET 项目的测试平台、框架、命令模式，以及 SDK 样式与经典项目系统，并解析 global.json、项目文件、packages.config、Directory.Build.props 和 Directory.Packages.props 对 MSTest、xUnit、NUnit 和 TUnit 的优先级。当询问“使用哪种测试平台或框架”“VSTest 还是 MTP”或“该项目使用什么测试运行器”时使用，包括桥接设置、UseVSTest 退出选项，以及 VSTest\u002FMTP 配置冲突。不适用于运行或筛选测试、命令、标志、TRX、转储或测试命令错误（使用 run-tests），也不适用于热重载或迁移请求。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fplatform-detection\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fplatform-detection\u002FSKILL.md",[205,206],{"categoryNo":153,"categoryName":154,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":156,"categoryName":157,"taxonomyType":27,"taxonomyTypeDesc":28},[208,162,168,169,170,139,141,209,172,173,210,211,165,160,212],"platform detection","config","json","system","packages",{"skillNo":214,"name":215,"nameZh":216,"description":217,"descriptionZh":218,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":219,"sourceHtmlUrl":220,"categories":221,"keywords":228,"publishedAt":41},"01M6BXW4VVFJH0WDPATWMFE9TY","orleans","Orleans 分布式系统设计","Designs Microsoft Orleans systems from each primitive's purpose and failure model: grains, digital twins, state versus databases, transactions, messaging, streams, timers, reminders, Durable Jobs, stateless workers, grain services, startup, and hosting. Use when a task needs an Orleans design decision: inspect version and topology, choose the primitive, implement, and validate. Not for other actor stacks, batch processing, relational-only CRUD, or advice without an Orleans decision.","从每种原语的用途和失效模型出发设计 Microsoft Orleans 系统：grain、数字孪生、状态与数据库、事务、消息传递、流（streams）、计时器（timers）、提醒（reminders）、Durable Jobs（持久作业）、无状态工作进程、grain 服务、启动与托管。当任务需要做出 Orleans 设计决策时使用：检查版本与拓扑、选择原语、实现并验证。不适用于其他 actor 技术栈、批处理、纯关系型 CRUD，或不涉及 Orleans 决策的建议。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Forleans\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Forleans\u002FSKILL.md",[222,225],{"categoryNo":223,"categoryName":224,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8C4ZVS0ZJKF2T2G58PW5VR2","系统架构师",{"categoryNo":226,"categoryName":227,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8C535MHXGXDSGN98VJTMCSK","系统架构设计模式",[215,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,195],"startup","decision","choose","model","crud","transactions","services","topology","messaging","batch","state","reminders","validate","microsoft","implement"]