golang-benchmark

Standardize Go benchmarking with b.Loop(), benchstat, and pprof profiles.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/dashkan/pivox --skill golang-benchmark-dashkan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-benchmark
Source: https://github.com/dashkan/pivox/tree/main/.agents/skills/golang-benchmark
Command: npx skills add https://github.com/dashkan/pivox --skill golang-benchmark-dashkan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It eliminates guesswork in Go performance work by providing a statistically rigorous, end-to-end method to measure, profile, and compare benchmark results.

Core Features & Use Cases

  • Go benchmark correctness: uses Go 1.24+ b.Loop() to avoid dead-code-elimination mistakes and to keep setup out of timing.
  • Benchmark execution and reporting: guides reliable benchmark runs with -count, -benchmem, and profile flags (cpu/mem/trace).
  • Statistical comparison and regression safety: interprets benchstat output (confidence intervals, p-values, and the ~ “not significant” case) and recommends CI regression detection workflows.

Quick Start

Ask an AI coding agent to help you write a new Go benchmark for your hot function using b.Loop(), then run it with -benchmem and compare before/after using benchstat so you can confidently decide whether to merge the 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 Go benchmarks correctly to avoid dead-code elimination?

Use Go 1.24+ b.Loop() to structure benchmarks, keeping setup code outside the timing loop and preventing the compiler from eliminating the code you intend to measure.

How do I compare Go benchmark results reliably with benchstat?

Compare Go benchmark results reliably by running benchmarks with -count and interpreting benchstat output using confidence intervals and p-values, avoiding conclusions from single runs or insignificant ~ results.

How do I generate and interpret pprof CPU and heap profiles in Go?

Generate pprof CPU and heap profiles by running Go benchmarks with profile flags, then analyze the execution traces to debug performance bottlenecks and validate optimization changes.

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

Set up CI performance regression detection by running Go benchmarks with -count and -benchmem on every change, then using benchstat to gate merges based on statistically significant performance shifts.

Why are my Go benchmark results inconsistent between runs?

Inconsistent Go benchmark results often come from single runs or noisy environments; ensure reliable execution by using -count for multiple iterations and checking benchstat for statistical significance.