name: startup-time-profiler description: 分析和优化桌面应用程序的启动时间 allowed-tools: Read, Write, Edit, Bash, Glob, Grep tags: [性能, 性能分析, 启动, 优化, 桌面]
启动时间分析器
分析和优化应用程序的启动时间,识别初始化、模块加载和渲染过程中的瓶颈。
功能
- 测量冷启动和热启动时间
- 识别模块加载瓶颈
- 分析初始化阶段
- 生成时间线可视化图表
- 提供优化建议
- 设置CI性能跟踪
输入模式
{
"type": "object",
"properties": {
"projectPath": { "type": "string" },
"framework": { "enum": ["electron", "tauri", "native"] },
"iterations": { "type": "number", "default": 5 }
},
"required": ["projectPath"]
}
Electron启动性能分析
// 添加到 main.js
const startTime = Date.now();
app.on('ready', () => {
console.log(`应用准备就绪: ${Date.now() - startTime}ms`);
});
// 启用追踪
app.commandLine.appendSwitch('trace-startup');
app.commandLine.appendSwitch('trace-startup-file', 'startup-trace.json');
优化技术
- 延迟加载模块
- 推迟非关键初始化
- 优化包大小
- 使用V8快照
- 预加载关键资源
基准测试
| 指标 | 优秀 | 可接受 | 较差 |
|---|---|---|---|
| 冷启动 | < 2秒 | < 4秒 | > 6秒 |
| 热启动 | < 1秒 | < 2秒 | > 3秒 |
| 窗口可见 | < 1.5秒 | < 3秒 | > 5秒 |
相关技能
memory-leak-detectorbundle-size-analyzer