]> git.proxmox.com Git - mirror_edk2.git/commitdiff
PerformancePkg/Dp_App: Support dumping cumulative data
authorCinnamon Shia <cinnamon.shia@hpe.com>
Tue, 10 Nov 2015 04:57:14 +0000 (04:57 +0000)
committerlzeng14 <lzeng14@Edk2>
Tue, 10 Nov 2015 04:57:14 +0000 (04:57 +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: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18762 6f19259b-4bc3-4df7-8a09-765794883524

PerformancePkg/Dp_App/Dp.c
PerformancePkg/Dp_App/DpInternal.h
PerformancePkg/Dp_App/DpStrings.uni
PerformancePkg/Dp_App/DpTrace.c

index 57144a8fb87467315cf54756a2cab8ed5bdbaabe..0f61b9daaaab7f27cbf2903a82379fc9976e0393 100644 (file)
@@ -14,6 +14,7 @@
   timer information to calculate elapsed time for each measurement.\r
  \r
   Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -81,6 +82,7 @@ PARAM_ITEM_LIST  ParamList[] = {
 #endif\r
   {STRING_TOKEN (STR_DP_OPTION_LX), TypeFlag},   // -x   eXclude Cumulative Items\r
   {STRING_TOKEN (STR_DP_OPTION_LI), TypeFlag},   // -i   Display Identifier\r
+  {STRING_TOKEN (STR_DP_OPTION_LC), TypeValue},  // -c   Display cumulative data.\r
   {STRING_TOKEN (STR_DP_OPTION_LN), TypeValue},  // -n # Number of records to display for A and R\r
   {STRING_TOKEN (STR_DP_OPTION_LT), TypeValue}   // -t # Threshold of interest\r
   };\r
@@ -138,6 +140,7 @@ ShowHelp( void )
   PrintToken (STRING_TOKEN (STR_DP_HELP_THRESHOLD));\r
   PrintToken (STRING_TOKEN (STR_DP_HELP_COUNT));\r
   PrintToken (STRING_TOKEN (STR_DP_HELP_ID));\r
+  PrintToken (STRING_TOKEN (STR_DP_HELP_CUM_DATA));\r
   PrintToken (STRING_TOKEN (STR_DP_HELP_HELP));\r
   Print(L"\n");\r
 }\r
@@ -168,7 +171,26 @@ DumpStatistics( void )
   FreePool (StringPtrUnknown);\r
 }\r
 \r
