Przejdź do treści
Biblioteka skilli
Programowanie · Testowanie

benchmarkdotnet-setup

/benchmarkdotnet-setup

Konfiguruje BenchmarkDotNet w projekcie .NET i pomaga interpretować wyniki: klasy benchmarków, diagnostyka pamięci, baseline'y, czasy w ns/op i alokacje.

Licencja
MIT
Ostatnia zmiana repozytorium
09.08.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
2
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 09.08.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Konfiguruje BenchmarkDotNet w projekcie .NET i pomaga interpretować wyniki: klasy benchmarków, diagnostyka pamięci, baseline'y, czasy w ns/op i alokacje.

Oryginalny opis (EN)

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.

Jak działa

  1. Input — point it at your code
  2. Project + benchmark class
  3. Pitfalls the skill prevents
  4. Reading the summary
  5. Principles
  6. How to use it & best prompts
Sekcje z nagłówków SKILL.md, w oryginale · 54 linii, 340 słów
Podgląd SKILL.md
---
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".
Pliki w paczce (2)
  • SKILL.md 3 KB
  • USAGE.md 1 KB

Wersje

W bazie nie ma innych skilli o nazwie benchmarkdotnet-setup.

Migawka bazy z 28.10.2026 · wersja paczki e2372b155f4e (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100microbenchmarking
    Obsługuje tworzenie, uruchamianie, konfigurację i przegląd benchmarków BenchmarkDotNet: projekt mikrobenchmarku, ustawienia projektu i pomiar potrzebny do odpowiedzi na pytania o wydajność .NET.
  • 95bench-fast
    Uruchamia benchmark z minimalną liczbą iteracji, aby wygenerować w BenchmarkDotNet jeden duży plik z kodem asemblera na benchmark.
  • 100split-asm
    Dzieli pliki assembly z BenchmarkDotNet na osobne pliki dla każdej metody benchmarku, przy użyciu narzędzia splitasm.
  • 100revit-benchmarking
    Projektuje i uruchamia pomiary BenchmarkDotNet wykonywane wewnątrz Revit, porównując gorące ścieżki wywołań API Revit.
  • 100microbenchmark
    Generuje i uruchamia doraźne mikrobenchmarki BenchmarkDotNet, aby sprawdzić wpływ zmiany kodu na wydajność w dotnet/runtime na poziomie metody lub API.
  • 100performance-testing
    Mierzy wydajność wskaźników w BenchmarkDotNet: benchmarki Series, Buffer i Stream, wykrywanie regresji oraz wzorce optymalizacji z celami 1,5x dla StreamHub i 1,2x dla BufferList.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.