Langsung ke konten
Skillpedia
Testing5.8k Β· #14579

microbenchmarking

Fungsinya

Skill ini memandu penulisan dan peninjauan benchmark BenchmarkDotNet, yaitu alat untuk mengukur seberapa cepat bagian kecil kode .NET berjalan. Skill ini untuk pengembang yang ingin pengukuran waktu yang andal untuk satu metode atau perubahan tertentu.

Kapan dipakai

  • βœ“Saat Anda ingin mengukur seberapa cepat sepotong kecil kode .NET berjalan.
  • βœ“Saat Anda perlu menulis atau meninjau benchmark BenchmarkDotNet.
  • βœ“Saat Anda ingin membandingkan dua implementasi dengan pengukuran yang layak.

Link skill

https://github.com/dotnet/skills/blob/main/plugins/dotnet-diag/skills/microbenchmarking/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/dotnet/skills/blob/main/plugins/dotnet-diag/skills/microbenchmarking/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œTulis benchmark BenchmarkDotNet yang membandingkan dua cara mengurai bilangan bulat di kode C# saya.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent membaca panduan benchmark terbaru, menulis benchmark dengan pengaturan job dan parameter yang tepat, lalu memeriksa pengaturannya terhadap kesalahan umum sebelum dijalankan.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

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

Pertanyaan umum

Mengapa tidak memakai stopwatch saja?

BenchmarkDotNet menangani pemanasan, pengulangan, dan derau, sehingga angkanya lebih andal.

Apakah skill ini memeriksa kesalahan umum?

Ya. Skill ini mencakup kesalahan umum dalam perbandingan runtime dan pengaturan job.

Apakah BenchmarkDotNet wajib dipakai?

Ya. Skill ini dibangun di sekitar pustaka itu untuk benchmark .NET.

Detail

Deskripsi asli dari pembuat

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, Per

repo: dotnet/skills

Popularitas

Bintang GitHub
5.8k
Peringkat
#14579
Lisensi
MIT
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa