2 Trace reporting for the Dp utility.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
5 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include <Library/BaseLib.h>
10 #include <Library/BaseMemoryLib.h>
11 #include <Library/MemoryAllocationLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/UefiBootServicesTableLib.h>
14 #include <Library/PeCoffGetEntryPointLib.h>
15 #include <Library/PerformanceLib.h>
16 #include <Library/PrintLib.h>
17 #include <Library/HiiLib.h>
18 #include <Library/PcdLib.h>
22 #include "DpInternal.h"
25 Attempts to retrieve a performance measurement log entry from the performance measurement log.
28 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
29 0, then the first performance measurement log entry is retrieved.
30 On exit, the key of the next performance log entry.
31 @param Handle Pointer to environment specific context used to identify the component
33 @param Token Pointer to a Null-terminated ASCII string that identifies the component
35 @param Module Pointer to a Null-terminated ASCII string that identifies the module
37 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
39 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
41 @param Identifier Pointer to the 32-bit identifier that was recorded when the measurement
44 @return The key for the next performance log entry (in general case).
48 GetPerformanceMeasurementRecord (
50 OUT CONST VOID
**Handle
,
51 OUT CONST CHAR8
**Token
,
52 OUT CONST CHAR8
**Module
,
53 OUT UINT64
*StartTimeStamp
,
54 OUT UINT64
*EndTimeStamp
,
55 OUT UINT32
*Identifier
58 if (LogEntryKey
== mMeasurementNum
) {
62 *Handle
= (VOID
*)(UINTN
)mMeasurementList
[LogEntryKey
].Handle
;
63 *Token
= mMeasurementList
[LogEntryKey
].Token
;
64 *Module
= mMeasurementList
[LogEntryKey
].Module
;
65 *StartTimeStamp
= mMeasurementList
[LogEntryKey
].StartTimeStamp
;
66 *EndTimeStamp
= mMeasurementList
[LogEntryKey
].EndTimeStamp
;
67 *Identifier
= mMeasurementList
[LogEntryKey
].Identifier
;
75 Collect verbose statistics about the logged performance measurements.
77 General Summary information for all Trace measurements is gathered and
78 stored within the SummaryData structure. This information is both
79 used internally by subsequent reporting functions, and displayed
80 at the end of verbose reports.
82 @pre The SummaryData and CumData structures must be initialized
83 prior to calling this function.
85 @post The SummaryData and CumData structures contain statistics for the
86 current performance logs.
88 @param[in, out] CustomCumulativeData A pointer to the custom cumulative data.
93 IN OUT PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
96 MEASUREMENT_RECORD Measurement
;
102 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
107 &Measurement
.StartTimeStamp
,
108 &Measurement
.EndTimeStamp
,
109 &Measurement
.Identifier
112 ++SummaryData
.NumTrace
; // Count the number of TRACE Measurement records
113 if (Measurement
.EndTimeStamp
== 0) {
114 ++SummaryData
.NumIncomplete
; // Count the incomplete records
118 if (Measurement
.Handle
!= NULL
) {
119 ++SummaryData
.NumHandles
; // Count the number of measurements with non-NULL handles
122 if (IsPhase (&Measurement
)) {
123 ++SummaryData
.NumSummary
; // Count the number of major phases
126 if (Measurement
.Handle
== NULL
) {
127 ++SummaryData
.NumGlobal
;
131 if (AsciiStrCmp (Measurement
.Token
, ALit_PEIM
) == 0) {
132 ++SummaryData
.NumPEIMs
; // Count PEIM measurements
135 Duration
= GetDuration (&Measurement
);
136 TIndex
= GetCumulativeItem (&Measurement
);
138 CumData
[TIndex
].Duration
+= Duration
;
139 CumData
[TIndex
].Count
++;
140 if ( Duration
< CumData
[TIndex
].MinDur
) {
141 CumData
[TIndex
].MinDur
= Duration
;
144 if ( Duration
> CumData
[TIndex
].MaxDur
) {
145 CumData
[TIndex
].MaxDur
= Duration
;
150 // Collect the data for custom cumulative data.
152 if ((CustomCumulativeData
!= NULL
) && (AsciiStrCmp (Measurement
.Token
, CustomCumulativeData
->Name
) == 0)) {
153 CustomCumulativeData
->Duration
+= Duration
;
154 CustomCumulativeData
->Count
++;
155 if (Duration
< CustomCumulativeData
->MinDur
) {
156 CustomCumulativeData
->MinDur
= Duration
;
159 if (Duration
> CustomCumulativeData
->MaxDur
) {
160 CustomCumulativeData
->MaxDur
= Duration
;
167 Gather and print ALL Trace Records.
169 Displays all "interesting" Trace measurements in order.<BR>
170 The number of records displayed is controlled by:
171 - records with a duration less than mInterestThreshold microseconds are not displayed.
172 - No more than Limit records are displayed. A Limit of zero will not limit the output.
173 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
176 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
177 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
178 They must not be in use by a calling function.
180 @param[in] Limit The number of records to print. Zero is ALL.
181 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
183 @retval EFI_SUCCESS The operation was successful.
184 @retval EFI_ABORTED The user aborts the operation.
185 @return Others from a call to gBS->LocateHandleBuffer().
190 IN BOOLEAN ExcludeFlag
193 MEASUREMENT_RECORD Measurement
;
202 EFI_HANDLE
*HandleBuffer
;
205 EFI_STRING StringPtrUnknown
;
207 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
208 IncFlag
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_ALL
), NULL
);
213 STRING_TOKEN (STR_DP_SECTION_HEADER
),
215 (IncFlag
== NULL
) ? StringPtrUnknown
: IncFlag
217 FreePool (StringPtrUnknown
);
219 // Get Handle information
221 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
222 if (EFI_ERROR (Status
)) {
223 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), mDpHiiHandle
, Status
);
225 // We have successfully populated the HandleBuffer
226 // Display ALL Measurement Records
227 // Up to Limit lines displayed
228 // Display only records with Elapsed times >= mInterestThreshold
229 // Display driver names in Module field for records with Handles.
232 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR2
), mDpHiiHandle
);
233 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_DASHES2
), mDpHiiHandle
);
235 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR
), mDpHiiHandle
);
236 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
242 while ( WITHIN_LIMIT (Count
, Limit
) &&
243 ((LogEntryKey
= GetPerformanceMeasurementRecord (
248 &Measurement
.StartTimeStamp
,
249 &Measurement
.EndTimeStamp
,
250 &Measurement
.Identifier
254 ++Index
; // Count every record. First record is 1.
256 SHELL_FREE_NON_NULL (IncFlag
);
257 if (Measurement
.EndTimeStamp
!= 0) {
258 Duration
= GetDuration (&Measurement
);
259 ElapsedTime
= DurationInMicroSeconds (Duration
);
260 IncFlag
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_COMPLETE
), NULL
);
262 IncFlag
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_INCOMPLETE
), NULL
); // Mark incomplete records
265 if (((Measurement
.EndTimeStamp
!= 0) && (ElapsedTime
< mInterestThreshold
)) ||
266 ((ExcludeFlag
) && (GetCumulativeItem (&Measurement
) >= 0))
267 ) // Ignore "uninteresting" or excluded records
272 ++Count
; // Count the number of records printed
274 // If Handle is non-zero, see if we can determine a name for the driver
275 AsciiStrToUnicodeStrS (Measurement
.Module
, mGaugeString
, ARRAY_SIZE (mGaugeString
)); // Use Module by default
276 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
277 if (Measurement
.Handle
!= NULL
) {
278 // See if the Handle is in the HandleBuffer
279 for (TIndex
= 0; TIndex
< HandleCount
; TIndex
++) {
280 if (Measurement
.Handle
== HandleBuffer
[TIndex
]) {
281 DpGetNameFromHandle (HandleBuffer
[TIndex
]);
287 if (AsciiStrCmp (Measurement
.Token
, ALit_PEIM
) == 0) {
288 UnicodeSPrint (mGaugeString
, sizeof (mGaugeString
), L
"%g", Measurement
.Handle
);
291 // Ensure that the argument strings are not too long.
292 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
293 mUnicodeToken
[13] = 0;
300 STRING_TOKEN (STR_DP_ALL_VARS2
),
302 Index
, // 1 based, Which measurement record is being printed
308 Measurement
.Identifier
315 STRING_TOKEN (STR_DP_ALL_VARS
),
317 Index
, // 1 based, Which measurement record is being printed
326 if (ShellGetExecutionBreakFlag ()) {
327 Status
= EFI_ABORTED
;
333 if (HandleBuffer
!= NULL
) {
334 FreePool (HandleBuffer
);
337 SHELL_FREE_NON_NULL (IncFlag
);
343 Gather and print Raw Trace Records.
345 All Trace measurements with a duration greater than or equal to
346 mInterestThreshold are printed without interpretation.
348 The number of records displayed is controlled by:
349 - records with a duration less than mInterestThreshold microseconds are not displayed.
350 - No more than Limit records are displayed. A Limit of zero will not limit the output.
351 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
354 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
356 @param[in] Limit The number of records to print. Zero is ALL.
357 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
359 @retval EFI_SUCCESS The operation was successful.
360 @retval EFI_ABORTED The user aborts the operation.
365 IN BOOLEAN ExcludeFlag
368 MEASUREMENT_RECORD Measurement
;
375 EFI_STRING StringPtr
;
376 EFI_STRING StringPtrUnknown
;
379 Status
= EFI_SUCCESS
;
381 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
382 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_RAWTRACE
), NULL
);
387 STRING_TOKEN (STR_DP_SECTION_HEADER
),
389 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
391 FreePool (StringPtr
);
392 FreePool (StringPtrUnknown
);
395 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR2
), mDpHiiHandle
);
396 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES2
), mDpHiiHandle
);
398 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR
), mDpHiiHandle
);
399 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES
), mDpHiiHandle
);
405 while ( WITHIN_LIMIT (Count
, Limit
) &&
406 ((LogEntryKey
= GetPerformanceMeasurementRecord (
411 &Measurement
.StartTimeStamp
,
412 &Measurement
.EndTimeStamp
,
413 &Measurement
.Identifier
417 ++Index
; // Count every record. First record is 1.
419 if (Measurement
.EndTimeStamp
!= 0) {
420 Duration
= GetDuration (&Measurement
);
421 ElapsedTime
= DurationInMicroSeconds (Duration
);
424 if ((ElapsedTime
< mInterestThreshold
) ||
425 ((ExcludeFlag
) && (GetCumulativeItem (&Measurement
) >= 0))
426 ) // Ignore "uninteresting" or Excluded records
431 ++Count
; // Count the number of records printed
438 STRING_TOKEN (STR_DP_RAW_VARS2
),
440 Index
, // 1 based, Which measurement record is being printed
442 Measurement
.StartTimeStamp
,
443 Measurement
.EndTimeStamp
,
446 Measurement
.Identifier
453 STRING_TOKEN (STR_DP_RAW_VARS
),
455 Index
, // 1 based, Which measurement record is being printed
457 Measurement
.StartTimeStamp
,
458 Measurement
.EndTimeStamp
,
464 if (ShellGetExecutionBreakFlag ()) {
465 Status
= EFI_ABORTED
;
474 Gather and print Major Phase metrics.
482 MEASUREMENT_RECORD Measurement
;
483 UINT64 BdsTimeoutValue
;
491 EFI_STRING StringPtr
;
493 EFI_STRING StringPtrUnknown
;
501 // Get Execution Phase Statistics
503 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
504 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PHASES
), NULL
);
509 STRING_TOKEN (STR_DP_SECTION_HEADER
),
511 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
513 FreePool (StringPtr
);
514 FreePool (StringPtrUnknown
);
517 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
522 &Measurement
.StartTimeStamp
,
523 &Measurement
.EndTimeStamp
,
524 &Measurement
.Identifier
527 if (Measurement
.EndTimeStamp
== 0) {
528 // Skip "incomplete" records
532 Duration
= GetDuration (&Measurement
);
533 if ( (Measurement
.Handle
!= NULL
)
534 && (AsciiStrCmp (Measurement
.Token
, ALit_BdsTO
) == 0)
537 BdsTimeoutValue
= Duration
;
538 } else if (AsciiStrCmp (Measurement
.Token
, ALit_SEC
) == 0) {
540 } else if (AsciiStrCmp (Measurement
.Token
, ALit_PEI
) == 0) {
542 } else if (AsciiStrCmp (Measurement
.Token
, ALit_DXE
) == 0) {
544 } else if (AsciiStrCmp (Measurement
.Token
, ALit_BDS
) == 0) {
551 // print SEC phase duration time
554 ElapsedTime
= DurationInMicroSeconds (SecTime
); // Calculate elapsed time in microseconds
555 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
556 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SEC_PHASE
), mDpHiiHandle
, ElapsedTime
);
559 // print PEI phase duration time
562 ElapsedTime
= DivU64x32 (PeiTime
, 1000000);
563 Total
+= ElapsedTime
;
564 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), mDpHiiHandle
, ALit_PEI
, ElapsedTime
);
567 // print DXE phase duration time
570 ElapsedTime
= DivU64x32 (DxeTime
, 1000000);
571 Total
+= ElapsedTime
;
572 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), mDpHiiHandle
, ALit_DXE
, ElapsedTime
);
575 // print BDS phase duration time
578 ElapsedTime
= DivU64x32 (BdsTime
, 1000000);
579 Total
+= ElapsedTime
;
580 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), mDpHiiHandle
, ALit_BDS
, ElapsedTime
);
583 if (BdsTimeoutValue
> 0) {
584 ElapsedTime
= DivU64x32 (BdsTimeoutValue
, 1000000);
585 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_BDSTO
), mDpHiiHandle
, ALit_BdsTO
, ElapsedTime
);
588 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_TOTAL_DURATION
), mDpHiiHandle
, Total
);
592 Gather and print Handle data.
594 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
596 @retval EFI_SUCCESS The operation was successful.
597 @retval EFI_ABORTED The user aborts the operation.
598 @return Others from a call to gBS->LocateHandleBuffer().
602 IN BOOLEAN ExcludeFlag
605 MEASUREMENT_RECORD Measurement
;
608 EFI_HANDLE
*HandleBuffer
;
609 EFI_STRING StringPtr
;
615 EFI_STRING StringPtrUnknown
;
617 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
618 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_DRIVERS
), NULL
);
623 STRING_TOKEN (STR_DP_SECTION_HEADER
),
625 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
627 FreePool (StringPtr
);
628 FreePool (StringPtrUnknown
);
630 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
631 if (EFI_ERROR (Status
)) {
632 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), mDpHiiHandle
, Status
);
635 Print (L
"There are %,d Handles defined.\n", (Size
/ sizeof (HandleBuffer
[0])));
639 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION2
), mDpHiiHandle
);
641 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION
), mDpHiiHandle
);
644 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
648 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
653 &Measurement
.StartTimeStamp
,
654 &Measurement
.EndTimeStamp
,
655 &Measurement
.Identifier
659 Duration
= GetDuration (&Measurement
);
660 ElapsedTime
= DurationInMicroSeconds (Duration
);
661 if ((ElapsedTime
< mInterestThreshold
) ||
662 (Measurement
.EndTimeStamp
== 0) ||
663 (!IsCorePerf (&Measurement
)) ||
664 ((ExcludeFlag
) && (GetCumulativeItem (&Measurement
) >= 0))
665 ) // Ignore "uninteresting" or excluded records
670 mGaugeString
[0] = 0; // Empty driver name by default
671 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
672 // See if the Handle is in the HandleBuffer
673 for (Index
= 0; Index
< HandleCount
; Index
++) {
674 if (Measurement
.Handle
== HandleBuffer
[Index
]) {
675 DpGetNameFromHandle (HandleBuffer
[Index
]); // Name is put into mGaugeString
680 // Ensure that the argument strings are not too long.
681 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
682 mUnicodeToken
[11] = 0;
683 if (mGaugeString
[0] != 0) {
684 // Display the record if it has a valid handle.
690 STRING_TOKEN (STR_DP_HANDLE_VARS2
),
692 Count
, // 1 based, Which measurement record is being printed
693 Index
+ 1, // 1 based, Which handle is being printed
697 Measurement
.Identifier
704 STRING_TOKEN (STR_DP_HANDLE_VARS
),
706 Count
, // 1 based, Which measurement record is being printed
707 Index
+ 1, // 1 based, Which handle is being printed
715 if (ShellGetExecutionBreakFlag ()) {
716 Status
= EFI_ABORTED
;
722 if (HandleBuffer
!= NULL
) {
723 FreePool (HandleBuffer
);
730 Gather and print PEIM data.
732 Only prints complete PEIM records
734 @retval EFI_SUCCESS The operation was successful.
735 @retval EFI_ABORTED The user aborts the operation.
742 MEASUREMENT_RECORD Measurement
;
745 EFI_STRING StringPtr
;
748 EFI_STRING StringPtrUnknown
;
751 Status
= EFI_SUCCESS
;
753 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
754 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PEIMS
), NULL
);
759 STRING_TOKEN (STR_DP_SECTION_HEADER
),
761 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
763 FreePool (StringPtr
);
764 FreePool (StringPtrUnknown
);
767 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION2
), mDpHiiHandle
);
769 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION
), mDpHiiHandle
);
772 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
775 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
780 &Measurement
.StartTimeStamp
,
781 &Measurement
.EndTimeStamp
,
782 &Measurement
.Identifier
786 if ((Measurement
.EndTimeStamp
== 0) ||
787 (AsciiStrCmp (Measurement
.Token
, ALit_PEIM
) != 0)
793 Duration
= GetDuration (&Measurement
);
794 ElapsedTime
= DurationInMicroSeconds (Duration
); // Calculate elapsed time in microseconds
795 if (ElapsedTime
>= mInterestThreshold
) {
796 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
802 STRING_TOKEN (STR_DP_PEIM_VARS2
),
804 TIndex
, // 1 based, Which measurement record is being printed
805 Measurement
.Handle
, // file guid
807 Measurement
.Identifier
814 STRING_TOKEN (STR_DP_PEIM_VARS
),
816 TIndex
, // 1 based, Which measurement record is being printed
817 Measurement
.Handle
, // file guid
823 if (ShellGetExecutionBreakFlag ()) {
824 Status
= EFI_ABORTED
;
833 Gather and print global data.
835 Strips out incomplete or "Execution Phase" records
836 Only prints records where Handle is NULL
837 Increment TIndex for every record, even skipped ones, so that we have an
838 indication of every measurement record taken.
840 @retval EFI_SUCCESS The operation was successful.
841 @retval EFI_ABORTED The user aborts the operation.
848 MEASUREMENT_RECORD Measurement
;
851 EFI_STRING StringPtr
;
853 UINTN Index
; // Index, or number, of the measurement record being processed
854 EFI_STRING StringPtrUnknown
;
857 Status
= EFI_SUCCESS
;
859 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
860 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_GENERAL
), NULL
);
865 STRING_TOKEN (STR_DP_SECTION_HEADER
),
867 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
869 FreePool (StringPtr
);
870 FreePool (StringPtrUnknown
);
873 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION2
), mDpHiiHandle
);
875 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION
), mDpHiiHandle
);
878 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
883 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
888 &Measurement
.StartTimeStamp
,
889 &Measurement
.EndTimeStamp
,
890 &Measurement
.Identifier
893 AsciiStrToUnicodeStrS (Measurement
.Module
, mGaugeString
, ARRAY_SIZE (mGaugeString
));
894 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
895 mGaugeString
[25] = 0;
896 mUnicodeToken
[31] = 0;
897 if ( !(IsPhase (&Measurement
) ||
898 IsCorePerf (&Measurement
) ||
899 (Measurement
.EndTimeStamp
== 0)
902 Duration
= GetDuration (&Measurement
);
903 ElapsedTime
= DurationInMicroSeconds (Duration
);
904 if (ElapsedTime
>= mInterestThreshold
) {
910 STRING_TOKEN (STR_DP_GLOBAL_VARS2
),
916 Measurement
.Identifier
923 STRING_TOKEN (STR_DP_GLOBAL_VARS
),
934 if (ShellGetExecutionBreakFlag ()) {
935 Status
= EFI_ABORTED
;
946 Gather and print cumulative data.
948 Traverse the measurement records and:<BR>
949 For each record with a Token listed in the CumData array:<BR>
950 - Update the instance count and the total, minimum, and maximum durations.
951 Finally, print the gathered cumulative statistics.
953 @param[in] CustomCumulativeData A pointer to the custom cumulative data.
958 IN PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
961 UINT64 AvgDur
; // the computed average duration
965 EFI_STRING StringPtr
;
967 EFI_STRING StringPtrUnknown
;
969 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
970 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE
), NULL
);
975 STRING_TOKEN (STR_DP_SECTION_HEADER
),
977 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
979 FreePool (StringPtr
);
980 FreePool (StringPtrUnknown
);
982 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1
), mDpHiiHandle
);
983 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2
), mDpHiiHandle
);
984 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
986 for ( TIndex
= 0; TIndex
< NumCum
; ++TIndex
) {
987 if (CumData
[TIndex
].Count
!= 0) {
988 AvgDur
= DivU64x32 (CumData
[TIndex
].Duration
, CumData
[TIndex
].Count
);
989 AvgDur
= DurationInMicroSeconds (AvgDur
);
990 Dur
= DurationInMicroSeconds (CumData
[TIndex
].Duration
);
991 MaxDur
= DurationInMicroSeconds (CumData
[TIndex
].MaxDur
);
992 MinDur
= DurationInMicroSeconds (CumData
[TIndex
].MinDur
);
998 STRING_TOKEN (STR_DP_CUMULATIVE_STATS
),
1000 CumData
[TIndex
].Name
,
1001 CumData
[TIndex
].Count
,
1011 // Print the custom cumulative data.
1013 if (CustomCumulativeData
!= NULL
) {
1014 if (CustomCumulativeData
->Count
!= 0) {
1015 AvgDur
= DivU64x32 (CustomCumulativeData
->Duration
, CustomCumulativeData
->Count
);
1016 AvgDur
= DurationInMicroSeconds (AvgDur
);
1017 Dur
= DurationInMicroSeconds (CustomCumulativeData
->Duration
);
1018 MaxDur
= DurationInMicroSeconds (CustomCumulativeData
->MaxDur
);
1019 MinDur
= DurationInMicroSeconds (CustomCumulativeData
->MinDur
);
1031 STRING_TOKEN (STR_DP_CUMULATIVE_STATS
),
1033 CustomCumulativeData
->Name
,
1034 CustomCumulativeData
->Count
,