Agent skill

Py Perf Analyzer

by rongxinzy in rongxinzy/RongxinAI

定位 Python 脚本的性能瓶颈,集成 cProfile、tracemalloc 和 lineprofiler,一键执行 CPU 热点函数、内存分配或逐行耗时分析,并可输出 JSON 报告。当用户提到优化脚本、分析性能、定位 CPU 或内存热点、进行逐行分析,或询问代码为什么慢、如何加速、内存泄漏等问题时触发。

MITAuto-check passedDevelopment

Install Py Perf Analyzer

skills CLI
$ npx skills add rongxinzy/RongxinAI --skill py-perf-analyzer -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rongxinzy/RongxinAI py-perf-analyzer --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rongxinzy/RongxinAI.git skills-src && mkdir -p .claude/skills && cp -r skills-src/SKILLs/py-perf-analyzer .claude/skills/py-perf-analyzer && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
py-perf-analyzer
GitHub stars
154
Token cost
~794 tokens
SKILL.md length
97 words
Files
6 (incl. scripts)
Skills in repo
94
Repo updated
First seen
Licence
MIT

At a glance

定位 Python 脚本的性能瓶颈,集成 cProfile、tracemalloc 和 lineprofiler,一键执行 CPU 热点函数、内存分配或逐行耗时分析,并可输出 JSON 报告。当用户提到优化脚本、分析性能、定位 CPU 或内存热点、进行逐行分析,或询问代码为什么慢、如何加速、内存泄漏等问题时触发。

  • Tasks that involve Performance optimization
  • SKILL.md covers 功能, 依赖, 使用方式 and 输出说明
  • Runs Python scripts from its folder; calls python and pip

What it does

Py Perf Analyzer is an agent skill from rongxinzy/RongxinAI. 定位 Python 脚本的性能瓶颈,集成 cProfile、tracemalloc 和 lineprofiler,一键执行 CPU 热点函数、内存分配或逐行耗时分析,并可输出 JSON 报告。当用户提到优化脚本、分析性能、定位 CPU 或内存热点、进行逐行分析,或询问代码为什么慢、如何加速、内存泄漏等问题时触发。

Its SKILL.md is about 790 tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including scripts (for example `scripts/perf_profile.py` and `zhiyuan/metadata.yaml`).

It sits in Development, covering Performance optimization. It works with Python. The repository describes itself as: An all-in-one local AI Agent workspace with a fully self-developed stack. The licence is MIT.

When your agent uses it

  • Tasks that involve Performance optimization

Example prompts

  • “/py-perf-analyzer”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit 9c64865. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python
    • pip

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Py Perf Analyzer loads about 794 tokens when it runs. Until then it costs about 44 tokens; SKILL.md has 97 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~44
When it runs · the whole SKILL.md, loaded when a task matches
~794

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from rongxinzy/RongxinAI at commit 9c64865, republished under its MIT licence (© rongxinzy). 97 words, ~794 tokens.

Download SKILL.mdSave it as .claude/skills/py-perf-analyzer/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
py-perf-analyzer
description
定位 Python 脚本的性能瓶颈,集成 cProfile、tracemalloc 和 line_profiler,一键执行 CPU 热点函数、内存分配或逐行耗时分析,并可输出 JSON 报告。当用户提到优化脚本、分析性能、定位 CPU 或内存热点、进行逐行分析,或询问代码为什么慢、如何加速、内存泄漏等问题时触发。
license
MIT
metadata.type
tool
metadata.tags
python, profiling, performance, cProfile, memory, optimization

Perf Profiler

Python 性能分析工具,集成 cProfile、line_profiler 和 tracemalloc,一键定位 CPU 和内存瓶颈。

功能

  • CPU 分析 (cProfile):统计每个函数的调用次数、累计耗时、自身耗时,定位热点函数
  • 内存分析 (tracemalloc):追踪内存分配热点、峰值内存、内存增长来源
  • 逐行分析 (line_profiler):精确到每一行代码的耗时和命中次数,适合深入优化
  • 组合分析:all 模式一次执行同时收集 CPU + 内存数据,减少重复运行开销

依赖

依赖类型用途
Python 3.7+必须运行环境
cProfile / pstats内置CPU 性能分析
tracemalloc内置内存追踪
line_profiler可选逐行分析(pip install line_profiler)

使用方式

