# 基准优化循环 (benchmark-optimization-loop)

> 把提速需求转为有边界的测量循环：先测基线，每个变体只验证一个假设，选出通过正确性关卡的最快方案。

- 分类: [性能优化](https://www.myskills.tools/zh/categories/performance/)
- 来源: 社区 · Affaan Mustafa
- 代码仓库: https://github.com/affaan-m/ECC/tree/main/skills/benchmark-optimization-loop (commit 0765f7a)
- SKILL.md: https://github.com/affaan-m/ECC/blob/main/skills/benchmark-optimization-loop/SKILL.md
- 安装命令: `npx skills add affaan-m/ECC --skill benchmark-optimization-loop`
- 许可证: MIT
- 兼容工具: Claude Code, Codex, Cursor, Copilot, OpenCode
- 权限: read-repo ✓, write-files ✓, shell ✓, network ✗
- 状态: 扫描通过
- 规则扫描无法覆盖所有风险，安装前请阅读此技能的 SKILL.md，确认权限后再使用。

## 核心规则

在明确优化对象、正确性关卡、指标、基线和搜索预算之前，不要开始优化。

## 执行阶段

1. **确立基线条件** — 明确要优化的操作、必须保持通过的正确性关卡、指标、当前基线，以及变体数、时间、花费和数据影响的上限。
2. **测量并定位瓶颈** — 测量基线，并根据证据而不是猜测找出瓶颈。
3. **生成并运行变体** — 每个变体只验证一个假设，用相同输入形态运行并记入变体表；递归搜索时把每次运行写入台账，并与此前的胜出者比较。
4. **通过关卡晋升** — 淘汰未通过正确性、安全性或可复现性的变体；只有测试通过、提升可重复且易于回滚时，最快的安全变体才成为默认。
5. **固化并复核** — 把胜出方案写入脚本、命令、测试、配置或文档，重新运行基线和胜出者确认差值，并在总结中给出确切命令和测量结果。

## 权限说明（据 SKILL.md 整理）

| 能力 | 是否需要 | 说明 |
|---|---|---|
| 文件写入 | 需要 | 修改代码，并把胜出方案固化到脚本、测试、配置或文档中。 |
| 命令执行 | 需要 | 运行基线和各变体的基准测试，以及正确性测试。 |
| 网络外发 | 不需要 | 技能未要求访问网络。 |

## SKILL.md 头部信息（YAML）

```yaml
---
name: benchmark-optimization-loop
description: Convert 'make it faster' requests into a bounded measured optimization loop — baseline first, generate one-hypothesis variants, benchmark each against a correctness gate, and promote the fastest safe variant with reproducible commands. Use when asked to speed something up, try many variants, run recursive optimization, benchmark latency/throughput/cost, or pick the best implementation by repeated measured tests.
license: MIT
metadata:
  origin: ECC
tools: Read, Write, Edit, Bash, Grep, Glob
---
```

首页: https://www.myskills.tools/zh/ · URL: https://www.myskills.tools/zh/skills/benchmark-optimization-loop/
