Agent skill

Perf Hotspot Profiling

by pa001024 in pa001024/dna-builder

用 V8 CPU profile 定位 JS/TS 热点函数,并用「同进程交替 A/B + best(min) 统计量 + checksum 锚点」的微基准方法安全地做性能优化。当需要优化计算热点、怀疑某函数耗时占比高、想评估某个优化(含 Wasm/SIMD 等加速路径)是否真有收益、或要建立可回归的性能基准时使用。

MITAuto-check passed

Install Perf Hotspot Profiling

skills CLI
$ npx skills add pa001024/dna-builder --skill perf-hotspot-profiling -a claude-code

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

GitHub CLI
$ gh skill install pa001024/dna-builder perf-hotspot-profiling --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/pa001024/dna-builder.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/perf-hotspot-profiling .claude/skills/perf-hotspot-profiling && 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
perf-hotspot-profiling
GitHub stars
136
Token cost
~1k tokens
SKILL.md length
215 words
Files
2 (incl. scripts)
Skills in repo
14
Repo updated
First seen
Licence
MIT

At a glance

用 V8 CPU profile 定位 JS/TS 热点函数,并用「同进程交替 A/B + best(min) 统计量 + checksum 锚点」的微基准方法安全地做性能优化。当需要优化计算热点、怀疑某函数耗时占比高、想评估某个优化(含 Wasm/SIMD 等加速路径)是否真有收益、或要建立可回归的性能基准时使用。

  • Works in 6 steps: 立锚点:先能证明「没算错」 → 抓 profile,算 self-time 找热点 → 按性价比顺序试优化 → …
  • SKILL.md covers Overview, When to use, Prerequisites and Workflow, plus 2 more sections
  • Runs JavaScript scripts from its folder; calls node and bun

What it does

Perf Hotspot Profiling is an agent skill from pa001024/dna-builder. 用 V8 CPU profile 定位 JS/TS 热点函数,并用「同进程交替 A/B + best(min) 统计量 + checksum 锚点」的微基准方法安全地做性能优化。当需要优化计算热点、怀疑某函数耗时占比高、想评估某个优化(含 Wasm/SIMD 等加速路径)是否真有收益、或要建立可回归的性能基准时使用。

Its SKILL.md is about 1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including scripts.

It works with WebAssembly. The repository describes itself as: 二重螺旋构筑模拟器 Duet Night Abyss Builder. The licence is MIT.

Example prompts

  • “/perf-hotspot-profiling”

Requirements

  • Node.js

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. 立锚点:先能证明「没算错」
  2. 抓 profile,算 self-time 找热点
  3. 按性价比顺序试优化
  4. 微基准:同进程交替 + best
  5. 加失效回归测试
  6. 复测 + 清理

What it can do on your machine

Read from SKILL.md and the folder at commit 0a808c9. 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/ (JavaScript), which the agent can run.

    Shell commands in SKILL.md call:

    • node
    • bun

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

  • Network

    No URLs in SKILL.md.

    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

Perf Hotspot Profiling loads about 1k tokens when it runs. Until then it costs about 46 tokens; SKILL.md has 215 words of instructions outside code blocks.

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

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 pa001024/dna-builder at commit 0a808c9, republished under its MIT licence (© pa001024). 215 words, ~1,017 tokens.

Download SKILL.mdSave it as .claude/skills/perf-hotspot-profiling/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
perf-hotspot-profiling
description
用 V8 CPU profile 定位 JS/TS 热点函数,并用「同进程交替 A/B + best(min) 统计量 + checksum 锚点」的微基准方法安全地做性能优化。当需要优化计算热点、怀疑某函数耗时占比高、想评估某个优化(含 Wasm/SIMD 等加速路径)是否真有收益、或要建立可回归的性能基准时使用。

热点剖析与微基准优化

Overview

前端/数据层的性能优化最容易踩的坑不是「不会优化」,而是量错了:用错统计量、在同一进程里先跑 A 后跑 B 导致顺序偏差、拿肉眼或单次耗时下结论。本技能固化一套可复现的流程:

  1. 先立正确性锚点(checksum),再谈提速;
  2. 用 CPU profile 的 self-time 找真热点,不靠猜;
  3. 微基准用 best(min) + 同进程交替采样,避开 GC/时钟抖动与加载顺序偏差;
  4. 优化手段按「查表化 → 版本号失效缓存 → 删掉净负收益的加速路径」顺序试;
  5. 加失效回归测试,最后复测 + 清理临时文件。

When to use

  • 某次 calculate() / 渲染 / 数据转换明显卡,需要知道「时间花在哪」。
  • 已经有一个「应该更快」的想法(缓存、查表、Wasm、SIMD、Worker),需要判断值不值得做。
  • 想给热点函数建立长期可跑的基准与回归(防以后悄悄劣化)。
  • 看到「优化后反而变慢」的报告,需要排除测量方法本身的偏差。

