]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiDpLib/DpTrace.c
ShellPkg/UefiDpLib: Support dumping cumulative data
[mirror_edk2.git] / ShellPkg / Library / UefiDpLib / DpTrace.c
index cf8200c6f1a235f6dbbc0f0da9653fa7c0f4f746..d17d514bf12ec613bf8019345fa54b98b292080f 100644 (file)
   \r
   @post The SummaryData and CumData structures contain statistics for the\r
         current performance logs.\r
+\r
+  @param[in, out] CustomCumulativeData  A pointer to the cumtom cumulative data.\r
+\r
 **/\r
 VOID\r
 GatherStatistics(\r
-  VOID\r
-)\r
+  IN OUT PERF_CUM_DATA              *CustomCumulativeData OPTIONAL\r
+  )\r
 {\r
   MEASUREMENT_RECORD        Measurement;\r
   UINT64                    Duration;\r
@@ -99,6 +102,20 @@ GatherStatistics(
         CumData[TIndex].MaxDur = Duration;\r
       }\r
     }\r
+\r
+    //\r
+    // Collect the data for custom cumulative data.\r
+    //\r
+    if ((CustomCumulativeData != NULL) && (AsciiStrCmp (Measurement.Token, CustomCumulativeData->Name) == 0)) {\r
+      CustomCumulativeData->Duration += Duration;\r
+      CustomCumulativeData->Count++;\r
+      if (Duration < CustomCumulativeData->MinDur) {\r
+        CustomCumulativeData->MinDur = Duration;\r
+      }\r
+      if (Duration > CustomCumulativeData->MaxDur) {\r
+        CustomCumulativeData->MaxDur = Duration;\r
+      }\r
+    }\r
   }\r
 }\r
 \r
@@ -782,12 +799,14 @@ ProcessGlobal(
   For each record with a Token listed in the CumData array:<BR>\r
      - Update the instance count and the total, minimum, and maximum durations.\r
   Finally, print the gathered cumulative statistics.\r
-  \r
+\r
+  @param[in]    CustomCumulativeData  A pointer to the cumtom cumulative data.\r
+\r
 **/\r
 VOID\r
 ProcessCumulative(\r
-  VOID\r
-)\r
+  IN PERF_CUM_DATA                  *CustomCumulativeData OPTIONAL\r
+  )\r
 {\r
   UINT64                    AvgDur;         // the computed average duration\r
   UINT64                    Dur;\r
@@ -826,4 +845,30 @@ ProcessCumulative(
                  );\r
     }\r
   }\r
+\r
+  //\r
+  // Print the custom cumulative data.\r
+  //\r
+  if (CustomCumulativeData != NULL) {\r
+    if (CustomCumulativeData->Count != 0) {\r
+      AvgDur = DivU64x32 (CustomCumulativeData->Duration, CustomCumulativeData->Count);\r
+      AvgDur = DurationInMicroSeconds (AvgDur);\r
+      Dur    = DurationInMicroSeconds (CustomCumulativeData->Duration);\r
+      MaxDur = DurationInMicroSeconds (CustomCumulativeData->MaxDur);\r
+      MinDur = DurationInMicroSeconds (CustomCumulativeData->MinDur);\r
+    } else {\r
+      AvgDur = 0;\r
+      Dur    = 0;\r
+      MaxDur = 0;\r
+      MinDur = 0;\r
+    }\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), gDpHiiHandle,\r
+                CustomCumulativeData->Name,\r
+                CustomCumulativeData->Count,\r
+                Dur,\r
+                AvgDur,\r
+                MinDur,\r
+                MaxDur\r
+                );\r
+  }\r
 }\r