benchmarkdotnet-setup
/benchmarkdotnet-setup
Set up BenchmarkDotNet for a .NET project and interpret the results — proper benchmark classes, memory diagnostics, baselines, and reading ns/op + allocations. Use this skill whenever the user wants to benchmark code, measure performance, compare two implementations, set up BenchmarkDotNet, or asks "which is faster / how do I benchmark this / interpret these benchmark results". Always use this skill for micro-benchmarking requests; it writes correct benchmarks and explains the numbers.
- Author
- stefanthecode ↗
- Repository
- dotnet-ai-toolkit ↗
- Licence
- MIT
- Last repository change
- 09.08.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 09.08.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Set up BenchmarkDotNet for a .NET project and interpret the results — proper benchmark classes, memory diagnostics, baselines, and reading ns/op + allocations. Use this skill whenever the user wants to benchmark code, measure performance, compare two implementations, set up BenchmarkDotNet, or asks "which is faster / how do I benchmark this / interpret these benchmark results". Always use this skill for micro-benchmarking requests; it writes correct benchmarks and explains the numbers.
Original author description
Set up BenchmarkDotNet for a .NET project and interpret the results — proper benchmark classes, memory diagnostics, baselines, and reading ns/op + allocations. Use this skill whenever the user wants to benchmark code, measure performance, compare two implementations, set up BenchmarkDotNet, or asks "which is faster / how do I benchmark this / interpret these benchmark results". Always use this skill for micro-benchmarking requests; it writes correct benchmarks and explains the numbers.
How it works
- Input — point it at your code
- Project + benchmark class
- Pitfalls the skill prevents
- Reading the summary
- Principles
- How to use it & best prompts
SKILL.md preview
---
name: benchmarkdotnet-setup
description: Set up BenchmarkDotNet for a .NET project and interpret the results — proper benchmark classes, memory diagnostics, baselines, and reading ns/op + allocations. Use this skill whenever the user wants to benchmark code, measure performance, compare two implementations, set up BenchmarkDotNet, or asks "which is faster / how do I benchmark this / interpret these benchmark results". Always use this skill for micro-benchmarking requests; it writes correct benchmarks and explains the numbers.
category: Performance
version: 1.0.0
---
# BenchmarkDotNet Setup
Write correct BenchmarkDotNet benchmarks (no common pitfalls) and read the results properly — so "which is faster" is answered with data, not vibes.
## Input — point it at your code
Works on a target: a **file**, **folder**, **project**, or **GitHub URL**. Identify the methods/implementations to compare; if the user pasted results, go straight to interpretation.
## Project + benchmark class
```
dotnet add package BenchmarkDotNet
```
```csharp
[MemoryDiagnoser] // allocations matter as much as time
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
public class StringJoinBenchmarks
{
private readonly string[] _items = Enumerable.Range(0, 1000).Select(i => i.ToString()).ToArray();
[Benchmark(Baseline = true)]
public string StringConcat() { var s = ""; foreach (var i in _items) s += i; return s; }
[Benchmark]
public string StringBuilder_() { var sb = new StringBuilder(); foreach (var i in _items) sb.Append(i); return sb.ToString(); }
[Benchmark]
public string StringJoin() => string.Join("", _items);
}
// Program.cs: BenchmarkRunner.Run<StringJoinBenchmarks>();
```
Run in **Release**: `dotnet run -c Release`.
## Pitfalls the skill prevents
- Benchmarking in Debug, or without `BenchmarkRunner` (JIT/optimizations differ).
- Dead-code elimination — **return** the result so the work isn't optimized away.
- Setup work inside the `[Benchmark]` method — move it to `[GlobalSetup]`.
- Comparing without a `[Baseline]` — you need a reference point.
- Tiny inputs that measure noise, not the algorithm.
## Reading the summary
- **Mean (ns/us/ms)** — central tendency; check **StdDev/Error** for noise.
- **Ratio** — vs baseline (the headline comparison).
- **Gen0/1/2 + Allocated** — allocations and GC pressure; often the real story, not raw time.
- A faster method that allocates 10× more may lose under real load — weigh both.
## Principles
- Measure the realistic input size and shape, not a toy.
- Allocations are a first-class result — keep `[MemoryDiagnoser]` on.
- One variable at a time; keep benchmarks isolated and deterministic.
- Don't micro-optimize a path that isn't hot — confirm it matters first (`hotpath-profiler-assistant`).
## How to use it & best prompts
"Benchmark these two implementations", "is StringBuilder faster here", "set up BenchmarkDotNet for this method", "interpret these benchmark results".
Files in this package (2)
- SKILL.md 3 KB
- USAGE.md 1 KB
Versions
The database has no other skills named benchmarkdotnet-setup.
Database snapshot: 13.11.2026 · package version e2372b155f4e (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100microbenchmarking
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… - 95bench-fast
Run a benchmark with minimal iterations to generate assembly code via BenchmarkDotNet's DisassemblyDiagnoser. Use to generate one big assembly code file per benchmark. - 100split-asm
Split BenchmarkDotNet assembly markdown files into individual files per benchmark method using splitasm. Use to break one big assembly code file per benchmark into one file per benchmark method. - 100revit-benchmarking
Design, write, run, or review BenchmarkDotNet measurements that run inside Autodesk Revit with Nice3point.BenchmarkDotNet.Revit. USE FOR: comparing viable Revit API implementations, measuring a Revit hot path, applying the runner's WithCurrentConfiguration requirement, and… - 100microbenchmark
Generate and run ad hoc BenchmarkDotNet microbenchmarks to validate the performance impact of a code change. Use this when asked to benchmark, profile, or validate the performance impact of a code change in dotnet/runtime at the method/API level. For end-to-end ASP.NET Core /… - 100performance-testing
Benchmark indicator performance with BenchmarkDotNet. Use for Series/Buffer/Stream benchmarks, regression detection, and optimization patterns. Target 1.5x Series for StreamHub, 1.2x for BufferList.