Cpu Profiling

aj-geddes/useful-ai-prompts/skills/cpu-profiling

作者 aj-geddes3f5182cfd739无许可证355 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Profile CPU usage to identify hot spots and bottlenecks. Optimize code paths consuming most CPU time for better performance and resource efficiency.

AI 生成的概览

指导进行 CPU 性能分析,找出热点与瓶颈,并优化最耗 CPU 的代码路径。

功能
该技能提供 CPU 使用情况分析的指导,用于识别消耗 CPU 时间最多的函数和代码路径。内容涵盖浏览器与 React 分析流程、分析结果的解读、优化流程以及监控最佳实践。它产出的是指导与参考资料,而非脚本或生成的文件。
适用场景
当应用出现 CPU 占用过高、执行缓慢或性能回退时使用,也适合在开展优化工作之前使用。它还面向 CPU 行为的生产环境监控。
运行要求
不附带脚本,该技能仅为说明与参考文档。它假定可以使用性能分析工具,例如浏览器开发者工具或 React Profiler。

CPU Profiling

Table of Contents

Overview

CPU profiling identifies which functions consume most CPU time, enabling targeted optimization of expensive code paths.

When to Use

  • High CPU usage
  • Slow execution
  • Performance regression
  • Before optimization
  • Production monitoring

Quick Start

Minimal working example:

yaml
Browser Profiling:
Chrome DevTools:  Steps:    1. DevTools → Performance    2. Click record    3. Perform action    4. Stop recording    5. Analyze flame chart  Metrics:    - Function call duration    - Call frequency    - Total time vs self time
Firefox Profiler:  - Built-in performance profiler  - Flame graphs  - Timeline view  - Export and share
React Profiler:  - DevTools → Profiler  - Component render times  - Phase: render vs commit  - Why component re-rendered// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Profiling Tools [blocked]Profiling Tools
Analysis & Interpretation [blocked]Analysis & Interpretation
Optimization Process [blocked]Optimization Process
Monitoring & Best Practices [blocked]Monitoring & Best Practices

Best Practices

✅ DO

  • Follow established patterns and conventions
  • Write clean, maintainable code
  • Add appropriate documentation
  • Test thoroughly before deploying

❌ DON'T

  • Skip testing or validation
  • Ignore error handling
  • Hard-code configuration values

来源与署名

来源:aj-geddes/useful-ai-prompts位于skills/cpu-profiling提交3f5182c

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架