performance-engineer by charon-fan/agent-playbook
npx skills add https://github.com/charon-fan/agent-playbook --skill performance-engineer专注于分析和优化应用程序性能、识别瓶颈并实施效率改进的专家。
当您遇到以下情况时触发:
定义指标
测量当前性能
# 响应时间
curl -w "@curl-format.txt" -o /dev/null -s https://example.com/users
# 数据库查询时间
# 在查询中添加计时日志
# 内存使用情况
# 使用性能分析器
分析应用程序性能
# Node.js
node --prof app.js
# Python
python -m cProfile app.py
# Go
go test -cpuprofile=cpu.prof
常见的瓶颈位置:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 层级 | 常见问题 |
|---|
| 数据库 | N+1 查询、缺少索引、结果集过大 |
| API | 过度获取数据、无缓存、串行请求 |
| 应用程序 | 低效算法、过多日志记录 |
| 前端 | 打包文件过大、重复渲染、未使用懒加载 |
| 网络 | 请求过多、负载过大、未启用压缩 |
N+1 查询:
// 错误示例:N+1 查询
const users = await User.findAll();
for (const user of users) {
user.posts = await Post.findAll({ where: { userId: user.id } });
}
// 正确示例:预加载
const users = await User.findAll({
include: [{ model: Post, as: 'posts' }]
});
缺少索引:
-- 在频繁查询的列上添加索引
CREATE INDEX idx_user_email ON users(email);
CREATE INDEX idx_post_user_id ON posts(user_id);
分页:
// 始终对大型结果集进行分页
const users = await User.findAll({
limit: 100,
offset: page * 100
});
字段选择:
// 仅选择需要的字段
const users = await User.findAll({
attributes: ['id', 'name', 'email']
});
压缩:
// 启用 gzip 压缩
app.use(compression());
代码分割:
// 懒加载路由
const Dashboard = lazy(() => import('./Dashboard'));
记忆化:
// 对昂贵的计算使用 useMemo
const filtered = useMemo(() =>
items.filter(item => item.active),
[items]
);
图片优化:
| 指标 | 目标 | 临界阈值 |
|---|---|---|
| API 响应时间 (p50) | < 100ms | < 500ms |
| API 响应时间 (p95) | < 500ms | < 1s |
| API 响应时间 (p99) | < 1s | < 2s |
| 数据库查询时间 | < 50ms | < 200ms |
| 页面加载 (FMP) | < 2s | < 3s |
| 可交互时间 | < 3s | < 5s |
| 内存使用量 | < 512MB | < 1GB |
// 缓存昂贵的计算
const cache = new Map();
async function getUserStats(userId: string) {
if (cache.has(userId)) {
return cache.get(userId);
}
const stats = await calculateUserStats(userId);
cache.set(userId, stats);
// 5分钟后失效
setTimeout(() => cache.delete(userId), 5 * 60 * 1000);
return stats;
}
// 错误示例:单个请求
for (const id of userIds) {
await fetchUser(id);
}
// 正确示例:批量请求
await fetchUsers(userIds);
// 防抖搜索输入
const debouncedSearch = debounce(search, 300);
// 节流滚动事件
const throttledScroll = throttle(handleScroll, 100);
| 工具 | 用途 |
|---|---|
| Lighthouse | 前端性能 |
| New Relic | APM 监控 |
| Datadog | 基础设施监控 |
| Prometheus | 指标收集 |
性能分析应用程序:
python scripts/profile.py
生成性能报告:
python scripts/perf_report.py
references/optimization.md - 优化技术references/monitoring.md - 监控设置references/checklist.md - 性能检查清单每周安装次数
43
代码仓库
GitHub Stars
11
首次出现
2026年1月22日
安全审计
安装于
codex37
gemini-cli37
opencode37
cursor36
github-copilot33
amp33
Specialist in analyzing and optimizing application performance, identifying bottlenecks, and implementing efficiency improvements.
Activates when you:
Define metrics
Measure current performance
# Response time
curl -w "@curl-format.txt" -o /dev/null -s https://example.com/users
# Database query time
# Add timing logs to queries
# Memory usage
# Use profiler
Profile the application
# Node.js
node --prof app.js
# Python
python -m cProfile app.py
# Go
go test -cpuprofile=cpu.prof
Common bottleneck locations:
| Layer | Common Issues |
|---|---|
| Database | N+1 queries, missing indexes, large result sets |
| API | Over-fetching, no caching, serial requests |
| Application | Inefficient algorithms, excessive logging |
| Frontend | Large bundles, re-renders, no lazy loading |
| Network | Too many requests, large payloads, no compression |
N+1 Queries:
// Bad: N+1 queries
const users = await User.findAll();
for (const user of users) {
user.posts = await Post.findAll({ where: { userId: user.id } });
}
// Good: Eager loading
const users = await User.findAll({
include: [{ model: Post, as: 'posts' }]
});
Missing Indexes:
-- Add index on frequently queried columns
CREATE INDEX idx_user_email ON users(email);
CREATE INDEX idx_post_user_id ON posts(user_id);
Pagination:
// Always paginate large result sets
const users = await User.findAll({
limit: 100,
offset: page * 100
});
Field Selection:
// Select only needed fields
const users = await User.findAll({
attributes: ['id', 'name', 'email']
});
Compression:
// Enable gzip compression
app.use(compression());
Code Splitting:
// Lazy load routes
const Dashboard = lazy(() => import('./Dashboard'));
Memoization:
// Use useMemo for expensive calculations
const filtered = useMemo(() =>
items.filter(item => item.active),
[items]
);
Image Optimization:
| Metric | Target | Critical Threshold |
|---|---|---|
| API Response (p50) | < 100ms | < 500ms |
| API Response (p95) | < 500ms | < 1s |
| API Response (p99) | < 1s | < 2s |
| Database Query | < 50ms | < 200ms |
| Page Load (FMP) | < 2s | < 3s |
| Time to Interactive | < 3s | < 5s |
| Memory Usage | < 512MB | < 1GB |
// Cache expensive computations
const cache = new Map();
async function getUserStats(userId: string) {
if (cache.has(userId)) {
return cache.get(userId);
}
const stats = await calculateUserStats(userId);
cache.set(userId, stats);
// Invalidate after 5 minutes
setTimeout(() => cache.delete(userId), 5 * 60 * 1000);
return stats;
}
// Bad: Individual requests
for (const id of userIds) {
await fetchUser(id);
}
// Good: Batch request
await fetchUsers(userIds);
// Debounce search input
const debouncedSearch = debounce(search, 300);
// Throttle scroll events
const throttledScroll = throttle(handleScroll, 100);
| Tool | Purpose |
|---|---|
| Lighthouse | Frontend performance |
| New Relic | APM monitoring |
| Datadog | Infrastructure monitoring |
| Prometheus | Metrics collection |
Profile application:
python scripts/profile.py
Generate performance report:
python scripts/perf_report.py
references/optimization.md - Optimization techniquesreferences/monitoring.md - Monitoring setupreferences/checklist.md - Performance checklistWeekly Installs
43
Repository
GitHub Stars
11
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
codex37
gemini-cli37
opencode37
cursor36
github-copilot33
amp33
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
116,600 周安装