Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a huge amount of warnings make C# compile time longer?

We have a big solution with thousands of warnings. Would it take less to compile the solution if I removed all of the warnings (either manually or using a tool)?

I've tried lowering the verbosity level to silent, no use. Maximum verbosity level makes no difference either.

like image 579
naeron84 Avatar asked Mar 02 '11 13:03

naeron84


People also ask

Do warnings slow down compilation?

Also, warnings are output, and sometimes, the IDE or the terminal reading the compiler output may be slowed down if you have a lot of warnings.

Should I ignore compiler warnings?

Warnings must not be ignored. You'd better fix every possible error before starting software testing. You may waste much time and effort to find an error in the debugger, although the compiler gives you an explicit warning about it.

How do I ignore warnings in C?

The short answer: Use "-w" to ignore warnings.

Why is it a good idea to always enable compiler warnings in C?

Not only does handling the warnings make better code, it makes you a better programmer. Warnings will tell you about things that may seem little to you today, but one day that bad habit will come back and bite your head off. Use the correct type, return that value, evaluate that return value.


1 Answers

No, it wouldn't make a significant impact on compilation time. Unlike special tools like FX Cop the compiler itself doesn't perform any complicated checks so in respect to the other logic it has to perform it's insignificant.

What actually may decrease the performance a bit is outputting a very large amount of messages into the console window when compiling from the command line. In this case redirecting the output into a file is a possible improvement.

However, it's a good idea to fix those parts of code that generate warnings. You'll end up with a higher quality code base and mitigate some bugs that would otherwise occur more easily.


Update: Experimental results.

Our codebase has approx. 340 thousand lines of C# code divided into 48 projects in a single solution. Recompiling yields 460 warnings. The compiler's output is 2800 lines longs and occupies nearly 400 kB when redirected into a file.

Compilation speed on a Core i7 920, 9 GB RAM, single 7.2 krpm disk:

  • 47 seconds when outputting into a console window,
  • 43 seconds when redirecting into a file — that is 9.1% decrease in compilation time.

All times are averages from three compilations, with a few initial compiles to force the files into the cache. Note that I didn't do any measurements with warnings turned off.

like image 93
Ondrej Tucny Avatar answered Oct 09 '22 21:10

Ondrej Tucny