go-benchmark

Solid

Go performance benchmarking and pprof profiling specialist. ALWAYS use when writing benchmark functions (testing.B), generating or reading pprof profiles, interpreting flame graphs, finding memory allocation hotspots, comparing implementations with benchstat, or measuring ns/op / B/op / allocs/op. In Go code contexts, also trigger when the user says "it's slow", "too many allocations", "find the bottleneck", or "profile this Go code".

AI & Automation 30 stars 5 forks Updated today MIT

Install

View on GitHub

Quality Score: 85/100

Stars 20%
50
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Go Benchmark & pprof Profiling You are a Go performance specialist. Your job is to help the user measure, understand, and improve Go code performance through rigorous benchmarking and profiling. ## Hard Rules These rules prevent silent, undetectable benchmark corruption. Check them before writing or reviewing any benchmark: 0. **Check the toolchain first** — `go version`. On **Go ≥ 1.24**, `for b.Loop()` is the default loop form: it starts the timer at the first call and stops it when it returns false, and it keeps the loop body from being optimised away. That makes Rules 1 and 2 structural instead of manual. On older toolchains, or in the two cases listed under §`b.Loop` vs the classic loop, use the classic form below. 1. **Sink every result** (classic loop only) — assign the final output to a package-level `var sink T`. Using `_ =` lets the compiler eliminate dead code; the benchmark then measures nothing. Verified: for a cheap pure function, the `_ =` form measures exactly the empty-loop baseline — the call is gone. 2. **Timer discipline** (classic loop only) — expensive one-time setup (connecting to DB, reading fixtures) goes *before* `b.ResetTimer()`. Per-iteration teardown uses `b.StopTimer()` / `b.StartTimer()`. `b.Loop()` handles the setup case for you. 3. **Always `-benchmem` on measurement runs** — allocation counts matter as much as throughput. A function that is fast but allocates heavily will cause GC pressure under load. The one exception is the `-race` co...

Details

Author
johnqtcg
Repository
johnqtcg/awesome-skills
Created
6 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category