mcpField
C
cpu-profiling

cpu-profiling

github.com/aj-geddes开发373452 次安装34 周前更新
代码仓库

关于 cpu-profiling

用于分析 CPU 使用情况并定位耗时最多函数的技能,帮助针对性优化。适用于调查运行缓慢、CPU 使用率高或性能回退。

主要功能

  1. 01定位 CPU 密集型函数
  2. 02调查运行缓慢问题
  3. 03分析性能回退
  4. 04性能分析工具参考
  5. 05优化与监控指引

适用场景

  1. 01调查 CPU 使用率过高
  2. 02查找运行缓慢的原因
  3. 03检查性能回退
  4. 04监控 CPU 性能

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill cpu-profiling

安装后在 Claude Code 中输入/cpu-profiling确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
analysis-interpretation.md
monitoring-best-practices.md
optimization-process.md
profiling-tools.md
templates/
component-template.tsx

详细介绍

CPU 性能分析

目录

概述

CPU 性能分析可确定哪些函数消耗的 CPU 时间最多,从而有针对性地优化开销较大的代码路径。

适用场景

  • CPU 使用率高
  • 执行缓慢
  • 性能回退
  • 优化前
  • 生产环境监控

快速入门

最简可运行示例:

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)

参考指南

references/ 目录中的详细实现:

指南内容
性能分析工具性能分析工具
分析与解读分析与解读
优化流程优化流程
监控与最佳实践监控与最佳实践

最佳实践

✅ 应该做
  • 遵循既定模式和惯例
  • 编写清晰、易维护的代码
  • 添加适当的文档
  • 部署前进行全面测试
❌ 不应该做
  • 跳过测试或验证
  • 忽略错误处理
  • 将配置值硬编码

评论

支持 Markdown