Prerequisites

  • 能跑被测代码的本地脚本(本仓库:bun;测试 node node_modules/vitest/vitest.mjs)。
  • 一份真实输入的固定场景(不要用玩具数据,热点分布完全不同)。
  • 一个可复现的数值结果作为正确性锚点(本仓库 CharBuild 用 calculate() 的 checksum)。

Workflow

Step 1 — 立锚点:先能证明「没算错」

优化前先记录一个确定性的数值结果,例如:

bash
bun tools/benchmark-charbuild.ts     # 本项目:打印 checksum 1164735053516.7178

把「场景 + 目标函数 + checksum 期望值」写进基准脚本的注释里,之后每次优化都对比它。 checksum 变了就是算错了,提速多少都没意义。

Step 2 — 抓 profile,算 self-time 找热点

用 Node 的 --cpu-prof 跑一段循环(或直接在探针里调用 console.profile),产出 .cpuprofile:

bash
node --cpu-prof --cpu-prof-dir .tmp/prof --cpu-prof-name c.cpuprofile .tmp/prof-calc.ts
# 或 bun(同样支持)
bun --cpu-prof --cpu-prof-dir .tmp/prof .tmp/prof-calc.ts

然后解析 self-time(不要只看 total time,被调用的下游会污染):

bash
node .agents/skills/perf-hotspot-profiling/scripts/profile-self-time.mjs .tmp/prof/c.cpuprofile --filter src/ --top 20

输出按 self-time 降序的函数表(含占比、文件:行)。盯占比最高的那一两个,优化它们; 占 2% 的函数再怎么优化也救不了整体。

Step 3 — 按性价比顺序试优化
手段适用注意
查表化同一批来源被反复线性扫描(每次调用都 for (mod of mods))一次性把来源摊平成 Map,查询变 O(1)。最大收益通常来自这步
版本号失效缓存派生数据依赖可变的源对象每个源类加 static propertiesRevision,所有改属性的入口都要自增,否则静默返回旧值
懒计算只有部分 key 会被查询按需算 + 缓存,别预计算全量
Wasm / SIMD / Worker目标是大规模数值计算本身先怀疑:构造输入 + 跨边界拷贝的开销经常远大于计算收益。必须用 Step 4 的方法实测

⚠️ 不可从加和表导出的量:Π(1+v)(独立乘区)、min/max、去重计数等,不能由 Σv 还原, 必须单独缓存。做「一张表搞定一切」时先检查有没有这类量。

Step 4 — 微基准:同进程交替 + best

写基准时遵守三条:

  1. 同进程交替采样:不要「先跑 2000 次 A,再跑 2000 次 B」,更不要分两次进程跑。 进程状态/堆布局会让后跑的一批系统性偏慢(实测可达 ±30%)。改成 A/B/A/B… 交替多轮。
  2. 统计量用 best(min),不要用 median。GC 与时钟抖动能把 median 抬 ±30%, 而 min 是「没有干扰时这函数要多久」,最稳定、最能反映优化效果。
  3. 每轮之间做等价性断言:A 与 B 的结果必须一致(容差内),否则你比的不是性能。

评估「某加速路径是否值得」时,把开关做成运行时可变(本仓库用 setWasmReady() + resetCharBuildSimdForTest()), 在同一进程里交替 9 轮,比值稳定在 1.00 ± 0.05 就说明没收益,直接删掉那条路径—— 净负收益的复杂度是纯负债。

Step 5 — 加失效回归测试

缓存类优化最大的风险是「该失效时没失效」。针对每一个能改属性的入口各写一条: 「改了 → 结果必须变,且等于重建对象后的结果」。

ts
// 模式:改一个属性源,然后和「重新构造一个等价构筑」对比
build.charMods[0].updateProperties(/* 新等级 */)
expect(build.calculate()).toBe(referenceBuild.calculate())          // 等于正确结果
expect(build.calculate()).not.toBe(untouched.calculate())           // 且确实变了
Step 6 — 复测 + 清理
bash
# 类型检查(本仓库整项目 vue-tsc 会 OOM 崩,用只含改动文件的 tsconfig)
NODE_OPTIONS="--max-old-space-size=8192" node node_modules/vue-tsc/bin/vue-tsc.js --noEmit -p .tmp/tsc-changed.json
# 格式化 + lint
node node_modules/@biomejs/biome/bin/biome check --write --linter-enabled=false <files>
node node_modules/@biomejs/biome/bin/biome lint <files>
# 测试
node node_modules/vitest/vitest.mjs run <test files>

最后删掉探针脚本、profile 目录、临时 tsconfig(保留一份优化前快照作回滚保险即可)。

