<bdo id='n3q99'></bdo><ul id='n3q99'></ul>
    <legend id='n3q99'><style id='n3q99'><dir id='n3q99'><q id='n3q99'></q></dir></style></legend>
  • <small id='n3q99'></small><noframes id='n3q99'>

    1. <tfoot id='n3q99'></tfoot>
        <i id='n3q99'><tr id='n3q99'><dt id='n3q99'><q id='n3q99'><span id='n3q99'><b id='n3q99'><form id='n3q99'><ins id='n3q99'></ins><ul id='n3q99'></ul><sub id='n3q99'></sub></form><legend id='n3q99'></legend><bdo id='n3q99'><pre id='n3q99'><center id='n3q99'></center></pre></bdo></b><th id='n3q99'></th></span></q></dt></tr></i><div id='n3q99'><tfoot id='n3q99'></tfoot><dl id='n3q99'><fieldset id='n3q99'></fieldset></dl></div>

        如何加快 g++ 编译时间(使用大量模板时)

        How to speed up g++ compile time (when using a lot of templates)(如何加快 g++ 编译时间(使用大量模板时))

        <legend id='RVZj7'><style id='RVZj7'><dir id='RVZj7'><q id='RVZj7'></q></dir></style></legend>
          <bdo id='RVZj7'></bdo><ul id='RVZj7'></ul>

            <small id='RVZj7'></small><noframes id='RVZj7'>

          1. <tfoot id='RVZj7'></tfoot>
              <tbody id='RVZj7'></tbody>

                • <i id='RVZj7'><tr id='RVZj7'><dt id='RVZj7'><q id='RVZj7'><span id='RVZj7'><b id='RVZj7'><form id='RVZj7'><ins id='RVZj7'></ins><ul id='RVZj7'></ul><sub id='RVZj7'></sub></form><legend id='RVZj7'></legend><bdo id='RVZj7'><pre id='RVZj7'><center id='RVZj7'></center></pre></bdo></b><th id='RVZj7'></th></span></q></dt></tr></i><div id='RVZj7'><tfoot id='RVZj7'></tfoot><dl id='RVZj7'><fieldset id='RVZj7'></fieldset></dl></div>
                • 本文介绍了如何加快 g++ 编译时间(使用大量模板时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这个问题可能有点奇怪,但我怎样才能加快 g++ 编译时间?我的 C++ 代码大量使用 boost 和模板.我已经尽可能多地移出头文件并使用 -j 选项,但编译(和链接)仍然需要很长时间.

                  This question is perhaps somehow odd, but how can I speed up g++ compile time? My C++ code heavily uses boost and templates. I already moved as much as possible out of the headers files and use the -j option, but still it takes quite a while to compile (and link).

                  是否有任何工具可以分析我的代码并指出编译器的瓶颈?或者可以以某种方式分析在我的代码上运行的编译器?这真的很好,因为有时我会有这样的印象,我花了太多时间盯着编译器控制台日志......

                  Are there any tools out there which analyse my code and point out bottle-necks for the compiler? Or can one somehow profile the compiler running on my code? This would be really nice, because sometimes I have the impression, that I spent too much time staring at the compiler console log ...

                  推荐答案

                  对我最有用的:

                  • 在 RAM 文件系统上构建.这在 Linux 上是微不足道的.您可能还希望在 RAM 文件系统上保留一份通用头文件(预编译的或实际的 .h 文件)的副本.
                  • 预编译头.我每个(主要)库(例如 Boost、Qt、stdlib)都有一个.
                  • 在可能的情况下声明而不是包含类.这减少了依赖性,从而减少了更改头文件时需要重新编译的文件数量.
                  • 并行化 make.这通常会根据具体情况有所帮助,但我在全局范围内使用 -j3 进行 make.不过,请确保您的 Makefile 中的依赖关系图正确无误,否则您可能会遇到问题.
                  • 如果您不测试执行速度或代码大小(并且您的计算机足够快,您不必太在意(可能很小)性能损失),请使用 -O0.
                  • 每次保存时都要编译.有些人不喜欢这样,但它可以让您及早发现错误并可以在后台完成,从而减少您在编写完成并准备好测试时必须等待的时间.
                  • Build on a RAM filesystem. This is trivial on Linux. You may want to keep a copy of common header files (precompiled or the actual .h files) on the RAM filesystem as well.
                  • Precompiled headers. I have one per (major) library (e.g. Boost, Qt, stdlib).
                  • Declare instead of include classes where possible. This reduces dependencies, thus reduces the number of files which need to be recompiled when you change a header file.
                  • Parallelize make. This usually helps on a case-by-case basis, but I have -j3 globally for make. Make sure your dependency graphs are correct in your Makefile, though, or you may have problems.
                  • Use -O0 if you're not testing execution speed or code size (and your computer is fast enough for you not to care much about the (probably small) performance hit).
                  • Compile each time you save. Some people don't like this, but it allows you to see errors early and can be done in the background, reducing the time you have to wait when you're done writing and ready to test.

                  这篇关于如何加快 g++ 编译时间(使用大量模板时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is Type(::x); valid?(是类型(::x);有效的?)
                  Difference between an inline function and static inline function(内联函数和静态内联函数的区别)
                  Compilation fails randomly: quot;cannot open program databasequot;(编译随机失败:“无法打开程序数据库)
                  Too many initializers error for a simple array in bcc32(bcc32 中的简单数组的初始值设定项过多错误)
                  No Member named stoi in namespace std(命名空间 std 中没有名为 stoi 的成员)
                  Error using a constexpr as a template parameter within the same class(在同一个类中使用 constexpr 作为模板参数时出错)
                    <tfoot id='NX9pe'></tfoot>
                      <bdo id='NX9pe'></bdo><ul id='NX9pe'></ul>
                        <tbody id='NX9pe'></tbody>
                      <legend id='NX9pe'><style id='NX9pe'><dir id='NX9pe'><q id='NX9pe'></q></dir></style></legend>

                      <i id='NX9pe'><tr id='NX9pe'><dt id='NX9pe'><q id='NX9pe'><span id='NX9pe'><b id='NX9pe'><form id='NX9pe'><ins id='NX9pe'></ins><ul id='NX9pe'></ul><sub id='NX9pe'></sub></form><legend id='NX9pe'></legend><bdo id='NX9pe'><pre id='NX9pe'><center id='NX9pe'></center></pre></bdo></b><th id='NX9pe'></th></span></q></dt></tr></i><div id='NX9pe'><tfoot id='NX9pe'></tfoot><dl id='NX9pe'><fieldset id='NX9pe'></fieldset></dl></div>

                            <small id='NX9pe'></small><noframes id='NX9pe'>