Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

codspeed-write-benchmarks

БесплатноБез исполняемых скриптовНе проверен

Write, fix, and maintain benchmarks so that CodSpeed measurements are valid and stable. Use this skill when adding benchmarks to a project that already runs…

CodSpeedHQот CodSpeedHQ★ 394 звезды на GitHub

Об этом скилле

Write Benchmarks

A benchmark is useful when a change in its result means a change in the code. Apply the rules below when writing a benchmark, and use them as the checklist when one misbehaves.

Run benchmarks through the CodSpeed CLI (codspeed run, codspeed exec) and read results with the CodSpeed MCP tools, not from raw framework output.

Rules

  1. Relevance: One benchmark answers one question about a real hot path or user-facing operation. Use inputs with a realistic size and distribution.

  2. Validity: The code under test must actually run. Use its result (return it, or pass it to the framework's black box) and keep inputs opaque to the optimizer, otherwise the work can be removed or computed at compile time. See optimized-out benchmarks.

  3. Measured region: Measure only the operation under test. Build inputs outside the measured code. If the operation mutates its input, give every iteration a fresh copy through the framework's setup hook. Every iteration must do the same work.

  4. Determinism: The same code must do the same work on every run. Seed random generators, use fixed-seed hashing or ordered containers, sort directory listings, and read committed fixtures. No network, clock, or environment-dependent branches. See Benchmark Variance.

  5. State isolation: A result must not depend on which benchmarks ran before it. Avoid shared caches and globals. Allocator and garbage collector state carries over between benchmarks, so allocate inputs in setup rather than in the measured code. If a micro-benchmark still moves with unrelated code changes, build it into its own binary. See Reducing Variance.

  6. Sizing: Size each benchmark so it gives a valid result under every instrument it runs with. One benchmark can run under several instruments, and each one has its own limits:

    • Simulation runs the code once on a simulated CPU and excludes system calls. Use it for CPU-bound code.
    • Walltime measures real time over repeated rounds and includes I/O. Very short operations need more iterations per round: set the framework's time or iteration options. Avoid running benchmark processes in parallel.
    • Memory runs the code once and tracks every allocation. Keep a benchmark under about 2 million allocations and split larger ones. Allocation order across threads is not deterministic.
  7. Naming: A benchmark's identity sets its history. Framework integrations use the file path, name, and parameters. The exec harness uses the name field, or the full command when there is none. Keep the identity stable, unique within a run, and descriptive of the scenario.

  8. Environment: Pin the toolchain and commit lockfiles. Avoid latest and stable tags in CI. Run walltime benchmarks on CodSpeed Macro Runners. Base and head must run on the same hardware.

Verify

  1. Read the benchmark against the rules.
  2. If the CodSpeed CLI is authenticated and the CodSpeed MCP tools are available, run the benchmark once with the CLI and check with the MCP tools:
    • get_run reports no issue on it.
    • The value is plausible and scales with input size the way the operation should, for example flat for a hash lookup and linear for a scan.
    • query_flamegraph shows the function under test, not setup code, as the main cost.
  3. Only when stability is in question, run it again without any change.
    • Simulation and memory results should be nearly identical. A visible difference means the benchmark breaks rule 4 or 5.
    • Local walltime results vary with the machine. Use them to rank suspects only. Judge stability from CI runs on macro runners, where get_benchmark_result shows the spread across rounds and the outliers.

If the CLI or the MCP tools are not available, report the findings from step 1 and state that nothing was measured.

Maintain

A benchmark is noisy

  1. Call compare_runs on two runs that disagree. If it lists environment differences (hardware, toolchain, integration version), fix rule 8 first.
  2. Call query_flamegraph on both runs and find what differs. Allocator, garbage collector, hashing, or I/O frames point to rules 4 and 5.
  3. Fix the benchmark, then verify.
  4. If the variance belongs to what is measured, such as real I/O, ask the user to set a per-benchmark regression threshold. Ignoring the benchmark is the last resort. Both are dashboard actions.

Audit a suite

List the benchmarks with get_run. Merge or remove benchmarks that answer the same question. Fix or remove those that break a rule. Shrink or split those that dominate the run time. Report hot paths without a benchmark, but do not add speculative ones.

Полный SKILL.md на GitHub

Установить codspeed-write-benchmarks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл codspeed-write-benchmarks?

Write, fix, and maintain benchmarks so that CodSpeed measurements are valid and stable. Use this skill when adding benchmarks to a project that already runs CodSpeed, when a benchmark is noisy, flaky, or changes without a related code change, when CodSpeed reports a benchmark as optimized out or measuring no execution time, when auditing or cleaning up a benchmark suite, when renaming, moving, or removing benchmarks, or when benchmarks need updating after the code under test changed. To install a benchmark framework or wire up CodSpeed for the first time, use codspeed-setup-harness instead.

Как установить скилл codspeed-write-benchmarks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл codspeed-write-benchmarks запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить codspeed-write-benchmarks с