How many unreachable functions and methods affect performance in C #

Possible duplicate:
Effect of unused methods and properties on a library or executable file

I am working on a project in which I am using an existing development application, and I am performing customization in accordance with the requirements of the project. When setting up, I found many functions and methods that are useless in the current project. I’m thinking about saving this code as it is and only tuning in the required code, but I’m not very sure how this unreachable code will affect the performance of my application. Should I keep them as is or delete them?

EDIT: In my application, the DataInteraction assembly contains 20 methods, of which 2 are used, and the rest are not, but according to my knowledge, if any of the assembly methods is called, than the entire assembly is loaded into memory, and if so, than I feel that this will affect performance.

+4
source share
4 answers

It just inflates the executable size .. if the methods do not call, they are not JIT'd ..

.. you should definitely consider cleaning them. What is their use? They inflate code and make code use worse.

I also agree with John's comment.

EDIT:

In response to a comment about unclaimed methods:

Unused methods in ILSpy

The answer is no, this is not the case (compiled for Release).

+4
source

Unused code has very little effect on performance. However, the impact on maintainability is another topic. Code must be managed first for ease of maintenance, readability, and understanding. If the code is not used and is unlikely to be used, get rid of it, as it will reduce all three of these measures.

Address effectiveness, when and where you know that you have problems, because you can measure them.

+1
source

When Microsoft released Visual Studio 2012, they include features in which you can analyze your code to help you optimize it. Some important rules:

CA1804: remove unused locales. Unused local variables and unnecessary assignments increase assembly size and reduce performance.

CA1809: Avoid excessive local area networks. A general performance optimization is to store a value in the processor register instead of memory, which is called "value registration". To increase the probability of registering all local variables, limit the number of local variables to 64.

It’s good to optimize your code, including getting rid of unused code, but before you do this, there is always a backup. Some unused code may be used again in the future. To find out what else you can do to optimize your code for better performance. visit the following links.

http://msdn.microsoft.com/en-us/library/ms182260.aspx

http://msdn.microsoft.com/en-us/library/dd380629.aspx

http://msdn.microsoft.com/en-us/library/ms182125.aspx

http://msdn.microsoft.com/en-us/library/ms182324.aspx

+1
source

This post should answer your question. The compiler should ignore any unused statements. Even if you use part of the namespace, which is why it is used at compile time, it will simply copy it and will only affect the size of your lib / exe, not the performance.

0
source

All Articles