I'm working on our continuous integration system, and I'm interested in simulating our systems handling of unexpectedly long compile times. Is there any way to cause the compilation to take a long time to complete? Or perhaps force it into some sort of loop that would take a large amount of time to compile? I'm looking for something as easy as Thread.Sleep() only on the compilation rather than the execution.
How about using preprocessor directives?
Any ideas?
Use a more modern compiler. Compilers are getting better all the time. They are getting efficient at doing better optimizations and generating better code than ever before all the while taking less time for compilation. Changing the older compiler to a newer one will improve C++ compile time for sure.
Every single compilation unit requires hundreds or even thousands of headers to be (1) loaded and (2) compiled. Every one of them typically has to be recompiled for every compilation unit, because the preprocessor ensures that the result of compiling a header might vary between every compilation unit.
A compiler takes the program code (source code) and converts the source code to a machine language module (called an object file). Another specialized program, called a linker, combines this object file with other previously compiled object files (in particular run-time modules) to create an executable file.
A default compile takes about 0.4 seconds of processor time.
Here's an MSBuild sleep task that should do the trick. Call it from BeforeBuild target in your .csproj file, or wherever is appropriate for your need.
MSBuild Community Tasks also has a Sleep task, so go with that if you need to use some of their other tasks, which I've found very useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With