Official agent skill

Microbenchmarking

by dotnet in dotnet/skills

Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks.

OfficialMITAuto-check passedTesting & QA

Install Microbenchmarking

skills CLI
$ npx skills add dotnet/skills --skill microbenchmarking -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dotnet/skills microbenchmarking --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dotnet/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/dotnet-diag/skills/microbenchmarking .claude/skills/microbenchmarking && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
microbenchmarking
GitHub stars
5.6k
Used in
3 other repos
Token cost
~3.3k tokens
SKILL.md length
1,629 words
Files
6 (incl. references)
Skills in repo
91
Repo updated
First seen
Licence
MIT

At a glance

Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks.

  • Works in 3 steps: Plan the test cases → Implement the benchmarks → Validate and run
  • Profiling/tracing .NET code (dotnet-trace
  • SKILL.md covers Key concepts, Benchmarks are comparative…, Use cases and benchmark… and Cost awareness, plus 3 more sections
  • Calls dotnet

What it does

Microbenchmarking is an agent skill from dotnet/skills, published by the product's own GitHub organization. Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side…

Its SKILL.md is about 3.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including reference files (for example `references/bdn-internals-and-tuning.md`, `references/comparison-strategies.md` and `references/diagnosers-and-exporters.md`).

It sits in Testing & QA, covering Load testing. It works with .NET. The repository describes itself as: Repository for skills to assist AI coding agents with .NET and C. The licence is MIT.

When your agent uses it

  • Profiling/tracing .NET code (dotnet-trace
  • Production telemetry
  • Load/stress testing (Crank

Example prompts

  • “/microbenchmarking”

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Plan the test cases
  2. Implement the benchmarks
  3. Validate and run

What it can do on your machine

Read from SKILL.md and the folder at commit 8d670fa. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • dotnet

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Microbenchmarking loads about 3.3k tokens when it runs, and up to ~15k if it reads all its reference files. Until then it costs about 171 tokens; SKILL.md has 1,629 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~171
When it runs · the whole SKILL.md, loaded when a task matches
~3.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~15k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from dotnet/skills at commit 8d670fa, republished under its MIT licence (© dotnet). 1,629 words, ~3,292 tokens.

Download SKILL.mdSave it as .claude/skills/microbenchmarking/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
microbenchmarking
description
Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side performance comparisons. Do NOT use for profiling/tracing .NET code (dotnet-trace, PerfView), production telemetry, or load/stress testing (Crank, k6).
license
MIT

Benchmark Authoring Guidelines

BenchmarkDotNet (BDN) is a .NET library for writing and running microbenchmarks. Throughout this skill, "BDN" refers to BenchmarkDotNet.

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.

Key concepts

  • 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.
  • Benchmark case — one method × one parameter combination × one job. The atomic unit BDN measures.
  • Operation — the logical unit of work being measured. All BDN output columns (Mean, Error, etc.) report time per operation.
  • Invocation — a single call to the benchmark method. By default, 1 invocation = 1 operation. With OperationsPerInvoke=N, each invocation counts as N operations.
  • 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.

Benchmarks are comparative instruments

A 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:

  • Approaches (A vs B): comparing alternative implementations side-by-side in the same run.
  • Runtimes: comparing the same code across .NET versions (e.g., net8.0 vs net9.0).
  • Package versions: comparing different versions of a NuGet dependency.
  • Builds (before/after): comparing a saved DLL of the old code against the current source.
  • Runtime configuration (GC mode, JIT settings): understanding how runtime settings affect performance — compared via multiple jobs in a single run.
  • Scale (N=100 vs N=1000): understanding how performance changes as input size grows.
  • Hardware/OS: comparing across different machines or operating systems — requires separate runs on each environment.
  • Historical measurements: comparing against measurements recorded at a previous point in time.

BDN 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/comparison-strategies.md for the correct approach for each strategy before configuring a comparison.

Use cases and benchmark lifecycle

There are four distinct reasons a developer writes a benchmark, and each one changes how the benchmark should be designed and where it should live:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

For 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.

For 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

Each 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:

PresetPer-case timeWhen to use
--job Dry<1sValidate correctness — confirms compilation and execution without measurement
--job Short5–8sQuick measurements during development or investigation
(default)15–25sFinal measurements for a coverage suite
--job Medium33–52sHigher confidence when results matter
--job Long3–12 minHigh statistical confidence

If benchmark runs take longer than expected, results seem unstable, or you need to tune iteration counts or execution settings, read references/bdn-internals-and-tuning.md for detailed information about BDN's execution pipeline and configuration options.

Entry points and configuration

BDN 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.

BDN behavior is customized through attributes, config objects, and CLI flags.

Read references/project-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/diagnosers-and-exporters.md.

Show full SKILL.md (700 more words)Show less

Running benchmarks

BenchmarkDotNet 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:

dotnet run -c Release -- --filter "*MethodName" --noOverwrite > benchmark.log 2>&1

Each 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/project-setup-and-running.md for filter syntax, CLI flags, and project setup.

After 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.

Writing new benchmarks

Step 1: Plan the test cases

Before writing any code, determine:

  • Which use case this benchmark serves (coverage, investigation, change validation, or development feedback).
  • Which comparison axis applies (what will the number be compared against?).
  • What real-world scenarios to benchmark, based on how callers actually use the API.

Each 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.

Decide on the list of test cases. For each test case, think through:

  • 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/writing-benchmarks.md for the full set of options and correctness patterns.
  • Where input data comes from — consider which sources are appropriate (these can be combined):
    • 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.
    • Asset files — static data that is too large or impractical to embed in source code such as binary blobs.
    • Programmatically generated via [ParamsSource]/[ArgumentsSource]/[GlobalSetup] — when data shape matters more than specific content, or when input must be parameterized by size.
  • 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).
Step 2: Implement the benchmarks

For 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/project-setup-and-running.md for project setup and entry point configuration.

Adding the BenchmarkDotNet package: Always use dotnet add package BenchmarkDotNet (no version) — this lets NuGet resolve the latest compatible version. Do NOT manually write a <PackageReference> with a version number into the .csproj; BDN versions in training data are outdated and may lack support for current .NET runtimes.

Write the benchmark code. Follow the patterns in references/writing-benchmarks.md to avoid common measurement errors — in particular:

  • Return results from benchmark methods to prevent dead code elimination
  • 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
  • Do not add manual loops — BDN controls invocation count automatically
  • 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
  • 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
Step 3: Validate and run

Validate before committing to a long run:

  1. Run with --job Dry first to catch compilation errors and runtime exceptions without spending time on measurement.
  2. Run a single representative case with default settings to verify the output looks correct and the numbers are in the expected range.
  3. Only run the full suite after validation passes.

When iterating on benchmark design, use --job Short until confident, then switch to default for final numbers.

© dotnet, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (references) in plugins/dotnet-diag/skills/microbenchmarking of dotnet/skills.

  • SKILL.md
  • references/bdn-internals-and-tuning.md
  • references/comparison-strategies.md
  • references/diagnosers-and-exporters.md
  • references/project-setup-and-running.md
  • references/writing-benchmarks.md

Open the folder on GitHubat commit 8d670fa

Used in 3 other repositories

We found 4 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 3 other GitHub owners. This page covers the copy in dotnet/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Microbenchmarking next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Microbenchmarking compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Microbenchmarking this skilldotnet/skills5.6k3 repos~3.3kAutomated safety check: PassMIT
Microbenchmarkingrodri-oliveira-dev/Dapper-FluentMap453—~1.1kAutomated safety check: PassMIT
Microbenchmarkingatherio-danp/cde-dotnetcc109—~979Automated safety check: NotesNone
Code Reviewdotnet/macios2.9k—~1.7kAutomated safety check: PassCustom licence
Profilingmanagedcode/dotnet-skills486—~1.6kAutomated safety check: PassMIT
Evaluate PR Testsdotnet/maui23k—~2.9kAutomated safety check: PassMIT

Similar skills

  • Microbenchmarking

    rodri-oliveira-dev/Dapper-FluentMap

    Activate when BenchmarkDotNet is involved or when a .NET performance question requires controlled microbenchmark measurement.

    453 GitHub stars~1.1k tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Microbenchmarking

    atherio-danp/cde-dotnetcc

    Create, run, configure, and interpret BenchmarkDotNet microbenchmarks in the .NET API — measure and compare approaches, runtime configs, or package versions.

    109 GitHub stars~979 tokensUpdated 2 mo ago
    Testing & QAAuto-check: notes
  • Code Review

    dotnet/macios

    Official

    Review dotnet/macios PRs against established rules. An agent skill from dotnet/macios.

    2.9k GitHub stars~1.7k tokensUpdated today
    DevelopmentAuto-check passed
  • Profiling

    managedcode/dotnet-skills

    Use the free official .NET diagnostics CLI tools for profiling and runtime investigation in .NET repositories.

    486 GitHub stars~1.6k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Official

    Reviews the tests added in a pull request for fix coverage, quality, edge cases and test type, and recommends lighter test types where they would do.

    23k GitHub stars~2.9k tokensUpdated today
    Testing & QAAuto-check passed
  • Official

    Investigate and triage CI failures for dotnet/macios from Azure DevOps build URLs.

    2.9k GitHub stars~2.3k tokensUpdated today
    Testing & QAAuto-check passed

More from dotnet/skills

All 91 skills in this repo
  • Official

    Resolves .NET runtime frames in Apple .ips crash logs to function names, source files and line numbers using dSYM symbols, atos and the Microsoft symbol server.

    5.6k GitHub starsUsed in 1 repo~2.4k tokens
    Auto-check passed
  • Official

    Resolves native crash frames from .NET Android tombstones to function names, source files and line numbers using BuildIds, Microsoft's symbol server and llvm-symbolizer.

    5.6k GitHub starsUsed in 1 repo~2.1k tokens
    Auto-check passed
  • Official

    Scans C# and .NET code for about 50 performance anti-patterns and reports prioritized findings with concrete fixes, at a scan depth you choose.

    5.6k GitHub starsUsed in 3 repos~3.1k tokens
    Auto-check passed
  • Official

    Statically pairs source files with test files to list code that no test references, using Roslyn for C# or tree-sitter for many languages, with no build.

    5.6k GitHub starsUsed in 1 repo~3.3k tokens
    Auto-check passed
  • Official

    Makes .NET projects compatible with Native AOT and trimming by resolving IL trim and AOT analyzer warnings through annotations rather than suppressions.

    5.6k GitHub starsUsed in 2 repos~4.2k tokens
    Auto-check passed
  • Official

    Configures automatic crash dumps or captures dumps from running processes for modern .NET apps on Linux, macOS and Windows, including Docker and Kubernetes.

    5.6k GitHub starsUsed in 2 repos~1.1k tokens
    Auto-check passed

Works with

Categories

Questions about Microbenchmarking

What does Microbenchmarking do?

Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Microbenchmarking is an agent skill from dotnet/skills, published by the product's own GitHub organization. Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks.

When should I use Microbenchmarking?

Microbenchmarking fits situations like: profiling/tracing .NET code (dotnet-trace; production telemetry; load/stress testing (Crank.

How do I install Microbenchmarking in Claude Code?

Run `npx skills add dotnet/skills --skill microbenchmarking -a claude-code`. Or copy the skill folder (plugins/dotnet-diag/skills/microbenchmarking in dotnet/skills) into .claude/skills/microbenchmarking in your project. Claude Code loads it when a task matches its description.

How do I install Microbenchmarking in Codex?

Run `npx skills add dotnet/skills --skill microbenchmarking -a codex`. Or copy the skill folder (plugins/dotnet-diag/skills/microbenchmarking in dotnet/skills) into .agents/skills/microbenchmarking in your project. Codex loads it when a task matches its description.

Can I use Microbenchmarking in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dotnet/skills --skill microbenchmarking -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/microbenchmarking, .gemini/skills/microbenchmarking, .github/skills/microbenchmarking and .opencode/skills/microbenchmarking in your project.

What does Microbenchmarking need to run?

Going by SKILL.md and its folder, Microbenchmarking needs the command-line tools its instructions call (dotnet).

Does Microbenchmarking access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Microbenchmarking safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Microbenchmarking use?

Microbenchmarking is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Microbenchmarking use?

About 3.3k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 12k tokens, read only when the agent opens those files.

What are the alternatives to Microbenchmarking?

Skills that share tags, products or a category with Microbenchmarking: Microbenchmarking (rodri-oliveira-dev/Dapper-FluentMap, 453 stars), Microbenchmarking (atherio-danp/cde-dotnetcc, 109 stars), Code Review (dotnet/macios, 2.9k stars) and Profiling (managedcode/dotnet-skills, 486 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Microbenchmarking?

dotnet (a GitHub organization, an official publisher) maintains it in dotnet/skills, which has 5,568 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on October 7, 2026.

Source: dotnet/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.