golang-benchmark

Measure, profile, and compare Go benchmark performance with benchstat.

4|Updated May 17, 2026
One-click install
npx skills add https://github.com/hellopoisonx/aim --skill golang-benchmark-hellopoisonx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-benchmark
Source: https://github.com/hellopoisonx/aim/tree/main/skills/golang-benchmark
Command: npx skills add https://github.com/hellopoisonx/aim --skill golang-benchmark-hellopoisonx

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It prevents misleading optimization decisions by teaching how to benchmark, profile, and compare Go performance results with enough rigor to distinguish signal from noise.

Core Features & Use Cases

  • Benchmark authoring that avoids dead-code elimination: Prefer b.Loop() for Go 1.24+ and structure setup so results reflect the measured work.
  • Reliable benchmark execution: Use -benchmem and multiple iterations (-count=10 or more) and capture outputs for later comparison.
  • Profile-driven diagnosis: Generate CPU, heap (alloc_objects/alloc_space/inuse_space), and execution traces to pinpoint where time and allocations actually come from.
  • Statistical comparison with benchstat: Interpret p-values, confidence intervals, and the meaning of "~" to decide whether changes are real.
  • CI regression workflows: Gate performance changes using benchdiff/cob/gobenchdata with an emphasis on robustness under noisy CI conditions.

Quick Start

Tell the assistant: "Write benchmarks for my Go function, run them with -benchmem and -count=10, produce CPU/heap profiles for any hot spots, and compare before/after results with benchstat, explaining any cases where '~' indicates the change is not statistically significant."

Frequently Asked Questions about golang-benchmark

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write Go benchmarks that avoid dead-code elimination?

To write Go benchmarks that prevent dead-code elimination, use b.Loop() for Go 1.24+ and structure setup so results reflect the measured work. This approach avoids misleading optimization decisions.

What's the best way to compare Go benchmark results statistically?

The best way to compare Go benchmark results statistically is using benchstat. Interpret p-values, confidence intervals, and '~' markers to decide whether performance changes across code revisions are real or just noise.

How do I capture CPU and heap profiles when running Go benchmarks?

To capture CPU and heap profiles during Go benchmark execution, run benchmarks with controlled flags like -benchmem and multiple iterations. Generate pprof profile types and execution traces to pinpoint where time and allocations originate.

Can I detect performance regressions in CI using Go benchmarks?

Yes, you can detect performance regressions in CI using Go benchmarks. Gate performance changes using tools like benchdiff, cob, or gobenchdata with benchstat-backed comparisons, emphasizing robustness under noisy CI conditions.

Why does benchstat show a '~' when comparing my Go benchmark runs?

Benchstat shows a '~' when comparing Go benchmark runs to indicate that the performance change is not statistically significant. This means the observed difference falls within confidence intervals and likely represents noise rather than a real improvement.