name: performance-profiler description: 分析应用程序性能,包括CPU、内存和火焰图生成 allowed-tools:
- Bash
- Read
- Write
- Glob
性能分析器技能
概述
分析应用程序性能,包括CPU分析、内存分析、火焰图生成、瓶颈识别和APM工具集成。
能力
- CPU分析
- 内存分析和堆快照
- 火焰图生成
- 瓶颈识别
- 热点路径分析
- 与APM工具集成(DataDog、New Relic)
- 事件循环分析(Node.js)
- 垃圾回收分析
目标流程
- 性能优化
输入模式
{
"type": "object",
"required": ["target"],
"properties": {
"target": {
"type": "string",
"description": "目标进程、脚本或端点"
},
"mode": {
"type": "string",
"enum": ["cpu", "memory", "heap", "all"],
"default": "cpu"
},
"duration": {
"type": "number",
"default": 30,
"description": "分析持续时间(秒)"
},
"options": {
"type": "object",
"properties": {
"samplingInterval": {
"type": "number",
"default": 1000,
"description": "采样间隔(微秒)"
},
"generateFlameGraph": {
"type": "boolean",
"default": true
},
"outputFormat": {
"type": "string",
"enum": ["json", "html", "svg"],
"default": "html"
}
}
}
}
}
输出模式
{
"type": "object",
"properties": {
"profile": {
"type": "object",
"properties": {
"duration": { "type": "number" },
"samples": { "type": "number" }
}
},
"hotspots": {
"type": "array",
"items": {
"type": "object",
"properties": {
"function": { "type": "string" },
"selfTime": { "type": "number" },
"totalTime": { "type": "number" },
"percentage": { "type": "number" }
}
}
},
"flameGraphPath": {
"type": "string"
},
"memoryStats": {
"type": "object",
"properties": {
"heapUsed": { "type": "number" },
"heapTotal": { "type": "number" },
"external": { "type": "number" }
}
},
"recommendations": {
"type": "array",
"items": { "type": "string" }
}
}
}
使用示例
{
kind: 'skill',
skill: {
name: 'performance-profiler',
context: {
target: 'npm run start',
mode: 'cpu',
duration: 30,
options: {
generateFlameGraph: true,
outputFormat: 'html'
}
}
}
}