Trace reporting for the Dp utility.\r
\r
Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+ (C) Copyright 2015-2016 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
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
UINTN TIndex;\r
\r
EFI_HANDLE *HandleBuffer;\r
- UINTN Size;\r
- EFI_HANDLE TempHandle;\r
+ UINTN HandleCount;\r
EFI_STATUS Status;\r
EFI_STRING StringPtrUnknown;\r
\r
\r
// Get Handle information\r
//\r
- Size = 0;\r
- HandleBuffer = &TempHandle;\r
- Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, &TempHandle);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- HandleBuffer = AllocatePool (Size);\r
- ASSERT (HandleBuffer != NULL);\r
- if (HandleBuffer == NULL) {\r
- return;\r
- }\r
- Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, HandleBuffer);\r
- }\r
+ Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);\r
if (EFI_ERROR (Status)) {\r
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);\r
}\r
AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);\r
if (Measurement.Handle != NULL) {\r
// See if the Handle is in the HandleBuffer\r
- for (TIndex = 0; TIndex < (Size / sizeof(HandleBuffer[0])); TIndex++) {\r
+ for (TIndex = 0; TIndex < HandleCount; TIndex++) {\r
if (Measurement.Handle == HandleBuffer[TIndex]) {\r
DpGetNameFromHandle (HandleBuffer[TIndex]);\r
break;\r
}\r
}\r
}\r
- if (HandleBuffer != &TempHandle) {\r
+ if (HandleBuffer != NULL) {\r
FreePool (HandleBuffer);\r
}\r
SHELL_FREE_NON_NULL (IncFlag);\r
UINTN Index;\r
UINTN LogEntryKey;\r
UINTN Count;\r
- UINTN Size;\r
- EFI_HANDLE TempHandle;\r
+ UINTN HandleCount;\r
EFI_STATUS Status;\r
EFI_STRING StringPtrUnknown;\r
\r
FreePool (StringPtr);\r
FreePool (StringPtrUnknown);\r
\r
- Size = 0;\r
- HandleBuffer = &TempHandle;\r
- Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, &TempHandle);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- HandleBuffer = AllocatePool (Size);\r
- ASSERT (HandleBuffer != NULL);\r
- if (HandleBuffer == NULL) {\r
- return Status;\r
- }\r
- Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, HandleBuffer);\r
- }\r
+ Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);\r
if (EFI_ERROR (Status)) {\r
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);\r
}\r
mGaugeString[0] = 0; // Empty driver name by default\r
AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);\r
// See if the Handle is in the HandleBuffer\r
- for (Index = 0; Index < (Size / sizeof(HandleBuffer[0])); Index++) {\r
+ for (Index = 0; Index < HandleCount; Index++) {\r
if (Measurement.Handle == HandleBuffer[Index]) {\r
DpGetNameFromHandle (HandleBuffer[Index]); // Name is put into mGaugeString\r
break;\r
}\r
}\r
}\r
- if (HandleBuffer != &TempHandle) {\r
+ if (HandleBuffer != NULL) {\r
FreePool (HandleBuffer);\r
}\r
return Status;\r
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
);\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