Analyze code for performance characteristics and bottlenecks.
Analyzes code for performance characteristics and bottlenecks across CPU, memory, and I/O.
/plugin marketplace add marcel-Ngan/ai-dev-team/plugin install marcel-ngan-ai-dev-team@marcel-Ngan/ai-dev-teamAnalyze code for performance characteristics and bottlenecks.
/profile [target] [--type cpu|memory|io|all]
Arguments:
target - File, function, or module to profile--type - Profiling focus (default: all)/profile src/services/dataProcessor.ts
/profile handleRequest --type cpu
/profile src/api/ --type memory
## Performance Profile: dataProcessor.ts
### Summary
| Metric | Assessment |
|--------|------------|
| CPU Efficiency | Medium |
| Memory Usage | High Risk |
| I/O Pattern | Suboptimal |
| Overall | Needs Optimization |
### Hotspots Identified
#### 1. processLargeDataset() - Line 45
**Issue:** O(n²) complexity due to nested loops
**Impact:** High - scales poorly with data size
**Current:**
```typescript
items.forEach(item => {
const match = allItems.find(i => i.id === item.refId);
});
Optimized:
const itemMap = new Map(allItems.map(i => [i.id, i]));
items.forEach(item => {
const match = itemMap.get(item.refId);
});
Improvement: O(n²) → O(n)
Issue: Event listener not cleaned up Impact: Medium - memory grows over time
| Operation | Current | Target |
|---|---|---|
| Process 1K items | 450ms | <100ms |
| Memory peak | 256MB | <64MB |
## Skill Used
`performance-profiling`
## When to Use Agent Instead
Use the **Software Architect** agent when:
- System-wide performance review needed
- Architecture changes may be required
- Capacity planning involved