Based on my understanding, the main advantages of creating a program with several compilation units are the reuse of components and reduction of compilation time when small changes are included.
I also think (perhaps erroneously) that there is a penalty associated with this, that functions that are defined in their own compilation units cannot be declared as "inline".
[I understand that this keyword does not actually make the compiler work with the built-in extension functions, but I understand that it gives the compiler more flexibility for optimization, and therefore it is worth including it where possible.]
So far so good?
My real question is that cost-benefit analysis still favors several compilation units when a program solves a complex modeling problem, and is required to continuously iterate through its main loop for several months on a cluster to generate useful output.
Let's say that a program for several compilations takes several minutes to compile, when the same program is re-configured as a single compilation unit, it takes several hours to compile ... if a single compilation unit declares all functions as built-in and, therefore, represents more Opportunities for optimization, it seems reasonable to expect that the execution time may decrease by several percent, and not compensate for the additional compilation time.
Are there any good rules for such situations, or is it highly dependent on the situation?
source share