-optimize-optimize

启用或禁用编译器优化。Enables or disables compiler optimizations.

语法Syntax

-optimize[ + | - ]  

自变量Arguments

术语Term 定义Definition
+ | -+ | - 可选。Optional. -optimize- 选项启用或禁用编译器优化。The -optimize- option disables compiler optimizations. -optimize+ 选项启用优化。The -optimize+ option enables optimizations. 默认情况下,禁用优化。By default, optimizations are disabled.

备注Remarks

编译器优化会使输出文件更智能、更快并且更有效。Compiler optimizations make your output file smaller, faster, and more efficient. 但是,由于优化会导致输出文件中的代码重排,因此 -optimize+ 可能会增加调试的难度。However, because optimizations result in code rearrangement in the output file, -optimize+ can make debugging difficult.

使用 -target:module 为程序集生成的所有模块都必须使用与程序集相同的 -optimize 设置。All modules generated with -target:module for an assembly must use the same -optimize settings as the assembly. 有关详细信息,请参阅 -target (Visual Basic)For more information, see -target (Visual Basic).

可以组合 -optimize-debug 选项。You can combine the -optimize and -debug options.

在 Visual Studio 集成开发环境中设置 -optimizeTo set -optimize in the Visual Studio integrated development environment
1.在 “解决方案资源管理器” 中选择一个项目。1. Have a project selected in Solution Explorer. 在“项目”菜单上,单击“属性” 。On the Project menu, click Properties.

2.单击“编译” 选项卡。2. Click the Compile tab.
3.单击“高级” 按钮。3. Click the Advanced button.
4.修改“启用优化” 复选框。4. Modify the Enable optimizations check box.

示例Example

下面的代码编译 T2.vb,并启用编译器优化。The following code compiles T2.vb and enables compiler optimizations.

vbc t2.vb -optimize  

请参阅See also