What tools to optimize a C#code?

Asked

Viewed 612 times

5

Code optimizer tools aim at, for example:

- Removal of dead code: removes any dead class, attribute, or method code that is not referenced and used in the project.

- Rewrite and reduce functions: rename what is possible to further increase memory usage performance by APP (smaller labels).

- Apply the so-called inlined Method: place constants and methods on the code line.

Based on this, we can note that the main objective of a code optimizer is to decrease the number of methods invoked, as well as variables and constants to be accessed in memory, consequently improving the performance of the application processing. We can also note that the code optimizer not necessarily worry about the readability of the code, it is important to have a copy of the original not optimized for future queries, as is already common to be done when we obfuscate a particular code. Many of the actions done by a code optimizer go unnoticed in the eyes of programmers, because the goal of the professional is to maintain a readable code applying concepts that may be inefficient in processing.

  • Compilers can perform a light work of optimization of the code, as some obfuscators also do, in the Java language we have the Proguard and the Dexguard, that optimize and obfuscate the code.
  • Dedicated optimization programs can make the service more efficient.

Code optimizers are common in interpreted languages due to the fact that there is no compiler available for such languages. For Javascript we have the Closure Compiler, that is able to reduce the weight of the codes as well as the consumption of resources in the client machine, just rewriting attributes and methods, logically without changing the final result of the classes.

After this brief summary, I would like to know if anyone knows C# tools similar to the one I mentioned here.

  • 1

    Optimize type as?

  • If you take a look at the Closure Compiler page you’ll understand better what I mean by "optimization". But, basically these optimizers make code lighter and more efficient at the processing level.

  • 1

    The C# compiler already does this optimization process. On improving readable code, as quoted by Resharper helps a lot, just be careful that no tool will work miracle, after all these tools only advise.

  • @Gabrielcoletta always needs to question the change and understand why it is being made

  • You want a source improvement counselor or you want something that effectively reduces unnecessary things on target?

  • 2

    I’m half-baked with micro-optimizations. I’m usually more in favor of using a profiler and detect the real bottleneck points, to then propose a suitable solution be peephole or a totally differentiated approach

  • @Jeffersonquesado What is a profiler?

  • 1

    Behold that answer. I believe that in it you find the most appropriate reference for the subject

  • 3

    I closed the question because he asks for certain things, including giving examples of similar tools and the answer given talks about a product that does not offer these things and the AP says that was exactly what he wanted. So he doesn’t know what he wants, didn’t properly describe the problem and an answer that doesn’t match the question will be misleading to many people who read here.

  • 1

    @Maniero I rewrote the question, I hope that now everyone can understand it.

  • 1

    @Danover doesn’t think she has any more salvation. She keeps asking for one thing and the answer delivers another.

  • @Maniero Strange, I read and I could understand that he wanted and then I thought about Resharp. It seems strange, my answer be wrong with so many upvotes. Even worse, the owner himself found the correct answer, it does not seem fair as some fail to understand the question to be closed.

  • 2

    @Luizsantos extenture why it is closed. She says one thing and people understand another. It is the definition of unclear. The votes are because people are getting it wrong and because people like Reshsarper. You have votes for another reason, but that will be dealt with differently.

  • 1

    @Maniero seems subjective to me, but ok. Everything you’re saying seems to be your view of the situation. But, who am I to dispute.

  • 2

    @Maniero However, to be quite honest, this situation is very discouraging and sounds mandatory

  • 3

    @Danover is important that questions lead to creating objective answers and on specific subjects. If the question causes each respondent to choose from what to speak in a blurred manner this question and answer(s) becomes a salad and very difficult to maintain over time. The more specific the question is the better.

  • 1

    I still don’t understand what the question asks exactly. If it is optimization, if it is improvement, and in which of the senses of the question (the answer confuses me even more, although I am not considering it for closure). I do not know if it is broad yet, after clarified.

  • @Luizsantos , here it seems to me that Resharper does a similar work to what Checkstyle does for Java. And Checkstyle is not seen as an optimizer, it doesn’t actually optimize anything. Proguard, on the other hand, changes compiled code to, for example, minify strings and make loading internal classes faster. So I agree with what Maniero said. On positive score, it may be because your answer contributes to the community in some way, but not necessarily that you contribute by solving the direct problem of the question

  • Got it! Guys, the problem is with the word optimize, optimize does not mean just "let faster" write with less words the same function is an "optimization", there is no link of the word "optimization" with speed, as much as Resharp brings speed. Optimize: create more favorable conditions for; make the best possible use of.

  • All right, let’s go. After searching I found a software called Eazfuscator.NET (Gapotchenko), this software meets well the requirements highlighted in the question. In short, it is a substitute for Proguarg (widely used by Java users), but Eazfuscator.NET is aimed at the .NET. platform. Like Proguard, it acts by overshadowing and performing tasks of automatic code optimization. There are other features. On the software page (https://goo.gl/YzT4xt), it is possible to check how the automatic code optimization is performed. It is programs like this that the author of the question is looking for.

Show 15 more comments

1 answer

8

For C#code improvement, my favorite is Resharper. It makes several improvements to code such as:

  • review the quality of the code;
  • eliminate errors and code checks;
  • safely change the code base;
  • instantly traverse the entire solution;
  • enjoy code editing helpers;
  • meet the coding standards.

In my experience I can attest that he has already freed me from:

  • if that would never get in;
  • redundant code;
  • unnecessary references;
  • elegance and readability of the code;
  • rename attributes and classes with greater security.

Super advised.

  • 5

    And there comes the downvote without improvement counseling.

  • 1

    It is exactly tools like this that I seek. I will seek to know you.

  • 1

    @Danover the installation is easy and use even more. Good benefit

  • 1

    @Luizsantos excellent reply, Thank you for that knowledge! + 1

  • 2

    I like Resharper but I don’t use it, Visual Studio already has a bad performance, with Resharper it gets even worse, and the Visual Studio itself has a lot of functions that Resharper has.

  • Thanks guys, I’m happy for the return :) @Danover if you can mark it right by clicking on I’m grateful.

  • @So I consider that all two are worth the weight, but the resharp is already available for the visualstudio code, which is lighter.

  • I recognize the merit of Resharper, Codefx, among others, but I believe it is obligation developer make all request above. We focused on misspelling and then incorrectly used a tool to 'fix' generated errors, sometimes even by technical malpractice. If you are hard working and like good practice, your code will already be produced without the need for such a tool...

  • So Daniel, the idea in the case of the resharp is that you learn according to the corrections, go to educate. It’s not supposed to be a softie

  • 1

    I’m a Resharper fan, too. I particularly use - Resharper - Codemaid (Helps a lot to "clear code") - Ozcode (very good for debugging, see lists in Linq, really worth it)

  • @Danover Since the question has been reopened, there is something I can do to improve it?

  • @Thiagoloureiro I think he is similar to the word broker, helps you improve and see where you miss and prevents slipping mistakes. Perhaps the only downside is the slowness.

  • 1

    @Luizsantos really is a little heavier but it pays.. ,. but if you go deep it has a lot of cool feature, for example the part of Unit Tests helps too much.. facilitates.. the shortcuts (type Ctrl+T) was too good... the "using" without needing "Ctrl + point"... fuck the refactor it makes to help create interface of the classes.. There’s a lot of stuff, it depends a lot on your code style! :)

  • 1

    @Thiagoloureiro I’m all for the resharp

  • 1

    @Luizsantos misinterpreted his answer, I even edited mine, If you like it, try Ozcode.. It’s paid too.. to debug.. is TOP... I’ll write a medium article about it.

  • I’ll try it on.

Show 11 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.