golang-benchmark

Write Go benchmarks, analyze pprof profiles, and compare results with benchstat.

2|Updated Mar 13, 2023
One-click install
npx skills add https://github.com/haipham22/golang-sample --skill golang-benchmark-haipham22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-benchmark
Source: https://github.com/haipham22/golang-sample/tree/main/.agents/skills/golang-benchmark
Command: npx skills add https://github.com/haipham22/golang-sample --skill golang-benchmark-haipham22

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you measure, compare, and explain Go performance without relying on guesswork, so optimization decisions are based on evidence instead of a single noisy run.

Core Features & Use Cases

  • Benchmark Authoring: Write correct Go benchmarks with modern loop patterns, allocation tracking, and custom metrics.
  • Profile Analysis: Interpret CPU, heap, goroutine, mutex, block, and trace data to find real bottlenecks.
  • Statistical Comparison: Use benchstat-friendly workflows to compare baseline and optimized runs with confidence intervals and p-values.
  • CI Regression Detection: Set up benchmark checks in CI to catch performance regressions before they ship.
  • Use Case: A Go service is getting slower after a refactor, and this Skill helps you benchmark the hot path, inspect profiles, and prove whether the change is a real improvement.

Quick Start

Ask me to benchmark a Go function, compare two benchmark runs, or analyze a pprof or trace profile from your project.

Frequently Asked Questions about golang-benchmark

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

FAQPage Schema
How do I write reliable Go benchmarks to measure function performance?

To write reliable Go benchmarks, use modern loop patterns, track memory allocations, and apply custom metrics to measure function performance accurately. This ensures reproducible measurement workflows, capturing precise timing and memory allocation data for evidence-based optimization decisions.

How do I analyze a pprof CPU or heap profile to find bottlenecks in my Golang application?

To find bottlenecks in your Golang application, analyze pprof CPU, heap, goroutine, mutex, block, and trace data. Interpreting these profiles helps locate exact resource consumption paths, identifying whether issues stem from CPU cycles, memory allocations, or concurrency contention.

What is the best way to compare Go benchmark results statistically?

Use benchstat-friendly workflows to compare Go benchmark results statistically, evaluating baseline and optimized runs. This provides confidence intervals and p-values, proving whether a change is a real improvement rather than a result of noisy single runs.

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

Set up CI regression detection by configuring benchmark checks in your continuous integration pipeline to catch performance regressions before they ship. This workflow automatically compares new benchmark runs against established baselines, preventing code refactors from silently degrading service speed.

Why does my Go benchmark show inconsistent timing results across runs?

Inconsistent Go benchmark timing results often stem from relying on a single noisy run instead of reproducible measurement workflows. To resolve this, use benchstat to compare multiple runs statistically with confidence intervals, ensuring optimization decisions are based on evidence rather than noise.