golang-benchmark

Write and execute Go benchmarks with benchstat significance testing and pprof profiling.

Updated May 28, 2026
One-click install
npx skills add https://github.com/vanstinator/semantic-search --skill golang-benchmark-vanstinator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-benchmark
Source: https://github.com/vanstinator/semantic-search/tree/main/.agents/skills/golang-benchmark
Command: npx skills add https://github.com/vanstinator/semantic-search --skill golang-benchmark-vanstinator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires benchstat, and includes references (resource) components.

What problem does it solve?

This Skill prevents misleading Go performance decisions by teaching you to benchmark, profile, and compare results with proper statistical and methodological discipline.

Core Features & Use Cases

  • Benchmark writing that avoids dead-code elimination: Prefer b.Loop() on Go 1.24+ and structure setup vs timed work correctly.
  • Reliable benchmark execution: Use -count and -benchmem to gather repeatable timing and allocation data, and capture output for later comparison.
  • Rigorous before/after comparison: Interpret benchstat output correctly (including confidence intervals and the ~ “not significant” indicator) and avoid p-hacking.
  • Profiling from benchmark findings: Generate CPU/heap/trace artifacts from go test runs and use pprof/trace guidance to explain where time and allocations come from.
  • CI regression detection: Select appropriate tooling (benchdiff, cob, gobenchdata) and mitigate noisy-neighbor issues so performance gates are trustworthy.
  • Performance investigation playbook: Use references to connect symptoms (benchmarks/profiles/metrics) to root-cause hypotheses and next diagnostic steps.

Quick Start

Ask an agent: “Using the golang-benchmark skill, show me how to write a correct Go benchmark for my hot function, run it with statistical confidence, and explain the benchstat results before I merge my optimization.”

Frequently Asked Questions about golang-benchmark

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

FAQPage Schema
How do I write a Go benchmark that avoids dead-code elimination?

To write a Go benchmark that avoids dead-code elimination, use b.Loop() on Go 1.24+ and structure setup code outside the timed work. This ensures the compiler does not optimize away the operations being measured.

How do I compare Go benchmark results with benchstat?

Compare Go benchmark results with benchstat by running tests multiple times using -count and capturing the output. benchstat performs significance testing and displays confidence intervals, indicating whether performance changes are statistically valid or marked as not significant.

How do I generate a pprof profile from a Go benchmark?

Generate a pprof profile from a Go benchmark by running your tests with specific profiling flags to produce CPU, heap, or execution trace artifacts. You can then use pprof guidance to identify where time and allocations originate.

How do I set up CI regression detection for Go performance?

Set up CI regression detection for Go performance by selecting tooling like benchdiff, cob, or gobenchdata. These tools help mitigate noisy-neighbor issues and establish trustworthy performance gates to catch regressions before merging.

Why are my Go benchmark results noisy and inconsistent?

Go benchmark results are noisy and inconsistent when running single tests or ignoring statistical variance. You should use -count for repeatable timing, -benchmem for allocation data, and analyze outputs with benchstat to avoid drawing misleading conclusions.