C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Note: ProfileOptimization requires a computer with at least 2 logical processor cores.
Note 2: If a single-core computer runs a ProfileOptimization program, the methods have no effect. They are silently ignored.
And: The StartProfile method specifies both the name of the profile file, and that profiling should begin.
Caution: To end profiling, the program must be exited normally—it cannot just be terminated.
C# program that uses ProfileOptimization
using System.Runtime;
class Program
{
static void Main()
{
// Profiles directory must exist.
// ... "profile" is created.
ProfileOptimization.SetProfileRoot("C:\\profiles\\");
ProfileOptimization.StartProfile("profile");
}
}
Then: When a profiled program starts up, the .NET Framework reads in the profile. It then compiles those methods on a separate thread.
And: This relieves the pause due to JIT-compilation for those needed methods. This reduces startup time.
Results: The program runs approximately 10% faster with a profile than without a profile.
ProfileOptimization results
Before: 1074 ms
1078 ms
1076 ms
After: 964 ms
962 ms
961 ms