Analyse des performances Go

VérifiéSûr

Exécute des benchmarks Go avec statistiques mémoire pour identifier les opportunités d'optimisation. Analyse les résultats comme ns/op, B/op, allocs/op pour trouver les points chauds. Aide les développeurs à réduire les allocations, améliorer le débit et comparer les changements de performance.

Spar Skills Guide Bot
TestingIntermédiaire
6002/06/2026
Claude Code
#go#benchmarking#performance#memory#optimization

Recommandé pour

Notre avis

Exécute des benchmarks Go, analyse les résultats incluant les allocations et le temps, et identifie des opportunités d'optimisation.

Points forts

  • Découvre automatiquement les fonctions de benchmark dans les fichiers de test Go.
  • Exécute les benchmarks avec les statistiques d'allocation mémoire pour une analyse complète.
  • Identifie les points chauds spécifiques et suggère des optimisations exploitables.
  • Compare optionnellement les résultats avec des exécutions précédentes via benchstat.

Limites

  • Nécessite des fonctions de benchmark existantes dans le code.
  • Dépend de `-benchmem` qui peut ne pas capturer toutes les sources d'allocation.
  • Ne réalise pas de profilage CPU ; se concentre uniquement sur la sortie des benchmarks.
Quand l'utiliser

Lorsque vous avez besoin d'identifier rapidement des goulots d'étranglement de performance et des problèmes d'allocation mémoire dans du code Go avec des benchmarks existants.

Quand l'éviter

Lorsque vous avez besoin d'un profilage CPU détaillé, de flame graphs, ou lorsque vous travaillez avec d'autres langages que Go.

Analyse de sécurité

Sûr
Score qualité90/100

The skill runs standard Go benchmarking commands (go test -bench) and analyzes results. It does not execute external or obfuscated payloads, and does not instruct to disable safety or destructively modify the system. Using Bash is necessary for running Go tools, which is a legitimate development activity.

Aucun point d'attention détecté

Exemples

Run benchmarks and analyze performance
Run all Go benchmarks in this project with memory statistics and identify the most significant optimization opportunities.
Compare current results with a baseline
Run benchmarks and compare the results with the saved baseline file 'old.txt' to detect performance regressions.
Find missing benchmarks
Check if this Go project has benchmarks. If not, suggest which functions should be benchmarked based on complexity and usage frequency.

name: go-bench description: Run Go benchmarks, analyze allocations and performance, identify optimization targets user-invocable: true allowed-tools: Read, Grep, Glob, Bash

You are a Go performance analyst. Run benchmarks, interpret results, and identify real optimization opportunities.

Steps

  1. Find benchmarks: Use Glob to find *_test.go files. Use Grep to find func Benchmark functions.

  2. Run benchmarks: Execute go test -bench=. -benchmem -count=3 ./... to get stable results with memory stats.

  3. Parse results: For each benchmark, note:

    • ns/op (time per operation)
    • B/op (bytes allocated per operation)
    • allocs/op (allocations per operation)
  4. Identify hot spots: Read the benchmarked functions. Look for:

    • Unnecessary allocations (string concatenation, slice growth, interface boxing)
    • Repeated work that could be cached
    • Synchronization overhead (mutex contention, channel bottlenecks)
    • I/O in hot paths
  5. Compare if possible: If the user provides a baseline or if previous results exist, compare using benchstat if available: go run golang.org/x/perf/cmd/benchstat@latest old.txt new.txt

  6. Output the analysis:

## Benchmark Analysis

### Results
| Benchmark | ns/op | B/op | allocs/op |
|-----------|-------|------|-----------|
| Name      | X     | Y    | Z         |

### Hot Spots
[Functions with high allocations or time, with file:line references]

### Optimization Opportunities
[Specific changes that would reduce allocations or improve throughput, ordered by expected impact]

### Recommendations
[What to benchmark next, what to profile with pprof, or what to leave alone]

If no benchmarks exist, suggest which functions should be benchmarked based on their complexity and call frequency.

Skills similaires