Performance profiler
Skill bg-szy/TOP-SKILLS/skills/marketplace/performance-profiler
全球最大的 Claude Code 技能聚合库 · 收录 3900+ 来自 12+ 来源的技能,提供在线搜索与趋势分析看板 / The world's largest Claude Code skill aggregation hub — 3900+ skills from 12+ sources with online search and trend dashboard
npx -y skills add bg-szy/TOP-SKILLS --skill performance-profilerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Identifies performance bottlenecks including N+1 queries, inefficient loops, memory leaks, and slow algorithms. Use when user mentions performance issues, slow code, optimization, or profiling.
SKILL.md
4.1 KB, as published. Nobody here has run it
Performance Profiler
Identifies and suggests fixes for common performance bottlenecks in code.
When to Use
- User reports performance issues or slow code
- Optimization requests
- Code review for performance
- User mentions "slow", "bottleneck", "optimization", "memory leak"
Instructions
1. Identify Performance Anti-Patterns
N+1 Query Problems:
// Bad: N+1 queries
users.forEach(user => {
const posts = db.query('SELECT * FROM posts WHERE user_id = ?', user.id);
});
// Good: Single query with JOIN
const usersWithPosts = db.query('SELECT * FROM users LEFT JOIN posts ON users.id = posts.user_id');
Inefficient Loops:
# Bad: O(n²) nested loops
for item in list1:
for other in list2:
if item.id == other.id:
process(item, other)
# Good: O(n) with hash map
lookup = {other.id: other for other in list2}
for item in list1:
if item.id in lookup:
process(item, lookup[item.id])
Unnecessary Re-renders (React):
// Bad: Creates new object on every render
<Component style={{ margin: 10 }} />
// Good: Define outside or useMemo
const style = { margin: 10 };
<Component style={style} />
Memory Leaks:
- Event listeners not cleaned up
- Timers not cleared
- Circular references
- Large caches without limits
Blocking Operations:
- Synchronous file I/O
- Long-running calculations in UI thread
- Missing pagination
2. Database Performance
Check for:
- Missing indexes on foreign keys
- SELECT * instead of specific columns
- Queries in loops (N+1)
- Missing query limits
- Inefficient JOINs
Suggest:
- Add indexes:
CREATE INDEX idx_user_id ON posts(user_id); - Use eager loading/prefetching
- Implement pagination
- Use database query analyzers (EXPLAIN)
3. Algorithm Complexity
Identify:
- O(n²) or worse algorithms
- Redundant calculations
- Unnecessary sorting
- Inefficient data structures
Common fixes:
- Hash maps for O(1) lookup vs O(n) array search
- Binary search O(log n) vs linear search O(n)
- Memoization for repeated calculations
- Lazy evaluation for expensive operations
4. Frontend Performance
Check for:
- Large bundle sizes
- Unoptimized images
- Missing code splitting
- Inefficient React components
- Missing memoization
Suggest:
- Lazy loading:
const Component = lazy(() => import('./Component')); - Image optimization
- Debounce/throttle expensive operations
- Virtual scrolling for long lists
- Web Workers for heavy computations
5. Network Performance
Issues:
- Too many HTTP requests
- Large payloads
- Missing caching
- Synchronous requests
Solutions:
- Bundle/concatenate resources
- Implement compression (gzip, brotli)
- Use HTTP/2 multiplexing
- Add caching headers
- Parallel vs sequential requests
6. Generate Performance Report
Performance Analysis
===================
Critical Issues (Fix Immediately):
1. N+1 query in UserController.index (file.js:45)
- Impact: 100+ DB queries per request
- Fix: Use eager loading or JOIN
2. Memory leak in EventEmitter (file.js:120)
- Impact: Memory grows unbounded
- Fix: Remove listeners in cleanup
High Priority:
3. O(n²) loop in processData (file.js:200)
- Impact: Slow for large datasets
- Fix: Use hash map for O(n)
Medium Priority:
4. Missing image optimization
- Impact: Slow page load
- Fix: Use next/image or optimize manually
7. Profiling Tools
JavaScript:
- Chrome DevTools Performance tab
- Node.js --inspect flag
console.time()/console.timeEnd()
Python:
- cProfile module
- line_profiler
- memory_profiler
Database:
- EXPLAIN / EXPLAIN ANALYZE
- Slow query log
- pg_stat_statements (PostgreSQL)
Best Practices
- Profile before optimizing
- Focus on hot paths (80/20 rule)
- Measure impact of changes
- Consider readability vs performance trade-offs
- Document performance-critical sections