Performance profiler
Skill bg-szy/TOP-SKILLS/skills/claude-skills/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
Profile and optimize application performance including load times, memory usage, and rendering. Use when debugging slow performance, memory leaks, or optimizing app speed.
SKILL.md
4.0 KB, as published. Nobody here has run it
Performance Profiler
Instructions
When profiling performance:
- Identify the bottleneck type: Network, rendering, memory, or compute
- Measure baseline before optimizing
- Profile with appropriate tools
- Apply optimizations
- Measure improvement
Web Performance
Core Web Vitals
# Lighthouse CLI
npx lighthouse https://yoursite.com --view
# With specific metrics
npx lighthouse https://yoursite.com --only-categories=performance
Target Metrics:
| Metric | Good | Needs Work | Poor |
|---|---|---|---|
| LCP (Largest Contentful Paint) | < 2.5s | 2.5-4s | > 4s |
| INP (Interaction to Next Paint) | < 200ms | 200-500ms | > 500ms |
| CLS (Cumulative Layout Shift) | < 0.1 | 0.1-0.25 | > 0.25 |
Bundle Analysis
# Next.js
ANALYZE=true npm run build
# Webpack
npx webpack-bundle-analyzer stats.json
# Vite
npx vite-bundle-visualizer
React Performance
React DevTools Profiler
- Install React DevTools browser extension
- Open DevTools → Profiler tab
- Click Record, interact with app, stop recording
- Analyze flame graph for slow components
Common React Optimizations
// 1. Memoize expensive components
const MemoizedList = React.memo(function List({ items }) {
return items.map(item => <Item key={item.id} {...item} />);
});
// 2. Use useMemo for expensive calculations
const sortedItems = useMemo(() => {
return [...items].sort((a, b) => a.name.localeCompare(b.name));
}, [items]);
// 3. Use useCallback for stable function references
const handleClick = useCallback((id: string) => {
setSelected(id);
}, []);
// 4. Virtualize long lists
import { FixedSizeList } from 'react-window';
function VirtualList({ items }) {
return (
<FixedSizeList
height={400}
itemCount={items.length}
itemSize={50}
width="100%"
>
{({ index, style }) => (
<div style={style}>{items[index].name}</div>
)}
</FixedSizeList>
);
}
// 5. Lazy load components
const HeavyComponent = React.lazy(() => import('./HeavyComponent'));
function App() {
return (
<Suspense fallback={<Loading />}>
<HeavyComponent />
</Suspense>
);
}
Node.js Performance
Profiling
# CPU profile
node --prof app.js
node --prof-process isolate-*.log > profile.txt
# Heap snapshot
node --inspect app.js
# Then use Chrome DevTools Memory tab
# Clinic.js (comprehensive)
npx clinic doctor -- node app.js
npx clinic flame -- node app.js
npx clinic bubbleprof -- node app.js
Memory Leak Detection
// Add to app for debugging
const used = process.memoryUsage();
console.log({
heapUsed: `${Math.round(used.heapUsed / 1024 / 1024)} MB`,
heapTotal: `${Math.round(used.heapTotal / 1024 / 1024)} MB`,
external: `${Math.round(used.external / 1024 / 1024)} MB`,
});
Database Performance
-- PostgreSQL: Analyze slow queries
EXPLAIN ANALYZE SELECT * FROM users WHERE email = '[email protected]';
-- Find missing indexes
SELECT relname, seq_scan, idx_scan
FROM pg_stat_user_tables
WHERE seq_scan > idx_scan;
Query Optimization
// Bad: N+1 query
const users = await db.user.findMany();
for (const user of users) {
const posts = await db.post.findMany({ where: { userId: user.id } });
}
// Good: Single query with include
const users = await db.user.findMany({
include: { posts: true }
});
// Good: Select only needed fields
const users = await db.user.findMany({
select: { id: true, name: true, email: true }
});
Quick Wins Checklist
- Enable gzip/brotli compression
- Add caching headers
- Lazy load images (
loading="lazy") - Preconnect to external domains
- Use CDN for static assets
- Minimize JavaScript bundle
- Defer non-critical JS
- Optimize images (WebP, proper sizing)
- Add database indexes
- Use connection pooling