Michael Pidde => { Programmer(); }

Compilation Speed

I undertook an exercise in code structure tonight to see if I could significantly decrease the compile time of Boreal Darkness. Since I'm not a long-time C++ programmer I don't have a baseline understanding of how bad or good compile times can be.

With the old code structure and build process, an average build start time could be 19:56:52.77 ending at 19:57:16.58 which is ~24 seconds overall. I removed the asset and static DLLs copying to the build directory. With the new code structure and build process, I've trimmed this time down to ~8 seconds (ex: 20:02:35.12 to 20:02:42.70).

I started by consolidating core header includes that are used all over into a single Boreal.h file. This will constitute the core "engine" which gets bootstrapped in (very roughly at this juncture). That header gets included only in main.cpp, which is the only file listed in the compile command. All other pertinent CPP files are included in main.cpp. This may be heresy to C++ programmers, but until I find a better way to speed up compilation without having to do other crazy things, the proof is in the pudding.

I plan on continuing to work on this process more and research the possibilities. I have to admit that I'm intrigued by how Handmade Hero compiles incredibly fast and he can recompile on the fly in order to change debug settings (e.g. episode 192). It doesn't seem like there should be any reason that a few-thousand line program needs to take half a minute to compile, much less 8 seconds right now. But I'll take the 2/3 decrease in time that I've already achieved.

Code Stats

Language                     files          blank        comment           code
C++                             20            237             89           1926
C/C++ Header                    35             92             29           1110
JavaScript                       2             80             35            559
PHP                              4             17             16            106
JSON                             4              0              0             85
DOS Batch                        3              5              9             21
Bourne Shell                     1              0              0              5
SUM:                            69            431            178           3812