Performance Analyzer
by ntaksh42
Analyze code performance, detect bottlenecks, suggest optimizations for algorithms, queries, and resource usage. Use when improving application performance or investigating slow code.
Skill Details
Repository Files
1 file in this skill directory
name: performance-analyzer description: Analyze code performance, detect bottlenecks, suggest optimizations for algorithms, queries, and resource usage. Use when improving application performance or investigating slow code.
Performance Analyzer Skill
パフォーマンスボトルネックを特定し、最適化提案を行うスキルです。
概要
コードの実行時間、メモリ使用量、アルゴリズム複雑度を分析し、具体的な最適化提案を提供します。
主な機能
- アルゴリズム複雑度分析: Big O記法での評価
- N+1クエリ検出: データベースクエリの最適化
- メモリリーク検出: 未解放リソース、循環参照
- キャッシング機会: メモ化、CDN活用
- 非同期処理: 並列化、Promise最適化
- バンドルサイズ: Tree shaking、Code splitting
- レンダリング最適化: 仮想化、遅延読み込み
使用方法
このコードのパフォーマンス分析:
[コード]
分析項目:
- アルゴリズム複雑度
- メモリ使用量
- 最適化提案
分析例
N+1 クエリ問題
問題のあるコード:
// O(n) のクエリを n 回実行 = O(n²)
const posts = await Post.findAll();
for (const post of posts) {
post.author = await User.findById(post.authorId); // N+1問題
}
最適化:
// O(n) + O(m) = O(n)
const posts = await Post.findAll();
const authorIds = posts.map(p => p.authorId);
const authors = await User.findByIds(authorIds); // 1回のクエリ
const authorMap = new Map(authors.map(a => [a.id, a]));
posts.forEach(post => post.author = authorMap.get(post.authorId));
改善: クエリ数 101回 → 2回、レスポンス時間 90% 削減
アルゴリズム最適化
非効率:
# O(n²) - 遅い
def has_duplicates(arr):
for i in range(len(arr)):
for j in range(i + 1, len(arr)):
if arr[i] == arr[j]:
return True
return False
最適化:
# O(n) - 高速
def has_duplicates(arr):
return len(arr) != len(set(arr))
メモリ最適化
問題:
// メモリリーク: イベントリスナーが解放されない
component.addEventListener('click', handler);
修正:
// クリーンアップ
const controller = new AbortController();
component.addEventListener('click', handler, { signal: controller.signal });
// コンポーネント破棄時
controller.abort();
出力レポート
# パフォーマンス分析レポート
## サマリー
- **Critical**: 2件(即時対応必須)
- **High**: 4件(短期対応)
- **Medium**: 6件(中期改善)
## Critical 問題
### [CRITICAL] N+1 クエリ問題
**場所**: api/posts.ts:45-52
**影響**: 100件のデータで101回のクエリ実行
**レスポンス時間**: 2.5秒 → 0.3秒(88%改善可能)
### [CRITICAL] O(n²) アルゴリズム
**場所**: utils/search.py:23
**影響**: 10,000件で100,000,000回の比較
**実行時間**: 45秒 → 0.5秒(98%改善可能)
## 最適化提案
1. **データベースクエリ**: Eager loading使用
2. **アルゴリズム**: ハッシュテーブル活用
3. **キャッシング**: Redis導入
4. **非同期処理**: Promise.all で並列化
ベストプラクティス
- 計測: プロファイリングツール使用
- ボトルネック特定: 最も影響の大きい部分から最適化
- トレードオフ: 可読性とのバランス
- 継続的監視: APM ツール導入
バージョン情報
- スキルバージョン: 1.0.0
- 最終更新: 2025-01-22
Related Skills
Mermaid Diagrams
Comprehensive guide for creating software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams (domain modeling, object-oriented design), sequence diagrams (application flows, API interactions, code execution), flowcharts (processes, algorithms, user journeys), entity relationship diagrams (database schemas), C4 architecture diagrams (system context, containers, components), state diagrams, git graphs, pie charts,
Matlab
MATLAB and GNU Octave numerical computing for matrix operations, data analysis, visualization, and scientific computing. Use when writing MATLAB/Octave scripts for linear algebra, signal processing, image processing, differential equations, optimization, statistics, or creating scientific visualizations. Also use when the user needs help with MATLAB syntax, functions, or wants to convert between MATLAB and Python code. Scripts can be executed with MATLAB or the open-source GNU Octave interpreter
Dask
Distributed computing for larger-than-RAM pandas/NumPy workflows. Use when you need to scale existing pandas/NumPy code beyond memory or across clusters. Best for parallel file processing, distributed ML, integration with existing pandas code. For out-of-core analytics on single machine use vaex; for in-memory speed use polars.
Consult Zai
Compare z.ai GLM 4.7 and code-searcher responses for comprehensive dual-AI code analysis. Use when you need multiple AI perspectives on code questions.
Writing Effective Prompts
Structure Claude prompts for clarity and better results using roles, explicit instructions, context, positive framing, and strategic organization. Use when crafting prompts for complex tasks, long documents, tool workflows, or code generation.
Analyze Performance
Establish performance baselines and detect regressions using flamegraph analysis. Use when optimizing performance-critical code, investigating performance issues, or before creating commits with performance-sensitive changes.
Flowchart Creator
Create HTML flowcharts and process diagrams with decision trees, color-coded stages, arrows, and swimlanes. Use when users request flowcharts, process diagrams, workflow visualizations, or decision trees.
Bio Reporting Rmarkdown Reports
Create reproducible bioinformatics analysis reports with R Markdown including code, results, and visualizations in HTML, PDF, or Word format. Use when generating analysis reports with RMarkdown.
Desmos Graphing
Create interactive Desmos graphs in Obsidian using desmos-graph code blocks. Use when visualizing functions, parametric curves, inequalities, or mathematical relationships with customizable styling and settings.
Performance
Rendimiento & Optimización - Atoll Tourisme. Use when optimizing performance or profiling code.
