]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/UefiDpLib: Support dumping cumulative data
authorCinnamon Shia <cinnamon.shia@hpe.com>
Thu, 5 Nov 2015 01:59:24 +0000 (01:59 +0000)
committershenshushi <shenshushi@Edk2>
Thu, 5 Nov 2015 01:59:24 +0000 (01:59 +0000)
Add a new option -c to dump cumulative data.
For example:
shell> dp -c
==[ Cumulative ]========
(Times in microsec.)     Cumulative   Average     Shortest    Longest
   Name          Count    Duration    Duration    Duration    Duration
LoadImage:         200     1000000        7000           0      100000
StartImage:        200    20000000       90000           0     7000000
  DB:Start:        200    20000000      100000           0     9000000
DB:Support:     200000      100000           0           0        7000

shell> dp -c DXE
==[ Cumulative ]========
(Times in microsec.)     Cumulative   Average     Shortest    Longest
   Name          Count    Duration    Duration    Duration    Duration
LoadImage:         200     1000000        7000           0      100000
StartImage:        200    20000000       90000           0     7000000
  DB:Start:        200    20000000      100000           0     9000000
DB:Support:     200000      100000           0           0        7000
        DXE          1    30000000    30000000           0    30000000

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cinnamon Shia <cinnamon.shia@hpe.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: El-Haj-Mahmoud Samer <samer.el-haj-mahmoud@hpe.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18728 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiDpLib/Dp.c
ShellPkg/Library/UefiDpLib/DpInternal.h
ShellPkg/Library/UefiDpLib/DpTrace.c
ShellPkg/Library/UefiDpLib/UefiDpLib.uni

index 62a4e7b57782722c3efe0e618c85692b63456cba..4d109d037c1b38f255a03e3cb06c9cd00ad403a8 100644 (file)
@@ -79,6 +79,7 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
 #endif // PROFILING_IMPLEMENTED\r
   {L"-x", TypeFlag},   // -x   eXclude Cumulative Items\r
   {L"-i", TypeFlag},   // -i   Display Identifier\r
+  {L"-c", TypeValue},  // -c   Display cumulative data.\r
   {L"-n", TypeValue},  // -n # Number of records to display for A and R\r
   {L"-t", TypeValue},  // -t # Threshold of interest\r
   {NULL, TypeMax}\r
@@ -164,6 +165,9 @@ ShellCommandRunDp (
   BOOLEAN                   TraceMode;\r
   BOOLEAN                   ProfileMode;\r
   BOOLEAN                   ExcludeMode;\r
+  BOOLEAN                   CumulativeMode;\r
+  CONST CHAR16              *CustomCumulativeToken;\r
+  PERF_CUM_DATA             *CustomCumulativeData;\r
 \r
   StringPtr   = NULL;\r
   SummaryMode = FALSE;\r
@@ -173,6 +177,8 @@ ShellCommandRunDp (
   TraceMode   = FALSE;\r
   ProfileMode = FALSE;\r
   ExcludeMode = FALSE;\r
+  CumulativeMode = FALSE;\r
+  CustomCumulativeData = NULL;\r
 \r
   // Get DP's entry time as soon as possible.\r
   // This is used as the Shell-Phase end time.\r
@@ -210,6 +216,7 @@ ShellCommandRunDp (
 #endif  // PROFILING_IMPLEMENTED\r
   ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");\r
   mShowId     = ShellCommandLineGetFlag (ParamPackage, L"-i");\r
+  CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");\r
 \r
   // Options with Values\r
   CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-n");\r
@@ -243,6 +250,20 @@ ShellCommandRunDp (
   //\r
   InitCumulativeData ();\r
 \r
+  //\r
+  // Init the custom cumulative data.\r
+  //\r
+  CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");\r
+  if (CustomCumulativeToken != NULL) {\r
+    CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));\r
+    CustomCumulativeData->MinDur = 0;\r
+    CustomCumulativeData->MaxDur = 0;\r
+    CustomCumulativeData->Count  = 0;\r
+    CustomCumulativeData->Duration = 0;\r
+    CustomCumulativeData->Name   = AllocateZeroPool (StrLen (CustomCumulativeToken) + 1);\r
+    UnicodeStrToAsciiStr (CustomCumulativeToken, CustomCumulativeData->Name);\r
+  }\r
+\r
   //\r
   // Timer specific processing\r
   //\r
@@ -302,8 +323,10 @@ ShellCommandRunDp (
 ****    !T &&  P  := (2) Only Profile records are displayed\r
 ****     T &&  P  := (3) Same as Default, both are displayed\r
 ****************************************************************************/\r
-  GatherStatistics();\r
-  if (AllMode) {\r
+  GatherStatistics (CustomCumulativeData);\r
+  if (CumulativeMode) {                       \r
+    ProcessCumulative (CustomCumulativeData);\r
+  } else if (AllMode) {\r
     if (TraceMode) {\r
       DumpAllTrace( Number2Display, ExcludeMode);\r
     }\r
@@ -326,7 +349,7 @@ ShellCommandRunDp (
         if ( ! EFI_ERROR( Status)) {\r
           ProcessPeims ();\r
           ProcessGlobal ();\r
-          ProcessCumulative ();\r
+          ProcessCumulative (NULL);\r
         }\r
       }\r
     }\r
@@ -339,6 +362,10 @@ ShellCommandRunDp (
   }\r
 \r
   SHELL_FREE_NON_NULL (StringPtr);\r
+  if (CustomCumulativeData != NULL) {\r
+    SHELL_FREE_NON_NULL (CustomCumulativeData->Name);\r
+  }\r
+  SHELL_FREE_NON_NULL (CustomCumulativeData);\r
 \r
   return SHELL_SUCCESS;\r
 }\r
index 9b8163aaa0f7a7205e42d17acff37769e4e08c71..aa07fea8c21d4512a5cb5236617aa1186a1d716e 100644 (file)
@@ -172,10 +172,13 @@ GetCumulativeItem(
   \r
   @post The SummaryData and CumData structures contain statistics for the\r
         current performance logs.\r
+\r
+  @param[in, out] CustomCumulativeData  The pointer to the custom cumulative data.\r
+\r
 **/\r
 VOID\r
 GatherStatistics(\r
-  VOID\r
+  IN OUT PERF_CUM_DATA              *CustomCumulativeData OPTIONAL\r
   );\r
 \r
 /** \r
@@ -283,11 +286,13 @@ 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
+  @param[in]    CustomCumulativeData  The pointer to the custom cumulative data.\r
   \r
 **/\r
 VOID\r
 ProcessCumulative(\r
-  VOID\r
+  IN PERF_CUM_DATA                  *CustomCumulativeData OPTIONAL\r
   );\r
 \r
 /** \r
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
index 1e5c26ac944e3f626c97c79ac9bb1c4196c70ed3..5bcb4964523aa7839694bc430f57ad27e8f63047 100644 (file)
Binary files a/ShellPkg/Library/UefiDpLib/UefiDpLib.uni and b/ShellPkg/Library/UefiDpLib/UefiDpLib.uni differ