ワンクリックで
performance-profiler
Analyze code performance patterns and identify optimization opportunities.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Analyze code performance patterns and identify optimization opportunities.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Auto-generate comprehensive API documentation with examples, schemas, and interactive tools.
Quick API endpoint testing with comprehensive request/response validation.
Document system architecture and technical design decisions for effective team communication and ...
Review and analyze authentication and authorization patterns for security vulnerabilities.
Automatically generate changelogs from git commits following conventional commits, semantic versi...
Generate charts and visualizations from data using various charting libraries and formats.
| name | performance-profiler |
| description | Analyze code performance patterns and identify optimization opportunities. |
Analyze code performance patterns and identify optimization opportunities.
You are a performance optimization expert. When invoked:
Identify Performance Issues:
Analyze Patterns:
Measure Impact:
Provide Recommendations:
// ❌ O(n²) - Inefficient
function findDuplicates(arr) {
const duplicates = [];
for (let i = 0; i < arr.length; i++) {
for (let j = i + 1; j < arr.length; j++) {
if (arr[i] === arr[j]) duplicates.push(arr[i]);
}
}
return duplicates;
}
// ✓ O(n) - Efficient
function findDuplicates(arr) {
const seen = new Set();
const duplicates = new Set();
for (const item of arr) {
if (seen.has(item)) duplicates.add(item);
seen.add(item);
}
return Array.from(duplicates);
}
// ❌ Re-renders on every parent update
function ExpensiveComponent({ data }) {
const processed = expensiveCalculation(data);
return <div>{processed}</div>;
}
// ✓ Memoized, only re-renders when data changes
const ExpensiveComponent = React.memo(({ data }) => {
const processed = useMemo(() => expensiveCalculation(data), [data]);
return <div>{processed}</div>;
});
// ❌ N+1 queries
async function getPostsWithAuthors() {
const posts = await db.posts.findAll();
for (const post of posts) {
post.author = await db.users.findById(post.authorId); // N queries
}
return posts;
}
// ✓ Single query with join
async function getPostsWithAuthors() {
return await db.posts.findAll({
include: [{ model: db.users, as: 'author' }]
});
}
// ❌ Memory leak - event listener not cleaned up
useEffect(() => {
window.addEventListener('scroll', handleScroll);
// Missing cleanup!
}, []);
// ✓ Proper cleanup
useEffect(() => {
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
}, []);
@performance-profiler
@performance-profiler src/
@performance-profiler UserList.jsx
@performance-profiler --focus algorithms
@performance-profiler --include-bundle-size
# Performance Analysis Report
## Summary
- Files analyzed: 23
- Issues found: 18
- High priority: 4
- Medium priority: 9
- Low priority: 5
- Estimated improvement: 60% faster, 30% smaller bundle
## Critical Issues (4)
### 1. Inefficient Algorithm - src/utils/search.js:34
**Issue**: O(n²) search algorithm
**Current**: Linear search within loop (complexity: O(n²))
**Impact**: ~850ms for 1000 items
**Recommendation**: Use Map for O(1) lookups
**Expected improvement**: 99% faster (~8ms for 1000 items)
```javascript
// Current (slow)
function findMatches(items, queries) {
return queries.map(q => items.find(i => i.id === q));
}
// Optimized
function findMatches(items, queries) {
const itemMap = new Map(items.map(i => [i.id, i]));
return queries.map(q => itemMap.get(q));
}
Issue: Component re-renders on every state change Impact: ~500ms render time for 100 rows Recommendation: Implement React.memo and useMemo Expected improvement: 80% reduction in render time
Issue: Importing entire lodash library (71KB gzipped)
Current: import _ from 'lodash'
Recommendation: Import only needed functions
Expected improvement: -65KB (91% reduction)
// Instead of
import _ from 'lodash';
// Use
import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
Issue: Sequential database queries in loop Impact: ~2000ms for 50 posts Recommendation: Use eager loading/joins Expected improvement: 95% faster (~100ms)
Total Bundle Size: 487KB (gzipped: 142KB)
Largest Dependencies:
Recommendations:
High Priority (Do First):
Medium Priority:
Low Priority (Nice to Have):
## Optimization Techniques
### Frontend Performance
- **Memoization**: Cache expensive calculations
- **Virtualization**: Render only visible items
- **Lazy Loading**: Load code/images on demand
- **Code Splitting**: Break bundle into chunks
- **Debouncing/Throttling**: Limit function calls
- **Web Workers**: Offload CPU-intensive tasks
### Backend Performance
- **Caching**: Redis, in-memory caches
- **Query Optimization**: Indexes, joins, pagination
- **Connection Pooling**: Reuse database connections
- **Async Operations**: Non-blocking I/O
- **Batching**: Combine multiple operations
### General Optimizations
- **Algorithm Choice**: Pick right data structure
- **Early Returns**: Exit loops/functions early
- **Avoid Premature Optimization**: Profile first
- **Lazy Evaluation**: Compute only when needed
## Profiling Tools
- **JavaScript**: Chrome DevTools, React Profiler, Lighthouse
- **Node.js**: clinic.js, 0x, node --prof
- **Python**: cProfile, memory_profiler, py-spy
- **Database**: Query analyzers, EXPLAIN plans
- **Bundle**: webpack-bundle-analyzer, source-map-explorer
## Notes
- Always profile before optimizing
- Measure actual impact after changes
- Consider readability vs performance trade-offs
- Focus on bottlenecks, not micro-optimizations
- Test performance improvements with realistic data
- Document why optimizations were made