Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think, your program runs faster when compiled as a single file because in this case compiler has more information, needed to optimize the code. For example, it can automatically inline some functions, which is not possible in case of separate compilation.</p> <p>To make it faster again, you can try to enable link-time optimizer (or whole program optimizer) with this option: <code>-flto</code>.</p> <hr> <p>If <code>-flto</code> option is not available (and it is available only starting with gcc 4.6) or if you don't want to use it for some reason, you have at least 2 options:</p> <ol> <li>If you split your project only <code>for better organization</code>, you can create a single source file (like <code>all.cxx</code>) and <code>#include</code> all source files (all other <code>*.cxx</code> files) to this file. Then you need to build only this <code>all.cxx</code>, and all compiler optimizations are available again. Or, if you split it also to make compilation incremental, you may prepare 2 build options: incremental build and unity build. First one builds all separate sources, second one - only <code>all.cxx</code>. See more information on this <a href="https://stackoverflow.com/q/543697/1009831">here</a>.</li> <li>You can find functions, that cost you performance after splitting the project, and move them either to the compilation unit, where they are used, or to header file. To do this, start with profiling (see "<a href="https://stackoverflow.com/q/375913/1009831">What can I use to profile C++ code in Linux?</a>"). Further investigate parts of the program, that significantly impact program's performance; here are 2 options: either use profiler again to compare results of incremental and unity builds (but this time you need a sampling profiler, like oprofile, while, an instrumenting profiler, like gprof, most likely, is too heavy for this task); or apply 'experimental' strategy, as described by <a href="https://stackoverflow.com/a/9745937/1009831">gbulmer</a>.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload