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★ 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
Relevance: One benchmark answers one question about a real hot path or user-facing operation. Use inputs with a realistic size and distribution.
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.
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.
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.
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.
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.
Naming: A benchmark's identity sets its history. Framework integrations use the file path, name, and parameters. The exec harness uses the
namefield, or the full command when there is none. Keep the identity stable, unique within a run, and descriptive of the scenario.Environment: Pin the toolchain and commit lockfiles. Avoid
latestandstabletags in CI. Run walltime benchmarks on CodSpeed Macro Runners. Base and head must run on the same hardware.
Verify
- Read the benchmark against the rules.
- 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_runreports 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_flamegraphshows the function under test, not setup code, as the main cost.
- 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_resultshows 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
- Call
compare_runson two runs that disagree. If it lists environment differences (hardware, toolchain, integration version), fix rule 8 first. - Call
query_flamegraphon both runs and find what differs. Allocator, garbage collector, hashing, or I/O frames point to rules 4 and 5. - Fix the benchmark, then verify.
- 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.
Установить 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), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic