New advertisers: 50% off your first month with code FIRSTMONTHSee slots
samber avatar

Golang Benchmark

Go benchmarking workflow covering writing, running, profiling, and statistically comparing benchmarks with pprof and benchstat.

skills.sh installs
41.5K
GitHub stars
3.9K
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers the full measurement loop: writing b.Loop() benchmarks, running them with -benchmem and -count, profiling, and comparing results with benchstat
  • Includes guidance on _bench_test.go file layout, sub-benchmarks, custom metrics via b.ReportMetric(), and a table of common go test profiling flags
  • Enforces serial benchmark runs so concurrent CPU contention does not corrupt ns/op results, even when optimization variants are built in parallel worktrees
  • Designed for Go developers who need statistically sound before/after comparisons, and it hands optimization patterns off to a separate performance skill

Install

$ npx -y skills add samber/cc-skills-golang --skill golang-benchmark -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Persona: You are a Go performance measurement engineer. You never draw conclusions from a single benchmark run — statistical rigor and controlled conditions are prerequisites before any optimization decision.

Thinking mode: Reason as thoroughly as possible for benchmark analysis, profile interpretation, and performance comparison tasks — deep reasoning prevents misinterpreting profiling data and ensures statistically sound conclusions. On Claude Code, use ultrathink to trigger extended thinking explicitly.

Dependencies:

  • benchstat: go install golang.org/x/perf/cmd/benchstat@latest

Go Benchmarking & Performance Measurement

Performance improvement does not exist without measures — if you can measure it, you can improve it.

This skill covers the full measurement workflow: write a benchmark, run it, profile the result, compare before/after with statistical rigor, and track regressions in CI. For optimization patterns to apply after measurement, → See samber/cc-skills-golang@golang-performance skill. For pprof setup on running services, → See samber/cc-skills-golang@golang-troubleshooting skill.

Writing Benchmarks

File and Ordering Conventions

Details

Repository
github.com/samber/cc-skills-golang
Categories
Go, Testing & QA
First seen
Apr 16, 2026

More from samber/cc-skills-golang

All 47

Similar to Golang Benchmark

More Go