Application Profiler 技能:用 cProfile 找出 Python 批处理热点
EnglishClaude Code 安装步骤
- 从 GitHub 固定提交获取完整的 `plugins/performance/application-profiler/skills/profiling-application-performance` 目录。
- 复制到目标项目的 `.claude/skills/`,确认 `.claude/skills/profiling-application-performance/SKILL.md`,再从项目根目录启动 Claude Code,输入 `/profiling-application-performance`。
中文摘要
让 Claude Code 阅读本地 Python 程序的性能记录,找出累计耗时高的函数,并用固定输入验证改动。
SKILL.md 中文导读
可复现示例
将 10,000 条合成商品分类记录交给本地 summarize.py。运行 python -m cProfile -s cumulative summarize.py,核对重复分类计算并在同样输入上复测。工作步骤
- 先记录输入、版本和启动方式。用 cProfile 对基准脚本采样,将结果按累计时间排序。
- 选出一个函数检查重复工作。保留优化前后的输出和 profile 供复核。
验收方法
报告指出实际热点、调用次数与累计耗时。两次汇总结果可逐项比较。
GitHub 原文 · 更新日期
适用环境
准备自己的 Python 批处理脚本、cProfile 和固定合成 CSV。示例记录调用次数与累计时间。
常见问题
累计时间比函数自身时间大是异常吗?
累计时间包含子调用,自身时间聚焦函数本身。两者一起看有助于确认优化位置。
相关指南
相关推荐
groq-install-auth 技能
jeremylongshore/claude-code-plugins-plus-skills
anima-common-errors 技能
jeremylongshore/claude-code-plugins-plus-skills
apple-notes-hello-world 技能
jeremylongshore/claude-code-plugins-plus-skills
castai-hello-world 技能
jeremylongshore/claude-code-plugins-plus-skills
cohere-local-dev-loop 技能
jeremylongshore/claude-code-plugins-plus-skills
figma-security-basics 技能
jeremylongshore/claude-code-plugins-plus-skills