Guidelines

  • 先量后改:任何「我觉得这里慢」的优化冲动,先用 Step 2 确认它确实是热点。
  • 一次只改一个手段,改完立刻复测;同时上三个手段就分不清谁有用谁有害。
  • 优化不改变行为:checksum 变了就回退,不要「顺便修一下」。
  • 加速路径要有退出条件:Wasm/SIMD/Worker 这类「看起来很专业」的方案, 实测比值 ≈1.0 就果断删。留着一个没收益的复杂度,以后每个读代码的人都要付利息。
  • 临时文件一律放 .tmp/;本仓库开发服务器固定在 http://localhost:1420,不要自己起 dev/build。

相关文件

  • scripts/profile-self-time.mjs — 解析 .cpuprofile,按 self-time 输出热点函数表。
  • 本仓库正式基准:tools/benchmark-charbuild.ts(bun bench:charbuild:real)。 加速路径(Wasm/SIMD)的决策复核工具在结论落地后已删除——结论:无收益,勿复活。
  • 本仓库已验证案例:src/data/CharBuild.ts 属性结算查表化(calculate() 约 45× 提速), 详见 .workbuddy/memory/2026-09-19.md 与 MEMORY.md 的「CharBuild 属性结算」小节。

© pa001024, 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 1 other file (scripts) in .agents/skills/perf-hotspot-profiling of pa001024/dna-builder.

  • SKILL.md
  • scripts/profile-self-time.mjs

Open the folder on GitHubat commit 0a808c9

Compare with similar skills

Perf Hotspot Profiling 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.

Perf Hotspot Profiling compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Perf Hotspot Profiling this skillpa001024/dna-builder136—~1kAutomated safety check: PassMIT
RuView CLI, API and WASMruvnet/RuView97k—~1.2kAutomated safety check: NotesMIT
Nginx To Higress Migrationhigress-group/higress9.5k—~3.9kAutomated safety check: PassApache-2.0
Update V86felixrieseberg/windows9524k—~1.7kAutomated safety check: PassCustom licence
Dotlottie WebLottieFiles/dotlottie-web892—~3.5kAutomated safety check: PassMIT
Adding Internal API RouteTriliumNext/Trilium38k—~3.3kAutomated safety check: PassAGPL-3.0

