ProfileOptimization 類別


根據先前編譯期間所建立的設定檔,對可能要執行的方法執行背景編譯,改善需要 Just-In-Time (JIT) 編譯器之應用程式的應用程式定義域啟動效能。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.

public ref class ProfileOptimization abstract sealed
public static class ProfileOptimization
type ProfileOptimization = class
Public Class ProfileOptimization



設定檔優化需要多核心電腦。Profile optimization requires a multicore computer. 這些方法會在其他電腦上略過。The methods are ignored on other computers.

每次當您在應用程式域中起始設定檔優化時,就會讀取先前使用期間所建立的設定檔。Each time you initiate profile optimization in an application domain, the profile that was created during the previous use is read. 設定檔中的資訊可用來引導背景編譯,方法是識別在啟動期間最有可能執行的方法。The information in the profile is used to guide background compilation by identifying the methods that are most likely to be executed during startup. 在多核心電腦上,這會增加方法在需要時已編譯的機率,因此主要應用程式執行緒不需要呼叫 JIT 編譯程式。On multicore computers, this increases the chances that a method is already compiled by the time it is needed so that the main application thread does not have to call the JIT compiler.

設定檔會在每次使用時覆寫,因此它一律包含在啟動期間使用哪些方法的最新資訊。The profile file is overwritten on each use, so it always contains the most recent information about which methods are used during startup.

優化設定檔不受限於應用程式域啟動。Optimization profiles are not restricted to application domain startup. 它們可用於任何需要大量使用 JIT 編譯程式的活動。They can be used for any activity that will require heavy use of the JIT compiler. 您可以維護應用程式域的多個設定檔,讓每個這類活動都有自己的設定檔。You can maintain multiple profiles for an application domain so that each such activity has its own profile.

若要在應用程式域中使用優化設定檔,您必須呼叫 SetProfileRoot 方法,並指定儲存設定檔的資料夾。To use optimization profiles in an application domain, you must call the SetProfileRoot method and specify the folder where profiles are stored. 資料夾必須已經存在。The folder must already exist. 若要開始使用設定檔,請呼叫 StartProfile 方法並指定設定檔的檔案名。To begin using a profile, call the StartProfile method and specify the file name of the profile. 如果先前未記錄檔案,則會在第一次使用時建立。If the file was not recorded previously, it is created on first use. 第一次建立設定檔時,沒有任何效能優勢。There is no performance benefit the first time a profile is created.

設定檔優化不會變更執行方法的順序。Profile optimization does not change the order in which methods are executed. 方法不會在背景執行緒上執行;如果某個方法已編譯但從未呼叫,則只會使用它。Methods are not executed on the background thread; if a method is compiled but never called, it is simply not used. 如果設定檔已損毀或無法寫入指定的資料夾 (例如,因為資料夾不存在) ,程式執行會繼續進行,而不會進行優化分析。If a profile file is corrupt or cannot be written to the specified folder (for example, because the folder does not exist), program execution continues without optimization profiling.



啟用對目前應用程式定義域的最佳化程式碼剖析,並設定儲存最佳化設定檔的資料夾。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.


在背景執行緒中,對先前指定設定檔名稱中記錄的方法啟動 just-in-time (JIT) 編譯。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.