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 make开发者_如何学Cs no difference either.
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.
You should not silent the warnings. Most of the warnings indicates problems with your code. You should look into your code and fix them.
Processing all the warning should cost compile time (The compieler need to send the warnings to visual studio, more warnings should mean more output data. But I don't know how big the impact is). But if you fix the warnings you propably fix bugs, too.
Silencing the warnings has no effect on compilation time. Silencing affects whether the warnings are reported, not whether the compiler checks all rules or whether it generates errors/warnings.
As Fox32 said, silencing the warnings is not a good idea. If you have too many of them somethings is seriously wrong with the code. This will also make compilation marginally faster as the compiler will have to handle fewer edge cases.
精彩评论