Automatic Code Optimization

Eazfuscator.NET applies code optimizations to deliver the best performance to your applications. .NET compilers such as C#, VB.NET, F# and JIT already do a pretty decent job in this area. And Eazfuscator.NET extends it even further with high-level optimizations for .NET applications.

High-level optimization is a fresh trend in optimization technology. Eazfuscator.NET is the first tool that delivered this technology to the wide .NET user base. The best way to briefly describe high-level optimization is to start thinking as developer thinks: we all know that there are some methods and code patterns which are faster than others.

What Eazfuscator.NET does is this: it finds the slow code and swaps it with faster one. Eazfuscator.NET uses a preciously brewed knowledge base of common and efficient code patterns that you can meet in every .NET application.

At first glance, high-level optimization is very similar to a well-known peephole optimization approach. But the main difference is that the classical peephole optimization works only on a small window of target machine instructions, while high-level optimization works at the application-wide level and considers control and data flows as well as the sacred knowledge about specific frameworks such as LINQ, MEF and others.

Let’s take a look at example.

Example 1. The slow code

    [Flags] 
    enum RunOptions 
    { 
        None = 0x00, 
        PrepareDatabase = 0x01, 
        SkipPlugins = 0x02 
    } 
  
    class Engine 
    { 
        public void Run(RunOptions options) 
        { 
            if (options.HasFlag(RunOptions.PrepareDatabase)) 
                InitializeDatabase(); 
            // ... 
        } 
  
        // ... 
    } 

The code above uses Enum.HasFlag method to check whether PrepareDatabase flag is set. Being sweet in syntax, the code has astonishingly bad performance due to boxing operations that are invisibly generated by C# compiler.

Eazfuscator.NET comes to the rescue:

Example 2. The fast code. Produced by Eazfuscator.NET after optimizing the slow code

    public void Run(RunOptions options) 
    { 
        if ((options & RunOptions.PrepareDatabase) == RunOptions.PrepareDatabase) 
            InitializeDatabase(); 
        // ... 
    }

As you can see, Eazfuscator.NET emitted a functionally equivalent code. The result of optimization is 500x speed improvement of condition evaluation over original slow code.

Eazfuscator.NET carefully performs a bunch of other performance optimizations delivering the great speed experience to your customers. Speed is the part of wow effect and this is why we appreciate it so much at Eazfuscator.NET.

The optimization is on by default and works behind the scenes during obfuscation.

Explore other features