← 返回刚才阅读的位置

知识卡片

操作参考卡 · 6075.c.1.g · 生成模型:未记录

按构建用途调节优化

理解等级:中级

构建 profile 是独立的一组编译设置。日常开发重视尽快生成新版本,发布可增加编译成本来换取运行性能。cargo build --release 选择 release,[profile.dev] 中的 opt-level = 1 可以只改变开发构建的一项设置。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 深入 Cargo 与 Crates.io Customizing Builds with Release Profiles · 查看原书依据

      The opt-level setting controls the number of optimizations Rust will apply to your code, with a range of 0 to 3. Applying more optimizations extends compiling time, so if you’re in development and compiling your code often, you’ll want fewer optimizations to compile faster even if the resultant code runs slower. The default opt-level for dev is therefore 0.

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第14章 深入 Cargo 与 Crates.io(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c14.xhtml`,块 0019) - 结论依据:原文用 dev 和 release 的默认优化级别解释编译成本与运行效果的权衡。 - 原始内容:The opt-level setting controls the number of optimizations Rust will apply to your code, with a range of 0 to 3. Applying more optimizations extends compiling time, so if you’re in development and compiling your code often, you’ll want fewer optimizations to compile faster even if the resultant code runs slower. The default opt-level for dev is therefore 0.