How we can take advantage of background just-in-time (JIT) compilation feature of .NET Framework 4.5?

On multi-core processors to improve application performance background just-in-time compilation is available to be utilized optionally. We can achieve this using ProfileOptimization class. ProfileOptimization class improves the startup performance of application domains in applications that require the just-in-time (JIT) compiler by performing background compilation of methods that are likely to be executed, based on profiles created during previous compilations.

using System.Runtime;
class Program
{
static void Main()
{
// Profiles directory must exist.
// "MyProfile" is created.
ProfileOptimization.SetProfileRoot("D:\ProfileCollection\Profiles\");
ProfileOptimization.StartProfile("MyProfile");
}
}

Here, “SetProfileRoot” – Enables optimization profiling for the current application domain, and sets the folder where the optimization profile files are stored. On a single-core computer, the method is ignored and “StartProfile” – Starts just-in-time (JIT) compilation of the methods that were previously recorded in the specified profile file, on a background thread. Starts the process of recording current method use, which later overwrites the specified profile file.
Note: Profile optimization requires a multicore computer. The methods are ignored on other computers.


Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*