[Mono-dev] JIT Optimisations

Alan McGovern alan.mcgovern at gmail.com
Sun Mar 25 09:45:55 EDT 2007


The following two constructs should be identical from an IL point of view,
yet the first performs far faster than the other:

if(condition)
    return X;

return Y;

as compared to

return (condition) ? X : Y;

>From my benchmarking, the first method is approximately 8% faster. Which
shouldn't really be happening. The following code should be identical to the
first construct mentioned above, yet it generates different IL to both the
above.

if(condition)
   return x;
else
    return y;

So all three of these constructs do the *exact* same thing, yet each forms
different IL, some of which is faster than the other. Just some food for
thought ;)

Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070325/95277c21/attachment.html 


More information about the Mono-devel-list mailing list