Loading...
Loading...
Compare original and translation side by side
| Term | Definition |
|---|---|
| complexity | Big-O algorithmic classification of a function or code path |
| hotspot | Code region with disproportionate resource consumption (time or memory) |
| bottleneck | System constraint limiting overall throughput |
| profiler output | Textual data from cProfile, py-spy, perf, or similar tools pasted by user |
| cache strategy | Eviction policy + write policy + invalidation approach for a caching layer |
| benchmark skeleton | Template code for measuring function performance with proper methodology |
| regression risk | Likelihood that a code change degrades performance, scored LOW/MEDIUM/HIGH/CRITICAL |
| anti-pattern | Known performance-harmful code pattern (N+1, unbounded allocation, etc.) |
| evidence | Concrete proof: AST analysis, profiler data, code pattern match, or external reference |
| recommendation | Actionable optimization suggestion with expected impact and trade-offs |
| flame graph | Hierarchical visualization of call stack sampling data |
| wall time | Elapsed real time (includes I/O waits) vs CPU time (compute only) |
| 术语 | 定义 |
|---|---|
| complexity | 函数或代码路径的大O算法分类 |
| hotspot | 资源消耗(时间或内存)占比过高的代码区域 |
| bottleneck | 限制系统整体吞吐量的约束环节 |
| profiler output | 用户粘贴的来自cProfile、py-spy、perf或类似工具的文本数据 |
| cache strategy | 缓存层的淘汰策略 + 写入策略 + 失效方案 |
| benchmark skeleton | 采用规范方法测量函数性能的模板代码 |
| regression risk | 代码变更导致性能下降的可能性,分为LOW/MEDIUM/HIGH/CRITICAL四个等级 |
| anti-pattern | 已知的有损性能的代码模式(如N+1查询、无界内存分配等) |
| evidence | 具体证据:AST分析、分析器数据、代码模式匹配或外部参考资料 |
| recommendation | 可落地的优化建议,包含预期影响与权衡点 |
| flame graph | 调用栈采样数据的层级可视化图表 |
| wall time | 实际流逝时间(包含I/O等待),区别于CPU时间(仅计算运算时间) |
| $ARGUMENTS | Mode |
|---|---|
| Algorithmic complexity analysis, Big-O review |
| Interpret textual profiler output (cProfile, py-spy, perf) |
| Caching strategy design (LRU/LFU/TTL/write-through/write-back) |
| Benchmark design and methodology review |
| Performance regression risk assessment from code diff |
| Common memory leak pattern scan (NOT actual detection) |
| Empty | Show mode menu with examples for each mode |
| 参数 | 模式 |
|---|---|
| 算法复杂度分析、大O评审 |
| 解析文本格式的分析器输出(cProfile、py-spy、perf) |
| 缓存策略设计(LRU/LFU/TTL/写穿/写回) |
| 基准测试设计与方法评审 |
| 基于代码差异的性能回归风险评估 |
| 常见内存泄漏模式扫描(非实际检测) |
| 空值 | 显示模式菜单及各模式示例 |
uv run python skills/performance-profiler/scripts/complexity-estimator.py <path>uv run python skills/performance-profiler/scripts/complexity-estimator.py <path>references/complexity-patterns.mdreferences/complexity-patterns.md| Function | Estimated Complexity | Evidence | Hotspot Risk | Recommendation |
|---|
| 函数 | 估算复杂度 | 证据 | 热点风险 | 建议 |
|---|
uv run python skills/performance-profiler/scripts/profile-parser.py --input <file>uv run python skills/performance-profiler/scripts/profile-parser.py --input <file>references/anti-patterns.mdreferences/anti-patterns.mdreferences/caching-strategies.md| Factor | LRU | LFU | TTL | Write-Through | Write-Back |
|---|---|---|---|---|---|
| Read-heavy, stable working set | Good | Best | OK | -- | -- |
| Write-heavy | -- | -- | -- | Safe | Fast |
| Strict freshness | -- | -- | Best | Best | Risky |
| Memory-constrained | Best | Good | OK | -- | -- |
references/caching-strategies.md| 因素 | LRU | LFU | TTL | Write-Through | Write-Back |
|---|---|---|---|---|---|
| 读密集、稳定工作集 | 良好 | 最佳 | 尚可 | -- | -- |
| 写密集 | -- | -- | -- | 安全 | 快速 |
| 严格新鲜度 | -- | -- | 最佳 | 最佳 | 有风险 |
| 内存受限 | 最佳 | 良好 | 尚可 | -- | -- |
uv run python skills/performance-profiler/scripts/benchmark-designer.py --function <signature> --language <lang>uv run python skills/performance-profiler/scripts/benchmark-designer.py --function <signature> --language <lang>git diffgit diff| Risk Factor | Weight | Check |
|---|---|---|
| Complexity increase | 3x | Loop nesting added, algorithm changed |
| Hot path change | 3x | Function called in request/render path |
| Data structure change | 2x | Collection type or size assumptions changed |
| I/O pattern change | 2x | New network/disk calls, removed batching |
| Memory allocation | 1x | New allocations in loops, larger buffers |
| 风险因素 | 权重 | 检查项 |
|---|---|---|
| 复杂度提升 | 3x | 添加循环嵌套、算法变更 |
| 热路径变更 | 3x | 函数在请求/渲染路径中被调用 |
| 数据结构变更 | 2x | 集合类型或规模假设变更 |
| I/O模式变更 | 2x | 新增网络/磁盘调用、移除批处理 |
| 内存分配 | 1x | 循环中新增内存分配、缓冲区扩容 |
references/leak-patterns.mdreferences/leak-patterns.md| Pattern | Language | Severity | False Positive Risk |
|---|
| 模式 | 语言 | 严重程度 | 误报风险 |
|---|
| Scope | Strategy |
|---|---|
| Single function | Direct analysis, inline report |
| Single file (< 500 LOC) | Script-assisted analysis, structured report |
| Multiple files / module | Parallel subagents per file, consolidated report |
| Full codebase | Prioritize entry points and hot paths, sample-based analysis |
| 范围 | 策略 |
|---|---|
| 单个函数 | 直接分析、内嵌报告 |
| 单个文件(<500行代码) | 脚本辅助分析、结构化报告 |
| 多文件/模块 | 每个文件分配并行子Agent、合并报告 |
| 完整代码库 | 优先分析入口点与热路径、基于采样的分析 |
| File | Content | Read When |
|---|---|---|
| Code pattern to Big-O mapping with examples | Mode 1 (Analyze) |
| Caching decision tree, eviction policies, trade-offs | Mode 3 (Cache) |
| Performance anti-patterns catalog (N+1, unbounded alloc, etc.) | Mode 2 (Profile), Mode 5 (Regression), Mode 6 (Leak) |
| Memory leak patterns by language (Python, JS, Go, Java) | Mode 6 (Leak-Patterns) |
| Profiler output interpretation, flame graph reading | Mode 2 (Profile) |
| Benchmark design best practices, statistical methods | Mode 4 (Benchmark) |
| Script | When to Run |
|---|---|
| Mode 1 — static complexity analysis via AST |
| Mode 2 — parse cProfile/pstats textual output to JSON |
| Mode 4 — generate benchmark skeleton from function signature |
| Template | When to Render |
|---|---|
| After any mode — inject results JSON into data tag |
| 文件 | 内容 | 加载时机 |
|---|---|---|
| 代码模式与大O映射及示例 | 模式1(分析) |
| 缓存决策树、淘汰策略、权衡点 | 模式3(缓存) |
| 性能反模式目录(N+1查询、无界分配等) | 模式2(剖析)、模式5(回归)、模式6(泄漏) |
| 各语言内存泄漏模式(Python、JS、Go、Java) | 模式6(泄漏模式) |
| 分析器输出解读、火焰图阅读指南 | 模式2(剖析) |
| 基准测试设计最佳实践、统计方法 | 模式4(基准测试) |
| 脚本 | 运行时机 |
|---|---|
| 模式1 — 通过AST进行静态复杂度分析 |
| 模式2 — 将cProfile/pstats文本输出解析为JSON |
| 模式4 — 根据函数签名生成基准测试模板 |
| 模板 | 渲染时机 |
|---|---|
| 任意模式完成后 — 将结果JSON注入数据标签 |
| File | Content |
|---|---|
| Code pattern to Big-O mapping (machine-readable) |
| Caching decision tree (machine-readable) |
| Performance anti-patterns catalog (machine-readable) |
| 文件 | 内容 |
|---|---|
| 代码模式与大O映射(机器可读) |
| 缓存决策树(机器可读) |
| 性能反模式目录(机器可读) |
[file:line][file:line]