hyperfine-benchmarking

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

hyperfine-benchmarking

hyperfine基准测试

Benchmark CLI commands with reproducible methodology instead of one-off
time
output.
使用可复现的方法对CLI命令进行基准测试,替代一次性的
time
输出。

When to use this skill

何时使用此Skill

  • Compare two or more command variants (
    tool-a
    vs
    tool-b
    )
  • Validate performance impact before/after script changes
  • Attach benchmark evidence to PRs
  • 比较两种或多种命令变体(
    tool-a
    vs
    tool-b
  • 在脚本变更前后验证性能影响
  • 为PR添加基准测试证据

Instructions

操作步骤

  1. Confirm tool availability.
  2. Keep input/workdir/environment stable across compared commands.
  3. Run warmups and enough runs for stable variance.
  4. Export JSON/markdown outputs for review.
  5. Summarize relative speedup + risk notes.
  1. 确认工具可用性。
  2. 在对比命令之间保持输入/工作目录/环境稳定。
  3. 运行预热操作,并执行足够次数的运行以获得稳定的方差。
  4. 导出JSON/Markdown输出以供审阅。
  5. 总结相对加速比 + 风险说明。

Examples

示例

Availability check

可用性检查

bash
hyperfine --version
bash
hyperfine --version

Two-command comparison

双命令对比

bash
hyperfine \
  --warmup 3 \
  --min-runs 10 \
  'cmd_a --with flags' \
  'cmd_b --with flags'
bash
hyperfine \
  --warmup 3 \
  --min-runs 10 \
  'cmd_a --with flags' \
  'cmd_b --with flags'

Parameter sweep

参数扫描

bash
hyperfine \
  --warmup 3 \
  --parameter-list mode fast,balanced,thorough \
  'mytool --mode {mode} input.txt'
bash
hyperfine \
  --warmup 3 \
  --parameter-list mode fast,balanced,thorough \
  'mytool --mode {mode} input.txt'

Export artifacts

导出成果物

bash
hyperfine \
  --warmup 3 \
  --min-runs 10 \
  --export-json benchmark.json \
  --export-markdown benchmark.md \
  'cmd_a' 'cmd_b'
bash
hyperfine \
  --warmup 3 \
  --min-runs 10 \
  --export-json benchmark.json \
  --export-markdown benchmark.md \
  'cmd_a' 'cmd_b'

Best practices

最佳实践

  • Prefer relative speedup and confidence ranges over single-run claims.
  • Do not compare commands with different semantics unless outputs are normalized.
  • If variance is high, increase runs or reduce background noise before concluding.
  • Record dataset/path and exact command strings in PR text.
  • 优先使用相对加速比和置信区间,而非单次运行的结果。
  • 除非输出已标准化,否则不要比较语义不同的命令。
  • 如果方差较高,在得出结论前增加运行次数或减少背景噪音。
  • 在PR文本中记录数据集/路径和精确的命令字符串。

References

参考资料