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. Eazfuscator.NET extends it even further with high-level optimizations.

High-level optimization is a relatively new optimization technology. Eazfuscator.NET was the first tool that delivered it 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 a faster equivalent. Eazfuscator.NET uses a preciously brewed knowledge base of common and efficient code patterns that you can find in many .NET applications.

At first glance, high-level optimization is very similar to a well-known peephole optimization approach. 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 in order to check whether PrepareDatabase flag is set. While being syntactically pleasant, the code has astonishingly bad performance due to two invisible boxing operations emitted 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 code.

Eazfuscator.NET carefully performs a bunch of other performance optimizations helping to deliver the best experience to your customers.

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

â–¶ Explore other features
â–¶ Give it a try