Skip to content
analyze-perf logo

Analyze-Perf

analyze-perf

Go プロジェクトのパフォーマンスを計測・分析する。「パフォーマンス計測」「ベンチマーク」「perf」「性能測定」「プロファイリング」「最適化提案」「パフォーマンス分析」などで起動。ベンチマーク実行、プロファイリング、改善案の提示をサポート。

SKILL.md

Full skill instructions

Analyze-Perf

Go プロジェクトのパフォーマンスを計測・分析し、改善案を提示します。

引数

  • [パッケージパス]: 対象パッケージ(例: ./​internal/​handler)
  • --bench: ベンチマークのみ実行
  • --profile: プロファイリングを実行
  • --help: ヘルプを表示

実行フロー

1. 対象コードの特定
   ↓
2. ベースライン測定
   ↓
3. ボトルネック分析
   ↓
4. 改善案提示
   ↓
5. ユーザーと方針決定
   ↓
6. 修正実装
   ↓
7. 効果測定

実行手順

1. ベンチマーク実行

# 基本的なベンチマーク
go test -bench=. -benchmem ./​...

# 特定パッケージのベンチマーク
go test -bench=. -benchmem ./​internal/​handler

# 複数回実行して安定した結果を取得
go test -bench=. -benchmem -count=3 ./​... | tee baseline.txt

2. プロファイリング

# CPU プロファイル
go test -bench=. -cpuprofile=cpu.prof ./​...
go tool pprof cpu.prof

# メモリプロファイル
go test -bench=. -memprofile=mem.prof ./​...
go tool pprof mem.prof

# pprof コマンド
# top    - 実行時間が最も長い関数を表示
# list   - 特定関数のソースコード行ごとの分析
# web    - グラフ形式で可視化

3. 結果レポート

## パフォーマンス分析結果

### ベンチマーク結果
- BenchmarkXxx: {N} ns/​op
- メモリアロケーション: {M} B/​op
- アロケーション回数: {K} allocs/​op

### 特定されたボトルネック
1. {関数名}: {問題の説明}
2. {関数名}: {問題の説明}

### 改善案
| 提案 | 内容 | 期待される改善 |
|------|------|---------------|
| 1 | {改善内容} | {効果} |
| 2 | {改善内容} | {効果} |

どの改善案を適用しますか?

改善案の観点

観点改善例
データ構造slice、map の適切な選択
アルゴリズム計算量の削減、キャッシング
並行処理goroutine、channel、ワーカープール
メモリ管理sync.Pool、スライスの事前確保
文字列操作strings.Builder の使用
PGOProfile-Guided Optimization(Go 1.22+)

期待される改善率の目安

最適化内容期待される改善率
スライスの事前確保メモリ 30-50% 削減
ポインタレシーバCPU 20-40% 高速化
strings.Builder文字列操作 2-5x 高速化
sync.Poolアロケーション 50-80% 削減
並行処理最適化スループット 2-10x 向上
PGO全体 2-14% 高速化

benchstat による比較

# 最適化前
go test -bench=. -benchmem -count=3 ./​... | tee before.txt

# 最適化後
go test -bench=. -benchmem -count=3 ./​... | tee after.txt

# 比較
benchstat before.txt after.txt

重要な注意事項

  • ✅ 最適化前に必ずベンチマークで現状を測定
  • ✅ 修正前後のベンチマーク結果を比較して効果を確認
  • ✅ 実際にボトルネックとなっている箇所に集中
  • ❌ パフォーマンス向上のために可読性を大きく損なわない
  • ❌ 早すぎる最適化を避ける

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View