Loading...
Loading...
Compare original and translation side by side
npx claude-flow bottleneck detectnpx claude-flow bottleneck detectnpx claude-flow analysis performance-report --format html --include-metricsnpx claude-flow analysis performance-report --format html --include-metricsnpx claude-flow bottleneck detect --fix --threshold 15npx claude-flow bottleneck detect --fix --threshold 15npx claude-flow bottleneck detect [options]npx claude-flow bottleneck detect [options]--swarm-id, -s <id>--time-range, -t <range>--threshold <percent>--export, -e <file>--fix--swarm-id, -s <id>--time-range, -t <range>--threshold <percent>--export, -e <file>--fixundefinedundefinedundefinedundefined🔍 Bottleneck Analysis Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Summary
├── Time Range: Last 1 hour
├── Agents Analyzed: 6
├── Tasks Processed: 42
└── Critical Issues: 2
🚨 Critical Bottlenecks
1. Agent Communication (35% impact)
└── coordinator → coder-1 messages delayed by 2.3s avg
2. Memory Access (28% impact)
└── Neural pattern loading taking 1.8s per access
⚠️ Warning Bottlenecks
1. Task Queue (18% impact)
└── 5 tasks waiting > 10s for assignment
💡 Recommendations
1. Switch to hierarchical topology (est. 40% improvement)
2. Enable memory caching (est. 25% improvement)
3. Increase agent concurrency to 8 (est. 20% improvement)
✅ Quick Fixes Available
Run with --fix to apply:
- Enable smart caching
- Optimize message routing
- Adjust agent priorities🔍 瓶颈分析报告
━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 摘要
├── 时间范围:过去1小时
├── 分析Agent数量:6
├── 处理任务数量:42
└── 关键问题:2
🚨 严重瓶颈
1. Agent通信(影响占比35%)
└── coordinator → coder-1消息平均延迟2.3秒
2. 内存访问(影响占比28%)
└── 神经模式加载每次访问耗时1.8秒
⚠️ 警告瓶颈
1. 任务队列(影响占比18%)
└── 5个任务等待分配超过10秒
💡 优化建议
1. 切换至分层拓扑结构(预计提升40%)
2. 启用内存缓存(预计提升25%)
3. 将Agent并发数增加至8(预计提升20%)
✅ 可用快速修复
添加--fix参数运行以应用:
- 启用智能缓存
- 优化消息路由
- 调整Agent优先级// Check for bottlenecks in Claude Code
mcp__claude-flow__bottleneck_detect({
timeRange: "1h",
threshold: 20,
autoFix: false
})
// Get detailed task results with bottleneck analysis
mcp__claude-flow__task_results({
taskId: "task-123",
format: "detailed"
}){
"bottlenecks": [
{
"type": "coordination",
"severity": "high",
"description": "Single agent used for complex task",
"recommendation": "Spawn specialized agents for parallel work",
"impact": "35%",
"affectedComponents": ["coordinator", "coder-1"]
}
],
"improvements": [
{
"area": "execution_time",
"suggestion": "Use parallel task execution",
"expectedImprovement": "30-50% time reduction",
"implementationSteps": [
"Split task into smaller units",
"Spawn 3-4 specialized agents",
"Use mesh topology for coordination"
]
}
],
"metrics": {
"avgExecutionTime": "142s",
"agentUtilization": "67%",
"cacheHitRate": "82%",
"parallelizationFactor": 1.2
}
}// 在Claude Code中检查瓶颈
mcp__claude-flow__bottleneck_detect({
timeRange: "1h",
threshold: 20,
autoFix: false
})
// 获取包含瓶颈分析的详细任务结果
mcp__claude-flow__task_results({
taskId: "task-123",
format: "detailed"
}){
"bottlenecks": [
{
"type": "coordination",
"severity": "high",
"description": "Single agent used for complex task",
"recommendation": "Spawn specialized agents for parallel work",
"impact": "35%",
"affectedComponents": ["coordinator", "coder-1"]
}
],
"improvements": [
{
"area": "execution_time",
"suggestion": "Use parallel task execution",
"expectedImprovement": "30-50% time reduction",
"implementationSteps": [
"Split task into smaller units",
"Spawn 3-4 specialized agents",
"Use mesh topology for coordination"
]
}
],
"metrics": {
"avgExecutionTime": "142s",
"agentUtilization": "67%",
"cacheHitRate": "82%",
"parallelizationFactor": 1.2
}
}npx claude-flow analysis performance-report [options]npx claude-flow analysis performance-report [options]--format <type>--include-metrics--compare <id>--time-range <range>--output <file>--sections <list>--format <type>--include-metrics--compare <id>--time-range <range>--output <file>--sections <list>undefinedundefinedundefinedundefinedundefinedundefined| Metric | Value | Trend | Target |
|---|---|---|---|
| Avg Task Time | 42s | ↓ 12% | 35s |
| Agent Utilization | 78% | ↑ 5% | 85% |
| Cache Hit Rate | 91% | → | 90% |
| Parallel Efficiency | 2.3x | ↑ 0.4x | 2.5x |
| 指标 | 数值 | 趋势 | 目标 |
|---|---|---|---|
| 平均任务时间 | 42s | ↓ 12% | 35s |
| Agent利用率 | 78% | ↑ 5% | 85% |
| 缓存命中率 | 91% | → | 90% |
| 并行效率 | 2.3x | ↑ 0.4x | 2.5x |
undefinedundefined--fix--fixundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined// scripts$analyze-performance.js
const { exec } = require('child_process');
const fs = require('fs');
async function analyzePerformance() {
// Run bottleneck detection
const bottlenecks = await runCommand(
'npx claude-flow bottleneck detect --format json'
);
// Generate performance report
const report = await runCommand(
'npx claude-flow analysis performance-report --format json'
);
// Analyze results
const analysis = {
bottlenecks: JSON.parse(bottlenecks),
performance: JSON.parse(report),
timestamp: new Date().toISOString()
};
// Save combined analysis
fs.writeFileSync(
'analysis$combined-report.json',
JSON.stringify(analysis, null, 2)
);
// Generate alerts if needed
if (analysis.bottlenecks.critical.length > 0) {
console.error('CRITICAL: Performance bottlenecks detected!');
process.exit(1);
}
}
function runCommand(cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
if (error) reject(error);
else resolve(stdout);
});
});
}
analyzePerformance().catch(console.error);// scripts/analyze-performance.js
const { exec } = require('child_process');
const fs = require('fs');
async function analyzePerformance() {
// 运行瓶颈检测
const bottlenecks = await runCommand(
'npx claude-flow bottleneck detect --format json'
);
// 生成性能报告
const report = await runCommand(
'npx claude-flow analysis performance-report --format json'
);
// 分析结果
const analysis = {
bottlenecks: JSON.parse(bottlenecks),
performance: JSON.parse(report),
timestamp: new Date().toISOString()
};
// 保存合并分析结果
fs.writeFileSync(
'analysis/combined-report.json',
JSON.stringify(analysis, null, 2)
);
// 必要时生成告警
if (analysis.bottlenecks.critical.length > 0) {
console.error('CRITICAL: 检测到性能瓶颈!');
process.exit(1);
}
}
function runCommand(cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
if (error) reject(error);
else resolve(stdout);
});
});
}
analyzePerformance().catch(console.error);undefinedundefined
**Slow Task Execution**
```bash
**任务执行缓慢**
```bash
**Poor Cache Performance**
```bash
**缓存性能不佳**
```bashundefinedundefinednpx claude-flow swarm monitornpx claude-flow token usagenpx claude-flow cache managenpx claude-flow agent metricsnpx claude-flow task statusnpx claude-flow swarm monitornpx claude-flow token usagenpx claude-flow cache managenpx claude-flow agent metricsnpx claude-flow task status