从Xcode更快地“发布”构建?

Chr*_*ris 5 xcode ios

我对Xcode比较陌生。我们正在测试一个显示传入数据的应用,它需要尽可能快。在其他平台上,我需要从“调试”更改为“发布”,以便启动优化并删除调试代码,这可能对速度产生深远影响。要在快速/发布模式下进行构建,我需要在Xcode中做哪些等效的事情?

(我正在使用谷歌搜索功能,看到很多热门歌曲似乎都在附近,但是我可能会被术语抛弃,我可能需要将其略微降低:))

谢谢您的帮助。

Dav*_* S. 6

第一步是如上所述设置发布的优化级别。这里有很多选择。从clang LLVM编译器手册页(man cc)-(请注意-Os是Release的默认值):

   Code Generation Options
   -O0 -O1 -O2 -O3 -Ofast -Os -Oz -O -O4
       Specify which optimization level to use:

       -O0 Means "no optimization": this level compiles the fastest and
           generates the most debuggable code.

       -O1 Somewhere between -O0 and -O2.

       -O2 Moderate level of optimization which enables most
           optimizations.

       -O3 Like -O2, except that it enables optimizations that take longer
           to perform or that may generate larger code (in an attempt to
           make the program run faster).

       -Ofast
           Enables all the optimizations from -O3 along with other
           aggressive optimizations that may violate strict compliance
           with language standards.

       -Os Like -O2 with extra optimizations to reduce code size.

       -Oz Like -Os (and thus -O2), but reduces code size further.

       -O  Equivalent to -O2.

       -O4 and higher
           Currently equivalent to -O3
Run Code Online (Sandbox Code Playgroud)

您会注意到“ Ofast”选项-非常快,有点冒险。

第二步是考虑是否启用“展开循环”。我已经读到这可以在某些代码中将速度提高15%(以调试为代价,但对于Release版本而言不是问题)。

接下来,考虑是否要构建和使用优化概要文件。有关详细信息,请参阅Apple,但是要点是:

Profile Guided Optimization(PGO)是一种改进应用程序的编译器优化的方法。PGO利用应用程序的特殊工具构建来生成有关最常用代码路径和方法的配置文件信息。然后,编译器使用此配置文件信息将优化工作集中在最常用的代码上,并利用有关程序通常如何表现的额外信息来更好地完成优化工作。

您可以在配置设置-> Apple LLVM 6.0-代码生成->使用优化配置文件下定义配置文件以及是否使用它。


das*_*dom 2

编辑方案以使用发布配置。