golang-benchmark

Run Go benchmarks with correct methodology and compare results using benchstat.

2|Updated Feb 12, 2024
One-click install
npx skills add https://github.com/adibfirman/dotfiles --skill golang-benchmark-adibfirman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-benchmark
Source: https://github.com/adibfirman/dotfiles/tree/main/claude/.claude/skills/technical/golang/golang-benchmark
Command: npx skills add https://github.com/adibfirman/dotfiles --skill golang-benchmark-adibfirman

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

It eliminates guesswork in Go performance work by turning benchmarking into a statistically rigorous measurement process you can trust.

Core Features & Use Cases

  • Benchmarking workflow: design correct benchmarks (setup isolation, b.Loop() usage, memory reporting) and run them with appropriate flags and repetition.
  • Profiling from benchmark runs: generate CPU, heap, and execution trace artifacts directly from go test -bench runs, then analyze hot paths.
  • Statistical comparison with benchstat: interpret confidence intervals, p-values, and the significance indicator to validate real before/after changes and avoid p-hacking.

Quick Start

Ask the AI to help you write a benchmark for a specific Go function using b.Loop(), run it with -benchmem and -count=10 to produce baseline and optimized result files, and then use benchstat to explain whether any change is statistically significant and what evidence supports the conclusion.

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 using b.Loop() to measure performance correctly?

To write a Go benchmark correctly, isolate setup logic outside the loop, use b.Loop() for iteration, and enable memory reporting with -benchmem to ensure defensible performance measurement.

How do I generate a CPU or heap profile from a Go benchmark run?

Generate CPU and heap profiles from a Go benchmark by running go test -bench with profiling flags, creating artifacts directly from the run to analyze hot paths and execution traces.

How do I interpret benchstat results for Go performance regression detection?

Interpret benchstat results for regression detection by analyzing confidence intervals, p-values, and the significance indicator to validate real before/after changes and avoid p-hacking from single runs.

Why are my Go benchmark results inconsistent across multiple runs?

Inconsistent Go benchmark results occur when drawing conclusions from single runs; rigorous measurement controls require appropriate iteration counts and running -count=10 to produce statistically defensible comparisons.

Do I need benchstat installed to compare Go benchmark results?

Yes, you need benchstat installed to compare Go benchmark results statistically, as it processes baseline and optimized result files to calculate confidence intervals and validate performance changes.