-/** \r
+/**\r
+  Initialize the cumulative data.\r
+\r
+**/\r
+VOID\r
+InitCumulativeData (\r
+  VOID\r
+  )\r
+{\r
+  UINTN                             Index;\r
+\r
+  for (Index = 0; Index < NumCum; ++Index) {\r
+    CumData[Index].Count = 0;\r
+    CumData[Index].MinDur = PERF_MAXDUR;\r
+    CumData[Index].MaxDur = 0;\r
+    CumData[Index].Duration = 0;\r
+  }\r
+}\r
+\r
+/**\r
   Dump performance data.\r
   \r
   @param[in]  ImageHandle     The image handle.\r
@@ -203,6 +225,9 @@ InitializeDp (
   BOOLEAN                   TraceMode;\r
   BOOLEAN                   ProfileMode;\r
   BOOLEAN                   ExcludeMode;\r
+  BOOLEAN                   CumulativeMode;\r
+  CONST CHAR16              *CustomCumulativeToken;\r
+  PERF_CUM_DATA             *CustomCumulativeData;\r
 \r
   EFI_STRING                StringDpOptionQh;\r
   EFI_STRING                StringDpOptionLh;\r
@@ -218,6 +243,7 @@ InitializeDp (
   EFI_STRING                StringDpOptionLn;\r
   EFI_STRING                StringDpOptionLt;\r
   EFI_STRING                StringDpOptionLi;\r
+  EFI_STRING                StringDpOptionLc;\r
   \r
   SummaryMode     = FALSE;\r
   VerboseMode     = FALSE;\r
@@ -226,6 +252,8 @@ InitializeDp (
   TraceMode       = FALSE;\r
   ProfileMode     = FALSE;\r
   ExcludeMode     = FALSE;\r
+  CumulativeMode = FALSE;\r
+  CustomCumulativeData = NULL;\r
 \r
   StringDpOptionQh = NULL;\r
   StringDpOptionLh = NULL;\r
@@ -241,6 +269,7 @@ InitializeDp (
   StringDpOptionLn = NULL;\r
   StringDpOptionLt = NULL;\r
   StringDpOptionLi = NULL;\r
+  StringDpOptionLc = NULL;\r
   StringPtr        = NULL;\r
 \r
   // Get DP's entry time as soon as possible.\r
@@ -289,6 +318,7 @@ InitializeDp (
       StringDpOptionLn = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LN), NULL);\r
       StringDpOptionLt = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LT), NULL);\r
       StringDpOptionLi = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LI), NULL);\r
+      StringDpOptionLc = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LC), NULL);\r
       \r
       // Boolean Options\r
       // \r
@@ -303,6 +333,7 @@ InitializeDp (
 #endif  // PROFILING_IMPLEMENTED\r
       ExcludeMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLx);\r
       mShowId     =  ShellCommandLineGetFlag (ParamPackage, StringDpOptionLi);\r
+      CumulativeMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLc);\r
 \r
       // Options with Values\r
       CmdLineArg  = ShellCommandLineGetValue (ParamPackage, StringDpOptionLn);\r
@@ -331,6 +362,20 @@ InitializeDp (
 #endif  // PROFILING_IMPLEMENTED\r
       }\r
 \r
+  //\r
+  // Init the custom cumulative data.\r
+  //\r
+  CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, StringDpOptionLc);\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
@@ -392,8 +437,10 @@ InitializeDp (
 ****    !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
@@ -418,7 +465,7 @@ InitializeDp (
             if ( ! EFI_ERROR( Status)) {\r
               ProcessPeims (     );\r
               ProcessGlobal (    );\r
-              ProcessCumulative ();\r
+              ProcessCumulative (NULL);\r
             }\r
           }\r
         }\r
@@ -432,6 +479,7 @@ InitializeDp (
     }\r
   }\r
 \r
+  //\r
   // Free the memory allocate from HiiGetString\r
   //\r
   ListIndex = 0;\r
@@ -455,9 +503,15 @@ InitializeDp (
   SafeFreePool (StringDpOptionLn);\r
   SafeFreePool (StringDpOptionLt);\r
   SafeFreePool (StringDpOptionLi);\r
+  SafeFreePool (StringDpOptionLc);\r
   SafeFreePool (StringPtr);\r
   SafeFreePool (mPrintTokenBuffer);\r
 \r
+  if (CustomCumulativeData != NULL) {\r
+    SafeFreePool (CustomCumulativeData->Name);\r
+  }\r
+  SafeFreePool (CustomCumulativeData);\r
+\r
   HiiRemovePackages (gHiiHandle);\r
   return Status;\r
 }\r
index fff2995358083728c15126785e6367239db08363..0e97e1e17d04c02fc76933cf42765118ef7f752b 100644 (file)
@@ -7,6 +7,7 @@
   DpUtilities.c, DpTrace.c, and DpProfile.c are included here.\r
 \r
   Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -188,10 +189,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
@@ -299,11 +303,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 eddc02c2b8536c63718b82040f9c0238e21d23ce..c4c146f6b152c5bd11c68b67c0aab22a17b90b44 100644 (file)
Binary files a/PerformancePkg/Dp_App/DpStrings.uni and b/PerformancePkg/Dp_App/DpStrings.uni differ
index 1ba2b72ba4fcfc056bfd7b5335c16e7e11543a57..d3df30ff28ab79c8e4a5b2c25e5d8a4c1af05856 100644 (file)
@@ -2,6 +2,7 @@
   Trace reporting for the Dp utility.\r
 \r
   Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   \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
@@ -98,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
@@ -785,12 +803,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
@@ -829,4 +849,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
+    PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_STATS),\r
+                CustomCumulativeData->Name,\r
+                CustomCumulativeData->Count,\r
+                Dur,\r
+                AvgDur,\r
+                MinDur,\r
+                MaxDur\r
+                );\r
+  }\r
 }\r