ワンクリックで
performance-profile
Analyze code for performance hotspots including complexity, N+1 queries, memory allocations, and caching opportunities
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Analyze code for performance hotspots including complexity, N+1 queries, memory allocations, and caching opportunities
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Create Architecture Decision Records using the Michael Nygard template with context, decision, alternatives, and consequences
Generate or validate OpenAPI and AsyncAPI specs from code or requirements with consistent naming, errors, and pagination
Generate CHANGELOG.md from git history in Keep a Changelog format with Added, Changed, Deprecated, Removed, Fixed, and Security categories
Generate CI/CD pipeline config for detected platform with lint, test, build, and deploy stages
Scan dependencies for CVEs, outdated packages, license issues, and unused deps to produce a prioritized remediation list
Guide deployment processes including CI/CD pipeline creation, environment setup, and rollback procedures
| name | performance-profile |
| description | Analyze code for performance hotspots including complexity, N+1 queries, memory allocations, and caching opportunities |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"developers","workflow":"general"} |
Use this skill when you need to:
Identify the scope: Determine what to profile
Analyze algorithmic complexity: Check for inefficient patterns
Detect N+1 queries: Scan database access patterns
Check memory patterns: Look for allocation hotspots
Evaluate caching: Identify caching opportunities
Produce optimization plan: Prioritize by impact and effort
# BAD: N+1 queries
users = db.query("SELECT * FROM users")
for user in users:
orders = db.query(f"SELECT * FROM orders WHERE user_id = {user.id}")
# GOOD: Single query with JOIN or batch
users_with_orders = db.query("""
SELECT u.*, o.*
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
""")
// BAD: O(n * m) lookup
for (const order of orders) {
const user = users.find(u => u.id === order.userId); // O(n) each time
}
// GOOD: O(n + m) with hash map
const userMap = new Map(users.map(u => [u.id, u]));
for (const order of orders) {
const user = userMap.get(order.userId); // O(1) each time
}
// BAD: Loading entire result set into memory
List<Record> allRecords = repository.findAll(); // millions of rows
// GOOD: Stream or paginate
try (Stream<Record> stream = repository.streamAll()) {
stream.forEach(record -> process(record));
}
// BAD: Recomputing expensive result
function getReport(params: Params) {
return expensiveComputation(params); // called repeatedly with same params
}
// GOOD: Cache the result
const cache = new Map<string, Report>();
function getReport(params: Params) {
const key = JSON.stringify(params);
if (!cache.has(key)) {
cache.set(key, expensiveComputation(params));
}
return cache.get(key);
}
## Performance Optimization Plan
### Summary
- **Scope:** Order processing pipeline
- **Current p95 latency:** 2.4s
- **Target p95 latency:** 500ms
### Findings (Priority Order)
| # | Issue | Impact | Effort | Location |
|---|-------|--------|--------|----------|
| 1 | N+1 query in order loader | High | Low | `src/orders/loader.ts:34` |
| 2 | Quadratic user lookup | High | Low | `src/orders/enrich.ts:67` |
| 3 | No caching on product catalog | Medium | Medium | `src/products/service.ts:12` |
| 4 | Large JSON serialization in loop | Low | Low | `src/orders/export.ts:89` |
### Detailed Recommendations
#### 1. N+1 query in order loader (High Impact, Low Effort)
**Current:** 1 query per order to fetch items (100 orders = 101 queries)
**Fix:** Use batch query with `WHERE order_id IN (...)`
**Expected improvement:** ~80% latency reduction for this path
| Level | Criteria |
|---|---|
| Critical | Causes timeouts, OOM, or system instability under normal load |
| High | Noticeable latency (>1s) on common user operations |
| Medium | Suboptimal but functional; affects throughput under high load |
| Low | Minor inefficiency; optimize if effort is minimal |