rust-library-performance-features

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Rust Library Performance Features

Rust库性能特性

Use this skill when a Rust library needs performance work that can be measured and shipped behind clear Cargo feature boundaries.
当Rust库需要可量化的性能优化工作,且该优化需封装在清晰的Cargo特性边界后交付时,可使用此技能。

Core Workflow

核心工作流

  1. Define the library operation and input sizes that matter to downstream users.
  2. Add or repair benchmarks before optimizing.
  3. Compare baseline and candidate implementations with the same harness.
  4. Use Cargo features for optional capabilities and dependencies.
  5. Test the feature matrix, including default features disabled.
  6. Document performance claims with scope and measurement commands.
  1. 明确对下游用户至关重要的库操作和输入规模。
  2. 在优化前添加或修复基准测试。
  3. 使用同一测试框架对比基准实现与候选实现。
  4. 利用Cargo特性来管理可选功能和依赖项。
  5. 测试特性矩阵,包括禁用默认特性的场景。
  6. 记录性能声明,包含适用范围和测量命令。

Read Next

后续阅读

TaskLoad
Add benchmarks or optimize a hot path
guidelines.md
,
workflows/benchmark-feature-matrix.md
Review Cargo features and optional dependencies
references/performance-feature-patterns.md
Validate performance claims before release
references/performance-feature-patterns.md
任务加载路径
添加基准测试或优化热点路径
guidelines.md
,
workflows/benchmark-feature-matrix.md
审核Cargo特性与可选依赖项
references/performance-feature-patterns.md
发布前验证性能声明
references/performance-feature-patterns.md

Source Notes

来源说明

Guidance is transformed and paraphrased from Herbert Wolverson, Advanced Hands-On Rust, especially Chapters 2 and 3 on creating, testing, optimizing, benchmarking, and feature-gating a library. Examples are original skeletons.
本指南改编自Herbert Wolverson所著的《Advanced Hands-On Rust》,尤其参考了书中第2章和第3章关于库的创建、测试、优化、基准测试以及特性门控的内容。示例为原创框架。