I rewrote a method that used reflection with new code that uses the System.Linq.Expressions classes and the Expression.Compile() method.
As expected, the program is much faster then using reflection.
I also rewrote the same method in plain C# to compare and the code in C# is 4 times faster than the code compiled with Expression.Compile(). In my case, the method is called in a loop, thousands of times.
Note that I have taken out the 1st call from my profiling to make sure I don't measure the time to compile. So I compile the expression once and then call it thousand of times.
Why is code compiled with Expression.Compile() slower than plain C#?