SuperAPI AI 工具集

performance-profiling

编程与开发

查看项目

更新于 10-16 06:00

技能介绍

Performance Profiling 是一个面向 AI 智能体的可安装技能,由 xenitv1/claude-code-maestro 发布,围绕“测量、分析、优化”的顺序组织性能优化工作方法。其核心口号为:Measure, analyze, optimize - in that order。

一、运行时脚本 技能提供一个可执行脚本用于自动化性能分析: scripts/lighthouse_audit.py,用途为 Lighthouse performance audit(Lighthouse 性能审计),用法:python scripts/lighthouse_audit.py https://example.com

二、Core Web Vitals 技能列出三项核心网页指标及其判定标准与衡量对象:

  • LCP:Good < 2.5s,Poor > 4.0s,衡量 Loading(加载)。
  • INP:Good < 200ms,Poor > 500ms,衡量 Interactivity(交互性)。
  • CLS:Good < 0.1,Poor > 0.25,衡量 Stability(稳定性)。 关于测量时机,技能按阶段给出对应工具:Development 阶段使用 Local Lighthouse;CI/CD 阶段使用 Lighthouse CI;Production 阶段使用 RUM(Real User Monitoring,真实用户监控)。

三、分析工作流 技能提出四步流程:1. BASELINE → Measure current state(建立基线,测量当前状态);2. IDENTIFY → Find the bottleneck(定位瓶颈);3. FIX → Make targeted change(做有针对性的修改);4. VALIDATE → Confirm improvement(验证改进效果)。 在分析工具选择上,技能按问题类型给出对应工具:Page load 用 Lighthouse;Bundle size 用 Bundle analyzer;Runtime 用 DevTools Performance;Memory 用 DevTools Memory;Network 用 DevTools Network。

四、包体(Bundle)分析 需要关注的信号:Large dependencies 表现为 Top of bundle;Duplicate code 表现为 Multiple chunks;Unused code 表现为 Low coverage;Missing splits 表现为 Single large chunk。 对应的优化动作:遇到 Big library 时 Import specific modules(只导入具体模块);遇到 Duplicate deps 时 Dedupe, update versions(去重、更新版本);遇到 Route in main 时 Code split(代码分割);遇到 Unused exports 时 Tree shake(摇树优化)。

五、运行时与内存分析 Performance 面板中可识别的模式:Long tasks (>50ms) 表示 UI blocking(阻塞 UI);Many small tasks 表示可能存在批处理机会;Layout/paint 表示渲染瓶颈;Script 表示 JavaScript 执行。 Memory 面板中可识别的模式:Growing heap 表示可能存在内存泄漏;Large retained 提示检查引用;Detached DOM 表示未清理的 DOM。

六、常见瓶颈与症状归因 Slow initial load 的常见原因是 Large JS、render blocking;Slow interactions 的常见原因是 Heavy event handlers;Jank during scroll 的常见原因是 Layout thrashing;Growing memory 的常见原因是 Leaks、retained refs。

七、快速见效的优化优先级

  1. Enable compression(启用压缩),影响 High;2. Lazy load images(图片懒加载),影响 High;3. Code split routes(路由代码分割),影响 High;4. Cache static assets(静态资源缓存),影响 Medium;5. Optimize images(图片优化),影响 Medium。

八、反模式 不要:Guess at problems(猜测问题)→ 应:Profile first(先做性能分析);不要:Micro-optimize(过度微优化)→ 应:Fix biggest issue(解决最大问题);不要:Optimize early(过早优化)→ 应:Optimize when needed(按需优化);不要:Ignore real users(忽略真实用户)→ 应:Use RUM data(使用 RUM 数据)。 技能最后强调:The fastest code is code that doesn't run. Remove before optimizing.(最快的代码是不运行的代码,先删除再优化。)

九、使用方式与限制 该技能为 AI 智能体可安装技能,通过发布来源 xenitv1/claude-code-maestro 提供,页面地址为 https://www.skills.sh/xenitv1/claude-code-maestro/performance-profiling。具体安装命令、支持的智能体平台、收费方式与价格、以及除上述内容外的更多功能细节,资料中暂未提供。