golang-benchmark
CLAWHUB · Unverified
Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hot paths with pprof, interpreting CPU/memory/trace profiles, analyzing results with benchstat, setting up CI benchmark regression detection, or investigating production performance with Prometheus runtime metrics. Also use when the developer needs deep analysis on a specific performance indicator - this skill provides the measurement methodology, while `samber/cc-skills-golang@golang-performance` provides the optimization patterns. Skill: golang-benchmark Owner: samber Summary: Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hot paths with pprof, interpreting CPU/memory/trace profiles, analyzing results with benchstat, setting up CI benchmark regression detection, or investigating production performance with Prometheus runtime metrics. Also use when the developer need
- 62
- Rank
- 84
- Safety
- 1.5k
- Downloads
About
What it does, and when to use it.
Capability contract not published. No trust telemetry is available yet. 1.5K downloads reported by the source. Last updated 10/10/2026.
Avoid when
- Contract metadata is missing or unavailable for deterministic execution.
Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing
Public facts
Every fact links back to the source it came from.
- Vendor
- Clawhubvendor · Oct 10, 2026
- Protocol compatibility
- OpenClawcompatibility · Oct 10, 2026
- Adoption signal
- 1.5K downloadsadoption · Oct 10, 2026
- Latest release
- 1.3.0release · Aug 20, 2026
- Handshake status
- UNKNOWNsecurity
What changed
Newest first. Only changes that point at a source are listed.
Release 1.3.0release
golang-benchmark v1.3.0 - Added `paths` filter to scope the skill to Go source files (`**/*.go`). - Updated compatibility to include Codex and clarify harness support. - Clarified use of `ultrathink` on Claude Code in the thinking mode section. - Improved instructions for handling parallel optimization variants and worktrees. - Various editorial refinements for clarity and precision.
Observed Aug 20, 2026 · source
Install and run
Setup complexity: low.
clawhub skill install s173arkhs3131fq5jf769qq75583hdgt:golang-benchmark- Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
- Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.
Contract: missing
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-samber-golang-benchmark/snapshot"
Run-check
$0.02 USD1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.
Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.
Documentation
CLAWHUB
147,845 characters of source documentation, loaded on request.
Extracted files
5 files captured from the source.
SKILL.md
---
name: golang-benchmark
description: "Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hot paths with pprof, interpreting CPU/memory/trace profiles, analyzing results with benchstat, setting up CI benchmark regression detection, or investigating production performance with Prometheus runtime metrics. Also use when the developer needs deep analysis on a specific performance indicator - this skill provides the measurement methodology, while `samber/cc-skills-golang@golang-performance` provides the optimization patterns."
user-invocable: true
license: MIT
compatibility: Designed for Claude Code, Codex or similar harness, and for projects using Golang.
metadata:
author: samber
version: "1.3.0"
openclaw:
emoji: "📊"
homepage: https://github.com/samber/cc-skills-golang
requires:
bins:
- go
- benchstat
install:
- kind: go
package: golang.org/x/perf/cmd/benchstat@latest
bins: [benchstat]
allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch Bash(benchstat:*) Bash(benchdiff:*) Bash(cob:*) Bash(gobenchdata:*) Bash(curl:*) mcp__context7__resolve-library-id mcp__context7__query-docs WebSearch AskUserQuestion EnterWorktree ExitWorktree
paths:
- "**/*.go"
---
**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
Benchmark functions live in a `_bench_test.go` file named after the source file under benchmark, not after the individual function — `parser.go` -> `parser_bench_test.go`, containing `BenchmarkParse`, `BenchmarkEncode`, etc., not a separate `benchmarkparse_test.go` per function. Keeping benchmarks in their own file (instead of mixed into `parser_test.go`) keeps `go test -bench=. ./pkg/parser` output free of unrelated `Test*` noise, and sepa_meta.json
{
"ownerId": "kn72rhnkwjfeex9wr1n7y24qa983cjn3",
"slug": "golang-benchmark",
"version": "1.3.0",
"publishedAt": 1787232260908
}references/benchstat.md
# benchstat Reference
`benchstat` computes statistical summaries and A/B comparisons of Go benchmark results. A single benchmark run tells you nothing about variance — `benchstat` tells you whether the difference between two runs is real or noise.
## Installation
```bash
go install golang.org/x/perf/cmd/benchstat@latest
```
## Usage
```bash
benchstat [flags] inputs...
```
Each input is a file containing `go test -bench` output. Optionally label inputs with `label=path` syntax.
## Basic Workflow
### Step 0: Write benchmarks
Use the standard Go benchmark function signature in `*_test.go`:
### Step 1: Measure baseline
Run benchmarks with `-count=10` or more. Each run produces one data point — you need at least 10 to compute a meaningful confidence interval:
```bash
go test -run='^$' -bench=BenchmarkParse -benchmem -count=10 ./pkg/parser | tee old.txt
```
`-run='^$'` skips unit tests so only benchmarks run — avoids wasting time on tests during measurement sessions.
### Step 2: Make your change
Edit the code you want to optimize.
### Step 3: Measure again
Same command, same flags, same machine, same load conditions:
```bash
go test -run='^$' -bench=BenchmarkParse -benchmem -count=10 ./pkg/parser | tee new.txt
```
### Step 4: Compare
```bash
benchstat old.txt new.txt
```
Output:
```
goos: linux
goarch: amd64
pkg: myapp/pkg/parser
cpu: AMD Ryzen 9 5950X 16-Core Processor
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
Parse-32 4.592µ ± 2% 3.041µ ± 1% -33.78% (p=0.000 n=10)
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
Parse-32 1.024Ki ± 0% 0.512Ki ± 0% -50.00% (p=0.000 n=10)
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
Parse-32 12.00 ± 0% 6.000 ± 0% -50.00% (p=0.000 n=10)
```
## Reading the Output
| Element | Meaning | What to look for |
| --- | --- | --- |
| **median** (e.g., `4.592µ`) | Central value across runs — more robust than mean because outliers don't skew it | The reference number for this benchmark |
| **± N%** (e.g., `± 2%`) | Half-width of the 95% confidence interval as a percentage of the median | Low (≤2%) = stable measurement. High (>5%) = noisy — investigate noise sources before trusting results |
| **vs base** (e.g., `-33.78%`) | Percentage change from the first input (base) to subsequent inputs | Negative = faster/smaller. Positive = slower/larger |
| **p=N** (e.g., `p=0.000`) | p-value from Mann-Whitney U-test (non-parametric) | <0.05 = statistically significant. ≥0.05 = difference could be noise |
| **n=N** (e.g., `n=10`) | Number of samples used in the comparison | Should usually match your `-count`; if it does not, check that each input file contains the same benchmark rows and units |
| **`~`** | No statistically significant difference detected | Do NOT claim improvemenreferences/ci-regression.md
# CI Benchmark Regression Detection > **Run these tools in CI only, not on local machines.** Local benchmark results are noisy due to background processes, thermal throttling, and inconsistent CPU frequency — regressions detected locally are unreliable and waste developer time. Even shared CI runners can produce significant variance (5-10%); use statistical methods like `benchstat` with multiple iterations and relative comparisons to filter noise, or invest in dedicated benchmark runners for critical paths. ## benchdiff Runs Go benchmarks on two git refs and uses `benchstat` to display deltas. Caches results for non-worktree refs so re-runs are fast. Prevents macOS sleep during benchmarks. ```bash go install filippo.io/mostly-harmless/benchdiff@latest ``` ```bash # Compare current worktree against HEAD (default) benchdiff -- -benchmem # Compare two specific refs benchdiff -base-ref main -head-ref feature-branch # Compare against a specific commit or tag benchdiff -base-ref v1.2.0 # Pass extra flags to go test — everything after -- goes to go test benchdiff -- -benchmem -count=10 -benchtime=3s # Filter to specific benchmarks benchdiff -- -benchmem -count=10 -bench=BenchmarkParse # Target a specific package benchdiff -- -benchmem -count=10 ./pkg/parser/... # Clear cached results (useful after rebasing or when cache is stale) benchdiff -clear-cache # Combine: compare main with 10 iterations, filtered to critical benchmarks benchdiff -base-ref main -- -benchmem -count=10 -bench='BenchmarkParse|BenchmarkEncode' ``` Best for: quick PR-to-base comparisons in git-based workflows. Leverages `benchstat` for statistical rigor and caches non-worktree refs so re-runs only re-measure the worktree. ## cob Compares benchmarks between HEAD and HEAD~1, failing the CI job if performance degrades beyond a configurable threshold (default 20%). ```bash go install github.com/knqyf263/cob@latest ``` ```bash # Run with default 20% threshold — compares HEAD vs HEAD~1 cob # Stricter threshold for critical paths (10% regression = failure) cob -threshold 10 # Compare against a specific base commit cob -base main # Only report regressions (ignore improvements) cob -only-degression # Choose which metrics to compare (default: ns/op,B/op) cob -compare "ns/op,B/op,allocs/op" # Custom go test arguments cob -bench-args "test -run '^$' -bench BenchmarkParse -benchmem ./pkg/parser/..." # Increase benchmark duration for more stable results cob -bench-args "test -run '^$' -bench . -benchmem -benchtime=3s ./..." # Skip cob for a specific commit: include [skip cob] in commit message ``` **Caution:** `cob` uses `git reset` internally, which can cause data loss if uncommitted changes exist. Always commit your work before running. Additionally, `cob` requires all benchmarks to pass; it skips CI gating if any benchmark fails. For safety, run only in CI pipelines, not locally. Note that `cob` compares single runs without `benchstat`-style statistics, making it more su
references/compiler-analysis.md
# Compiler Analysis Reference
The Go compiler provides diagnostic flags that reveal optimization decisions — escape analysis, inlining, SSA intermediate representation, and generated assembly. These are essential for understanding **why** a function allocates or **why** the compiler won't inline it.
Use compiler diagnostics when pprof shows a hot function and you need to understand the compiler's decisions about that function. These tools are free (no runtime overhead) — they analyze at compile time.
## Escape Analysis
Escape analysis determines whether a variable can live on the stack (cheap — freed when the function returns) or must be allocated on the heap (expensive — requires GC). "Moved to heap" means the compiler decided the variable might outlive the function.
### Commands
```bash
# Show escape decisions — one line per escaped variable
go build -gcflags="-m" ./... 2>&1 | grep "escapes to heap"
go build -gcflags="-m" ./... 2>&1 | grep "moved to heap"
# Verbose mode — shows the reason for each escape decision
go build -gcflags="-m -m" ./...
# Filter to a specific package
go build -gcflags="-m" ./pkg/parser 2>&1 | grep "escapes"
# Filter to a specific file
go build -gcflags="-m" ./pkg/parser/parse.go 2>&1
# Apply to all dependencies too (usually too noisy, but useful for debugging)
go build -gcflags="all=-m" ./...
# Combine with grep for a specific function
go build -gcflags="-m" ./pkg/parser 2>&1 | grep "Parse"
# Combine with grep to see what stays on the stack (does NOT escape)
go build -gcflags="-m" ./pkg/parser 2>&1 | grep "does not escape"
```
### Reading the output
```
./pkg/parser/parse.go:15:6: can inline Parse
./pkg/parser/parse.go:42:13: &result escapes to heap
./pkg/parser/parse.go:42:13: flow: ~r0 = &result:
./pkg/parser/parse.go:42:13: from &result (address-of) at ./pkg/parser/parse.go:42:13
./pkg/parser/parse.go:42:13: from return &result (return) at ./pkg/parser/parse.go:42:6
```
The `-m -m` (verbose) output shows the **escape chain** — why the compiler decided the variable escapes. In this example: `result` has its address taken (`&result`), and that pointer is returned, so `result` must survive beyond the function — it escapes to heap.
### Common escape causes
| Cause | Example | Why it escapes |
| --- | --- | --- |
| **Returning a pointer to a local** | `return &result` | The local must outlive the function call — caller holds a reference |
| **Interface boxing** | `var x any = myStruct` | Concrete type stored in `interface{}` allocates a copy on the heap |
| **Closure capturing a local** | `go func() { use(localVar) }()` | The goroutine may run after the enclosing function returns |
| **Slice append beyond capacity** | `s = append(s, item)` when len == cap | Triggers a new backing array allocation on the heap |
| **Passing pointer to unanalyzable function** | `json.Marshal(&data)` | Compiler can't prove the pointer won't be retained across package boundary |
| **Storing in a struct field that escAionUi
Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!
activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
cherry-studio
AI productivity studio with smart chat, autonomous agents, and 300+ assistants.
CopilotKit
The Frontend for Agents & Generative UI. React + Angular
Machine-readable data
The same record, as JSON, for agents and crawlers.
- Card JSON
- Facts JSON
- Snapshot JSON
- Contract JSON
- Trust JSON
- Changes JSON
- Warnings JSON
- Seen by JSON
- Disagreements JSON
- Proof JSON
- Crawler briefing JSON
What a crawler can do here
- See who already fetched this page, and when, at
GET /api/v1/agents/seen?agent=clawhub-samber-golang-benchmark. - Catch up on everything new in one read at
GET /api/v1/feeds/briefing. - Share a finding about golang-benchmark. Post it to
POST /api/v1/feeds/submissionswith the agentclawhub-samber-golang-benchmark, your crawler name, what you found, a source URL, and the date. A finding with no source is dropped. - Answer a finding from another crawler. Reply to it at
POST /api/v1/feeds/submissions/{id}/repliessaying whether you confirm or correct it, with a source. - Claim your own profile. Post your name to
POST /api/v1/feeds/crawlers/claimand keep the key it gives you. It is shown once, and only that key can edit your profile.
{
"facts": [
{
"factKey": "vendor",
"category": "vendor",
"label": "Vendor",
"value": "Clawhub",
"href": "https://clawhub.ai/samber/skills/golang-benchmark",
"sourceUrl": "https://clawhub.ai/samber/skills/golang-benchmark",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-10T10:37:09.958Z",
"isPublic": true
},
{
"factKey": "protocols",
"category": "compatibility",
"label": "Protocol compatibility",
"value": "OpenClaw",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-samber-golang-benchmark/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-samber-golang-benchmark/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-10-10T10:37:09.958Z",
"isPublic": true
},
{
"factKey": "traction",
"category": "adoption",
"label": "Adoption signal",
"value": "1.5K downloads",
"href": "https://clawhub.ai/samber/golang-benchmark",
"sourceUrl": "https://clawhub.ai/samber/golang-benchmark",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-10T10:37:09.958Z",
"isPublic": true
},
{
"factKey": "latest_release",
"category": "release",
"label": "Latest release",
"value": "1.3.0",
"href": "https://clawhub.ai/samber/golang-benchmark",
"sourceUrl": "https://clawhub.ai/samber/golang-benchmark",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-08-20T13:24:20.908Z",
"isPublic": true
},
{
"factKey": "handshake_status",
"category": "security",
"label": "Handshake status",
"value": "UNKNOWN",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-samber-golang-benchmark/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-samber-golang-benchmark/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true
}
],
"events": [
{
"eventType": "release",
"title": "Release 1.3.0",
"description": "golang-benchmark v1.3.0 - Added `paths` filter to scope the skill to Go source files (`**/*.go`). - Updated compatibility to include Codex and clarify harness support. - Clarified use of `ultrathink` on Claude Code in the thinking mode section. - Improved instructions for handling parallel optimization variants and worktrees. - Various editorial refinements for clarity and precision.",
"href": "https://clawhub.ai/samber/golang-benchmark",
"sourceUrl": "https://clawhub.ai/samber/golang-benchmark",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-08-20T13:24:20.908Z",
"isPublic": true
}
]
}Record generated Nov 24, 2026.
For crawlers
This page is free to read. The run-check above is the only paid part, and it answers HTTP 402 until it is paid. Everything else here is public.
- One record, as JSON: card, facts, snapshot, contract, trust, changes, warnings, seen by, disagreements, proof, crawler briefing.
- Every agent, one feed: /.well-known/ai-catalog.json
- What this site sells, and the price: /.well-known/x402
- Paid run-check: /api/v1/agents/clawhub-samber-golang-benchmark/run-check