bash
python scripts/perf_profile.py <脚本路径> [脚本参数...] [选项]
参数
参数说明默认值
script要分析的 Python 脚本路径(必填)-
script_args传递给目标脚本的参数无
--mode分析模式:cpu / memory / line / allcpu
--top显示 Top N 结果20
--sortCPU 分析排序:cumulative / tottime / callscumulative
--output输出 JSON 报告到文件仅终端输出
--function逐行分析的目标函数名(逗号分隔)自动发现
--threshold只显示占比超过此值(%)的函数0
示例
bash
# CPU 分析(默认模式)
python scripts/perf_profile.py my_script.py

# 内存分析
python scripts/perf_profile.py my_script.py --mode memory

# 逐行分析指定函数
python scripts/perf_profile.py my_script.py --mode line --function compute,process_data

# 全量分析(CPU + 内存),只看 Top 10
python scripts/perf_profile.py my_script.py --mode all --top 10

# 传递参数给目标脚本,输出 JSON 报告
python scripts/perf_profile.py my_script.py --output report.json -- --input data.csv --output result.csv

# 只关注占比 > 5% 的函数
python scripts/perf_profile.py my_script.py --threshold 5

输出说明

CPU 分析报告
============================================================
  CPU 性能分析报告 (cProfile)
============================================================

  总执行时间: 2.3456 秒
  总函数调用: 1,234,567 次
  分析函数数: 89 个

  Top 5 耗时函数:
  --------------------------------------------------------
  排名   占比   累计(s)    自身(s)      调用  函数
  --------------------------------------------------------
  1     45.2%    1.0605    0.8234     1000  compute.py:23:matrix_multiply
  2     22.1%    0.5183    0.5183    50000  utils.py:45:normalize
  3     12.3%    0.2885    0.1200      500  io.py:12:read_batch
  ...

  🔍 主要瓶颈: matrix_multiply (45.2% 时间)
     位置: compute.py:23
内存分析报告
============================================================
  内存分析报告 (tracemalloc)
============================================================

  峰值内存: 128.5 MB
  当前内存: 64.2 MB

  Top 5 内存分配:
  --------------------------------------------------------
  排名       大小     数量  位置
  --------------------------------------------------------
  1      45.2 MB    10000  data_loader.py:78
  2      22.1 MB     5000  transform.py:45
  ...

  内存增长热点:
  --------------------------------------------------------
  1     +32.0 MB  (+8000)  data_loader.py:78
  ...
JSON 报告

使用 --output 参数可导出完整的结构化 JSON 报告,包含所有分析维度的详细数据,便于后续处理或接入 CI 流水线。

© rongxinzy, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (scripts) in SKILLs/py-perf-analyzer of rongxinzy/RongxinAI.

  • SKILL.md
  • LICENSE
  • requirements.txt
  • scripts/perf_profile.py
  • zhiyuan/icon.png
  • zhiyuan/metadata.yaml

Open the folder on GitHubat commit 9c64865

Compare with similar skills

Py Perf Analyzer next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Py Perf Analyzer compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Py Perf Analyzer this skillrongxinzy/RongxinAI154—~794Automated safety check: PassMIT
Code Review ChecklistshareAI-lab/learn-claude-code78k4 repos~1.1kAutomated safety check: PassMIT
Pycrazyguitar/pysheeet8.2k—~886Automated safety check: PassMIT
Python Performance Optimizationwshobson/agents40k13 repos~814Automated safety check: PassMIT
Keybase RPC Log Analysiskeybase/client9.3k—~3kAutomated safety check: PassBSD-3-Clause
The Art of Debuggingstas00/the-art-of-debugging1.7k—~6.1kAutomated safety check: NotesCC-BY-SA-4.0

Similar skills

  • Code Review Checklist

    shareAI-lab/learn-claude-code

    Reviews code against a five-part checklist covering security, correctness, performance, maintainability and testing, and reports findings in a fixed format.

    78k GitHub starsUsed in 4 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Py

    crazyguitar/pysheeet

    Comprehensive Python programming reference covering syntax, concurrency, networking, databases, ML/LLM development, and HPC.

    8.2k GitHub stars~886 tokensUpdated 3 days ago
    DevelopmentAuto-check passed
  • Profiles slow Python code with cProfile and memory profilers, then applies targeted fixes for CPU, memory, I/O and query bottlenecks.

    40k GitHub starsUsed in 13 repos~814 tokens
    DevelopmentAuto-check passed
  • Captures a clean Keybase service log and analyzes it for redundant, duplicated or looping RPCs, then checks whether a caching fix reduced the calls.

    9.3k GitHub stars~3k tokensUpdated today
    DevelopmentAuto-check passed
  • The Art of Debugging

    stas00/the-art-of-debugging

    Condensed debugging method and tool recipes for Unix, Python and PyTorch programs: crashes, hangs, segfaults, wrong output, CUDA OOM, NaN values and slowness.

    1.7k GitHub stars~6.1k tokensUpdated 3 days ago
    DevelopmentAuto-check: notes
  • Code Review Specialist

    luongnv89/claude-howto

    Reviews code for security, performance, quality and maintainability, using a checklist, a finding template and two metrics scripts.

    42k GitHub stars~764 tokensUpdated 9 days ago
    DevelopmentAuto-check passed

