共用方式為


3.設定檔定義

Windows Performance Recorder (WPR) 錄製設定檔會儲存在副檔名為 .wprp 的 XML 檔案中。 設定檔定義 會將收集器和提供者定義結合在 .wprp 檔案中。

Profiles

您可以使用參考收集器和提供者定義 XML 標籤的 XML 標籤來定義 WPR 設定檔 (<Profile> … </Profile> ,這些標記是在相同的 .wprp 檔案中定義,或是在另一個 .wprp 檔案中使用繼承。 每個設定檔定義 XML 標籤都必須具有下列屬性:

  • 識別碼:設定檔定義的唯一識別碼。 使用下列設定檔識別碼建構:

    < 名稱> 。 <DetailLevel> 。 <LoggingMode> 。

  • 名稱:指出設定檔名稱的字串。

  • DetailLevel:屬性,指定設定檔定義是用於計時追蹤 (Light) 還是分析追蹤 (詳細資訊) 。

  • LoggingMode:屬性,指定設定檔會將事件記錄到循序檔案或迴圈記憶體緩衝區。 所有設定檔都必須在相同的 .wprp 檔案中同時有檔案和記憶體版本。

  • 描述:使用者看到之設定檔的文字描述。

WPR 支援每個 .wprp 檔案的檔案和記憶體記錄模式的效能記錄,但 開啟/關閉設定檔除外。 您必須登入/關閉設定檔到檔案,但您必須同時定義檔案和記憶體版本。 因為單一設定檔定義只能支援一個記錄模式,所以 .wprp 檔案中可以有兩個或四個設定檔定義,每個記錄模式和詳細資料層級的組合都有一個。 單一 .wprp 檔案中的所有設定檔定義都必須具有相同 的 Name 屬性。

< 名稱> 。 <DetailLevel> 。 <LoggingMode>

下列程式碼範例顯示 Example1.wprp。 此檔案包含兩個設定檔定義。 省略號 (...) 代表設定檔的本文。

<Profile
  Id="Example1.Verbose.File"
  Name="Example1"
  DetailLevel="Verbose"
  LoggingMode="File"
  Description="Example1 profile">
…
</Profile>
<Profile
  Id="Example1.Verbose.Memory"
  Name="Example1"
  DetailLevel="Verbose"
  LoggingMode="Memory"
  Description="Example1 profile">
…
</Profile>

下列程式碼範例顯示 Example2.wprp。 此檔案包含四個設定檔定義。 省略號 (...) 代表設定檔的本文。

<Profile
  Id="Example2.Verbose.File"
  Name="Example2"
  DetailLevel="Verbose"
  LoggingMode="File"
  Description="Example2 profile">
…
</Profile>
<Profile
  Id="Example2.Light.File"
  Name="Example2"
  DetailLevel="Light"
  LoggingMode="File"
  Description="Example2 profile">
…
</Profile>
<Profile
  Id="Example2.Verbose.Memory"
  Name="Example2"
  DetailLevel="Verbose"
  LoggingMode="Memory"
  Description="Example2 profile">
…
</Profile>
<Profile
  Id="Example2.Light.Memory"
  Name="Example2"
  DetailLevel="Light"
  LoggingMode="Memory"
  Description="Example2 profile">
…
</Profile>

Collectors 元素

Collectors元素包含先前定義的系統和事件收集器的參考。 SystemCollectorIdEventCollectorId元素會識別這些收集器。

每個 SystemCollectorIdEventCollectorId 元素都包含必要 Value 屬性,指定要使用之收集器的 Id 屬性。 每個 SystemCollectorIdEventCollectorId 元素也都包含 SystemProviderIdEventCollectorId 元素的清單。 這些元素具有類似的語法。 不過,這些元素是指先前定義的系統和事件提供者。

您也可以在設定檔定義內定義收集器和提供者。

設定檔定義範例

下列程式碼範例顯示完整的設定檔定義。

<Profile
  Id="Example.Light.File"
  Name="Example"
  DetailLevel="Light"
  LoggingMode="File"
  Description="Example profile">
  <ProblemCategories> 
    <ProblemCategory
      Value="First Level Triage"/>
  </ProblemCategories> 
  <Collectors> 
    <SystemCollectorId
      Value="WPRSystemCollector">
      <!--Enables the system provider for this system collector. --> 
      <SystemProviderId
        Value="system-provider"/>
    </SystemCollectorId> 
    <EventCollectorId
      Value="WPREventCollector">
      <EventProviders> 
      <!--Enables two event providers for this event collector. --> 
        <EventProviderId
          Value="Win32K-provider"/>
        <EventProviderId
          Value="Search-Core-provider"/>
      </EventProviders> 
    </EventCollectorId> 
  </Collectors>
</Profile>

撰寫錄製設定檔

2.系統和事件提供者定義

記錄模式

詳細等級

ProblemCategories

SystemCollectorId

HeapEventProviderId