performance

Profile, benchmark, and optimize Go application performance using pprof and testing benchmarks.

111|73|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/autopus-ai/autopus-adk --skill performance-autopus-ai
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: performance
Source: https://github.com/autopus-ai/autopus-adk/tree/main/.omp/skills/performance
Command: npx skills add https://github.com/autopus-ai/autopus-adk --skill performance-autopus-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Go developers often guess at performance bottlenecks instead of measuring them, leading to wasted optimization effort and regressions. This Skill provides concrete patterns for benchmarking, CPU/memory/goroutine profiling with pprof, and common optimization techniques so performance work is driven by data. ## Core Features & Use Cases - Benchmark Authoring: Write Go benchmarks with testing.B, allocation tracking via b.ReportAllocs(), and run them with go test -bench flags including -benchmem and -count. - pprof Profiling: Collect CPU, heap, and goroutine profiles from a running server via net/http/pprof or from test runs with -cpuprofile and -memprofile flags. - Optimization Patterns: Apply pre-allocation of slices, sync.Pool buffer reuse, and strings.Builder concatenation to reduce allocations, plus caching strategies with sync.Map, LRU, or Redis. - Use Case: A Go API endpoint is slow under load. Use this Skill to capture a 30-second CPU profile, identify the hot function, write a benchmark, apply pre-allocation and pooling, then verify the improvement with before/after numbers. ## Quick Start Ask the agent to profile the slow endpoint in my Go service and write a benchmark comparing performance before and after optimization.

Frequently Asked Questions about performance

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

FAQPage Schema
How do I write a benchmark in Go?▼

Write a function starting with Benchmark that takes *testing.B and loops b.N times over the code under test. Call b.ResetTimer() after setup and b.ReportAllocs() to track memory allocations, then run it with go test -bench=. -benchmem.

How to profile CPU usage in a Go application?▼

Import net/http/pprof and start an HTTP server on a debug port such as localhost:6060. Then collect a profile with go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30 to analyze where CPU time is spent.

How do I reduce memory allocations in Go code?▼

Pre-allocate slices with make([]T, 0, len) instead of relying on append growth, reuse buffers with sync.Pool, and use strings.Builder instead of repeated string concatenation. Verify improvements with b.ReportAllocs() in benchmarks.

Can I capture pprof profiles from Go tests?▼

Yes, run go test with -cpuprofile=cpu.out and -memprofile=mem.out alongside -bench to write profile files during test execution. Inspect them interactively with go tool pprof -http=:8080 cpu.out.

When should I use sync.Pool in Go?▼

Use sync.Pool for frequently allocated temporary objects like bytes.Buffer in hot paths, where reuse reduces GC pressure. Always Reset the object before reuse and avoid pooling objects that hold state needed across calls.