More from rongxinzy/RongxinAI

All 94 skills in this repo
  • SaaS Metrics Coach

    rongxinzy/RongxinAI

    SaaS financial health advisor. An agent skill from rongxinzy/RongxinAI.

    154 GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check passed
  • Churn Prevention

    rongxinzy/RongxinAI

    Reduce voluntary and involuntary churn through cancel flow design, save offers, exit surveys, and dunning sequences.

    154 GitHub starsUsed in 3 repos~2.6k tokens
    Auto-check passed
  • Presentation Studio

    rongxinzy/RongxinAI

    The only skill for creating a new PowerPoint deck. An agent skill from rongxinzy/RongxinAI.

    154 GitHub stars~2.1k tokensUpdated today
    Auto-check passed
  • Zhiyuan Expert Manager

    rongxinzy/RongxinAI

    ZhiYuan Agent expert package lifecycle manager for the pi engine.

    154 GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Ziwei Doushu

    rongxinzy/RongxinAI

    Professional Ziwei Doushu consultation skill with an offline calculation engine.

    154 GitHub stars~746 tokensUpdated today
    Auto-check passed
  • Lark Mail

    rongxinzy/RongxinAI

    飞书邮箱:Use when user mentions 起草邮件、写邮件、草稿、发送/回复/转发邮件、查阅邮件、看邮件、搜索邮件、邮件文件夹、邮件标签、邮件联系人、监听新邮件、邮件收信规则等;use for mail/email intent only.

    154 GitHub starsUsed in 3 repos~4.1k tokens
    Auto-check: warnings

Works with

Categories

Questions about Py Perf Analyzer

What does Py Perf Analyzer do?

定位 Python 脚本的性能瓶颈,集成 cProfile、tracemalloc 和 lineprofiler,一键执行 CPU 热点函数、内存分配或逐行耗时分析,并可输出 JSON 报告。当用户提到优化脚本、分析性能、定位 CPU 或内存热点、进行逐行分析,或询问代码为什么慢、如何加速、内存泄漏等问题时触发。. Py Perf Analyzer is an agent skill from rongxinzy/RongxinAI.

When should I use Py Perf Analyzer?

Py Perf Analyzer fits situations like: tasks that involve Performance optimization.

How do I install Py Perf Analyzer in Claude Code?

Run `npx skills add rongxinzy/RongxinAI --skill py-perf-analyzer -a claude-code`. Or copy the skill folder (SKILLs/py-perf-analyzer in rongxinzy/RongxinAI) into .claude/skills/py-perf-analyzer in your project. Claude Code loads it when a task matches its description.

How do I install Py Perf Analyzer in Codex?

Run `npx skills add rongxinzy/RongxinAI --skill py-perf-analyzer -a codex`. Or copy the skill folder (SKILLs/py-perf-analyzer in rongxinzy/RongxinAI) into .agents/skills/py-perf-analyzer in your project. Codex loads it when a task matches its description.

Can I use Py Perf Analyzer in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rongxinzy/RongxinAI --skill py-perf-analyzer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/py-perf-analyzer, .gemini/skills/py-perf-analyzer, .github/skills/py-perf-analyzer and .opencode/skills/py-perf-analyzer in your project.

What does Py Perf Analyzer need to run?

Going by SKILL.md and its folder, Py Perf Analyzer needs Python for the scripts in its folder and the command-line tools its instructions call (python and pip). Our summary lists: Python 3.

Does Py Perf Analyzer access the network?

SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Py Perf Analyzer safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Py Perf Analyzer use?

Py Perf Analyzer is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Py Perf Analyzer use?

About 794 tokens (SKILL.md is roughly 3.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Py Perf Analyzer?

Skills that share tags, products or a category with Py Perf Analyzer: Code Review Checklist (shareAI-lab/learn-claude-code, 78k stars), Py (crazyguitar/pysheeet, 8.2k stars), Python Performance Optimization (wshobson/agents, 40k stars) and Keybase RPC Log Analysis (keybase/client, 9.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Py Perf Analyzer?

rongxinzy (a GitHub organization) maintains it in rongxinzy/RongxinAI, which has 154 GitHub stars. The repository holds 94 skills in this directory. The repository was last updated on October 10, 2026.

Source: rongxinzy/RongxinAI on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.