C++ Options (Optimize Code)

本文详细介绍了编译器中的各种优化选项,包括为获得最小大小而优化代码的/O1,为获得最高速度而优化代码的/O2,控制内联函数展开的/Ob等。这些选项有助于开发者根据实际需求调整代码的优化方向。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The /O options control various optimizations that help you create code for maximum speed or minimum size.

  • /O1 optimizes code for minimum size. /O1 为获得最小大小而优化代码。

  • /O2 optimizes code for maximum speed. 为获得最高速度而优化代码。

  • /Ob controls inline function expansion. 控制内联函数展开。

  • /Od disables optimization, speeding compilation and simplifying debugging. 禁用优化,从而加快编译并简化调试。

  • /Og enables global optimizations. 启用全局优化。

  • /Oi generates intrinsic functions for appropriate function calls. 为适当的函数调用生成内部函数。

  • /Os tells the compiler to favor optimizations for size over optimizations for speed. 通知编译器优选大小优化而非速度优化。

  • /Ot (a default setting) tells the compiler to favor optimizations for speed over optimizations for size. (默认设置)通知编译器优选速度优化而非大小优化。

  • /Ox selects full optimization. 选择完全优化。

  • /Oy suppresses the creation of frame pointers on the call stack for quicker function calls. 取消在调用堆栈上创建框架指针,以更快地进行函数调用。

Optimized C++: Proven Techniques for Heightened Performance 1st Edition Paperback: 388 pages Publisher: O'Reilly Media; 1 edition (May 23, 2016) Language: English ISBN-10: 1491922060 ISBN-13: 978-1491922064 In today’s fast and competitive world, a program’s performance is just as important to customers as the features it provides. This practical guide teaches developers performance-tuning principles that enable optimization in C++. You’ll learn how to make code that already embodies best practices of C++ design run faster and consume fewer resources on any computer—whether it’s a watch, phone, workstation, supercomputer, or globe-spanning network of servers. Author Kurt Guntheroth provides several running examples that demonstrate how to apply these principles incrementally to improve existing code so it meets customer requirements for responsiveness and throughput. The advice in this book will prove itself the first time you hear a colleague exclaim, “Wow, that was fast. Who fixed something?” Locate performance hot spots using the profiler and software timers Learn to perform repeatable experiments to measure performance of code changes Optimize use of dynamically allocated variables Improve performance of hot loops and functions Speed up string handling functions Recognize efficient algorithms and optimization patterns Learn the strengths—and weaknesses—of C++ container classes View searching and sorting through an optimizer’s eye Make efficient use of C++ streaming I/O functions Use C++ thread-based concurrency features effectively
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值