Similar skills

  • Covers the RuView `wifi-densepose` command line binary, its Axum REST API and the WebAssembly builds for browsers and ESP32, for embedding or scripting RuView.

    97k GitHub stars~1.2k tokensUpdated today
    Backend & APIsAuto-check: notes
  • Nginx To Higress Migration

    higress-group/higress

    Migrate from ingress-nginx to Higress in Kubernetes environments.

    9.5k GitHub stars~3.9k tokensUpdated yesterday
    DevOps & CloudAuto-check passed
  • Update V86

    felixrieseberg/windows95

    Build and install v86 (wasm + libv86.js + BIOS) into windows95.

    24k GitHub stars~1.7k tokensUpdated 28 days ago
    Testing & QAAuto-check passed
  • Dotlottie Web

    LottieFiles/dotlottie-web

    Implement Lottie animations using dotLottie runtimes (@lottiefiles/dotlottie-web and @lottiefiles/dotlottie-react).

    892 GitHub stars~3.5k tokensUpdated 2 days ago
    Media & CreativeAuto-check passed
  • Adding Internal API Route

    TriliumNext/Trilium

    A skill your agent uses when adding, moving, or wiring an internal REST endpoint in Trilium (a new /api/ route) — choosing between a core-shared handler (packages/trilium-core/src/routes/index.ts…

    38k GitHub stars~3.3k tokensUpdated today
    Testing & QAAuto-check passed
  • Client Request Signature Reversal

    awarexone/Agentic-Bug-Hunter

    Recovers a client-side request signature or anti-bot token just far enough to replay blocked requests in bug bounty testing, starting from a captured packet.

    5.3k GitHub stars~4.7k tokensUpdated yesterday
    SecurityAuto-check passed

More from pa001024/dna-builder

All 14 skills in this repo
  • Fmodel Unpack

    pa001024/dna-builder

    This skill documents how to use the fmodel-mcp toolkit (a CUE4Parse-based .NET CLI plus a thin Python MCP server) to inspect and export Unreal Engine game assets — pak files, textures, meshes…

    136 GitHub stars~2.6k tokensUpdated yesterday
    Auto-check passed
  • Bun Webview Test

    pa001024/dna-builder

    使用 Bun 1.4 内置的 Bun.WebView 无头浏览器对前端页面(Vue/Vite 等)做端到端冒烟与交互测试。当需要加载页面、真实点击、读取 DOM/应用状态、做断言、截图归档,或对本地开发服务器/静态站点做零依赖的浏览器级验证、可视化巡检、交互回归测试时,应使用本技能。

    136 GitHub stars~1.2k tokensUpdated yesterday
    Auto-check passed
  • Ue4 Pak Mod

    pa001024/dna-builder

    制作与调试 Unreal Engine 4.27 游戏的 pak 模组(模型/网格/资产换皮,如《二重螺旋》Duet Night Abyss)。两条路线:编辑器烘焙(Blender 自由改模型 → UE4.27 cook → pak)与二进制替换(改写已烘焙 .uasset 的导出名/载荷)。当需要「把 A 的模型换成 B 的模型」「让模型能自由导入 Blender…

    136 GitHub stars~2.5k tokensUpdated yesterday
    Auto-check passed
  • Build Creator

    pa001024/dna-builder

    给 dna-builder 里任意角色从零推一套「最优构筑」(BD)的通用方法论:读角色机制 → 辅助候选排列组合 → buff 组(含光环型海妖 / 角色专属如大冲击)→ 定计算方向 → 魔灵与潜质 → 必带 MOD → 用 autoBuild 跑一遍并剔除不合理件 → 消融实验。当需要「给某个角色配一套最优 BD」「这个角色带什么辅助/队友最强」「跑一下 XX…

    136 GitHub stars~3.6k tokensUpdated yesterday
    Auto-check passed
  • For Beginer

    pa001024/dna-builder

    《二重螺旋》新手开荒指南(校对至 1.6 版本)。含分阶段开荒流程(历练 35 前 / 35~45 / 45~60 / 60 后)、前期角色与武器获取清单、角色获取循环(深渊→周本→密函商店)、魔之楔六大系列与金 Mod 升级口径、减负活动、灾厄武器四把(棘刺绝响 / 无止无休 / 权火将熄 / 血染织羽)的两条刷取路线与 1.6 配队(暗队 /…

    136 GitHub stars~2.1k tokensUpdated yesterday
    Auto-check passed
  • Admin Management Page

    pa001024/dna-builder

    在 dna-builder 里新增一个 /admin 后台管理页(侧边栏菜单 + 路由 + REST 封装 + 统计卡/筛选卡/表格/分页 + 详情弹窗),并在本地实测验证。当需要给后台加新的管理页面、或改动 src/admin/ 下的页面结构时使用。

    136 GitHub stars~890 tokensUpdated yesterday
    Auto-check passed

Works with

Questions about Perf Hotspot Profiling

What does Perf Hotspot Profiling do?

用 V8 CPU profile 定位 JS/TS 热点函数,并用「同进程交替 A/B + best(min) 统计量 + checksum 锚点」的微基准方法安全地做性能优化。当需要优化计算热点、怀疑某函数耗时占比高、想评估某个优化(含 Wasm/SIMD 等加速路径)是否真有收益、或要建立可回归的性能基准时使用。. Perf Hotspot Profiling is an agent skill from pa001024/dna-builder.

How do I install Perf Hotspot Profiling in Claude Code?

Run `npx skills add pa001024/dna-builder --skill perf-hotspot-profiling -a claude-code`. Or copy the skill folder (.agents/skills/perf-hotspot-profiling in pa001024/dna-builder) into .claude/skills/perf-hotspot-profiling in your project. Claude Code loads it when a task matches its description.

How do I install Perf Hotspot Profiling in Codex?

Run `npx skills add pa001024/dna-builder --skill perf-hotspot-profiling -a codex`. Or copy the skill folder (.agents/skills/perf-hotspot-profiling in pa001024/dna-builder) into .agents/skills/perf-hotspot-profiling in your project. Codex loads it when a task matches its description.

Can I use Perf Hotspot Profiling 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 pa001024/dna-builder --skill perf-hotspot-profiling -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/perf-hotspot-profiling, .gemini/skills/perf-hotspot-profiling, .github/skills/perf-hotspot-profiling and .opencode/skills/perf-hotspot-profiling in your project.

What does Perf Hotspot Profiling need to run?

Going by SKILL.md and its folder, Perf Hotspot Profiling needs JavaScript for the scripts in its folder and the command-line tools its instructions call (node and bun). Our summary lists: Node.js.

Does Perf Hotspot Profiling access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Perf Hotspot Profiling 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 Perf Hotspot Profiling use?

Perf Hotspot Profiling is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Perf Hotspot Profiling use?

About 1k tokens (SKILL.md is roughly 4.1k 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 Perf Hotspot Profiling?

Skills that share tags, products or a category with Perf Hotspot Profiling: RuView CLI, API and WASM (ruvnet/RuView, 97k stars), Nginx To Higress Migration (higress-group/higress, 9.5k stars), Update V86 (felixrieseberg/windows95, 24k stars) and Dotlottie Web (LottieFiles/dotlottie-web, 892 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Perf Hotspot Profiling?

pa001024 (a GitHub user) maintains it in pa001024/dna-builder, which has 136 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on October 8, 2026.

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