Created
April 9, 2017 10:05
-
-
Save devlights/028b7e2e225c1bc0bbfc9cd262fa7530 to your computer and use it in GitHub Desktop.
System.Runtime.ProfileOptimizationクラスのサンプルです。
Monoには存在しない。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Sazare.Samples | |
| { | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Runtime; | |
| using Sazare.Common; | |
| #region MulticoreJITSamples-01 | |
| /// <summary> | |
| /// マルチコアJITのサンプルです. | |
| /// </summary> | |
| [Sample] | |
| public class MulticoreJITSamples01 : Sazare.Common.IExecutable | |
| { | |
| public void Execute() | |
| { | |
| // | |
| // .NET 4.5よりマルチコアJITが搭載されている. | |
| // 文字通り、マルチコア構成の環境にて並列でJITを行う機能である。 | |
| // これにより、アプリケーションの動きに先行して、必要となるメソッドのJITが | |
| // 行われる可能性が高くなり、結果的にアプリケーションのパフォーマンスが上がるとのこと。 | |
| // | |
| // マルチコアJITは、ASP.NET 4.5とSilverlight5では | |
| // 既定で有効となっているが、デスクトップアプリケーションでは | |
| // デフォルトで有効になっていない。 | |
| // | |
| // 有効になっていない理由は、この機能を利用するためには | |
| // プロファイリング処理が必須であり、プロファイルデータを保存 | |
| // することが条件であるため。デスクトップアプリケーションでは | |
| // フレームワーク側が、プロファイルデータをどこに保存するべきなのかを | |
| // 判断できないため、手動で実行するようになっている。 | |
| // | |
| // 参考URL: | |
| // http://blogs.msdn.com/b/dotnet/archive/2012/10/18/an-easy-solution-for-improving-app-launch-performance.aspx | |
| // http://stackoverflow.com/questions/12965606/why-is-multicore-jit-not-on-by-default-in-net-4-5 | |
| // http://msdn.microsoft.com/ja-jp/magazine/hh882452.aspx | |
| // | |
| // マルチコアJITを有効にするには、System.Runtime.ProfileOptimizationクラスの | |
| // 以下のstaticメソッドを呼び出すだけである。 | |
| // ・SetProfileRoot | |
| // ・StartProfile | |
| // 上記メソッドは、アプリケーションのエントリポイントで呼び出す方がよい。 | |
| // | |
| // | |
| // マルチコアJITを有効にする. | |
| // プロファイルデータ格納場所は、アプリ実行フォルダ. | |
| // プロファイルデータのファイル名は、App.JIT.Profileとする。 | |
| // | |
| ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory); | |
| ProfileOptimization.StartProfile("App.JIT.Profile"); | |
| } | |
| } | |
| #endregion | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment