2 Trace reporting for the Dp utility.
4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
5 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <Library/BaseLib.h>
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/MemoryAllocationLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/UefiBootServicesTableLib.h>
20 #include <Library/TimerLib.h>
21 #include <Library/PeCoffGetEntryPointLib.h>
22 #include <Library/PerformanceLib.h>
23 #include <Library/PrintLib.h>
24 #include <Library/HiiLib.h>
25 #include <Library/PcdLib.h>
27 #include <Guid/Performance.h>
31 #include "DpInternal.h"
34 Collect verbose statistics about the logged performance measurements.
36 General Summary information for all Trace measurements is gathered and
37 stored within the SummaryData structure. This information is both
38 used internally by subsequent reporting functions, and displayed
39 at the end of verbose reports.
41 @pre The SummaryData and CumData structures must be initialized
42 prior to calling this function.
44 @post The SummaryData and CumData structures contain statistics for the
45 current performance logs.
47 @param[in, out] CustomCumulativeData A pointer to the cumtom cumulative data.
52 IN OUT PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
55 MEASUREMENT_RECORD Measurement
;
61 while ((LogEntryKey
= GetPerformanceMeasurementEx (
66 &Measurement
.StartTimeStamp
,
67 &Measurement
.EndTimeStamp
,
68 &Measurement
.Identifier
)) != 0)
70 ++SummaryData
.NumTrace
; // Count the number of TRACE Measurement records
71 if (Measurement
.EndTimeStamp
== 0) {
72 ++SummaryData
.NumIncomplete
; // Count the incomplete records
76 if (Measurement
.Handle
!= NULL
) {
77 ++SummaryData
.NumHandles
; // Count the number of measurements with non-NULL handles
80 if (IsPhase( &Measurement
)) {
81 ++SummaryData
.NumSummary
; // Count the number of major phases
83 else { // !IsPhase(...
84 if(Measurement
.Handle
== NULL
) {
85 ++SummaryData
.NumGlobal
;
89 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
90 ++SummaryData
.NumPEIMs
; // Count PEIM measurements
93 Duration
= GetDuration (&Measurement
);
94 TIndex
= GetCumulativeItem (&Measurement
);
96 CumData
[TIndex
].Duration
+= Duration
;
97 CumData
[TIndex
].Count
++;
98 if ( Duration
< CumData
[TIndex
].MinDur
) {
99 CumData
[TIndex
].MinDur
= Duration
;
101 if ( Duration
> CumData
[TIndex
].MaxDur
) {
102 CumData
[TIndex
].MaxDur
= Duration
;
107 // Collect the data for custom cumulative data.
109 if ((CustomCumulativeData
!= NULL
) && (AsciiStrCmp (Measurement
.Token
, CustomCumulativeData
->Name
) == 0)) {
110 CustomCumulativeData
->Duration
+= Duration
;
111 CustomCumulativeData
->Count
++;
112 if (Duration
< CustomCumulativeData
->MinDur
) {
113 CustomCumulativeData
->MinDur
= Duration
;
115 if (Duration
> CustomCumulativeData
->MaxDur
) {
116 CustomCumulativeData
->MaxDur
= Duration
;
123 Gather and print ALL Trace Records.
125 Displays all "interesting" Trace measurements in order.<BR>
126 The number of records displayed is controlled by:
127 - records with a duration less than mInterestThreshold microseconds are not displayed.
128 - No more than Limit records are displayed. A Limit of zero will not limit the output.
129 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
132 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
133 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
134 They must not be in use by a calling function.
136 @param[in] Limit The number of records to print. Zero is ALL.
137 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
139 @retval EFI_SUCCESS The operation was successful.
140 @retval EFI_ABORTED The user aborts the operation.
141 @return Others from a call to gBS->LocateHandleBuffer().
146 IN BOOLEAN ExcludeFlag
149 MEASUREMENT_RECORD Measurement
;
158 EFI_HANDLE
*HandleBuffer
;
161 EFI_STRING StringPtrUnknown
;
163 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
164 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_ALL
), NULL
);
165 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
166 (IncFlag
== NULL
) ? StringPtrUnknown
: IncFlag
);
167 FreePool (StringPtrUnknown
);
169 // Get Handle information
171 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
172 if (EFI_ERROR (Status
)) {
173 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), gDpHiiHandle
, Status
);
176 // We have successfully populated the HandleBuffer
177 // Display ALL Measurement Records
178 // Up to Limit lines displayed
179 // Display only records with Elapsed times >= mInterestThreshold
180 // Display driver names in Module field for records with Handles.
183 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR2
), gDpHiiHandle
);
184 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_DASHES2
), gDpHiiHandle
);
186 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR
), gDpHiiHandle
);
187 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
193 while ( WITHIN_LIMIT(Count
, Limit
) &&
194 ((LogEntryKey
= GetPerformanceMeasurementEx (
199 &Measurement
.StartTimeStamp
,
200 &Measurement
.EndTimeStamp
,
201 &Measurement
.Identifier
)) != 0)
204 ++Index
; // Count every record. First record is 1.
206 SHELL_FREE_NON_NULL (IncFlag
);
207 if (Measurement
.EndTimeStamp
!= 0) {
208 Duration
= GetDuration (&Measurement
);
209 ElapsedTime
= DurationInMicroSeconds ( Duration
);
210 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_COMPLETE
), NULL
);
213 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_INCOMPLETE
), NULL
); // Mark incomplete records
215 if (((Measurement
.EndTimeStamp
!= 0) && (ElapsedTime
< mInterestThreshold
)) ||
216 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
217 ) { // Ignore "uninteresting" or excluded records
220 ++Count
; // Count the number of records printed
222 // If Handle is non-zero, see if we can determine a name for the driver
223 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
); // Use Module by default
224 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
225 if (Measurement
.Handle
!= NULL
) {
226 // See if the Handle is in the HandleBuffer
227 for (TIndex
= 0; TIndex
< HandleCount
; TIndex
++) {
228 if (Measurement
.Handle
== HandleBuffer
[TIndex
]) {
229 DpGetNameFromHandle (HandleBuffer
[TIndex
]);
235 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
236 UnicodeSPrint (mGaugeString
, sizeof (mGaugeString
), L
"%g", Measurement
.Handle
);
239 // Ensure that the argument strings are not too long.
240 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
241 mUnicodeToken
[13] = 0;
244 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS2
), gDpHiiHandle
,
245 Index
, // 1 based, Which measurement record is being printed
251 Measurement
.Identifier
254 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS
), gDpHiiHandle
,
255 Index
, // 1 based, Which measurement record is being printed
263 if (ShellGetExecutionBreakFlag ()) {
264 Status
= EFI_ABORTED
;
269 if (HandleBuffer
!= NULL
) {
270 FreePool (HandleBuffer
);
272 SHELL_FREE_NON_NULL (IncFlag
);
278 Gather and print Raw Trace Records.
280 All Trace measurements with a duration greater than or equal to
281 mInterestThreshold are printed without interpretation.
283 The number of records displayed is controlled by:
284 - records with a duration less than mInterestThreshold microseconds are not displayed.
285 - No more than Limit records are displayed. A Limit of zero will not limit the output.
286 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
289 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
291 @param[in] Limit The number of records to print. Zero is ALL.
292 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
294 @retval EFI_SUCCESS The operation was successful.
295 @retval EFI_ABORTED The user aborts the operation.
300 IN BOOLEAN ExcludeFlag
303 MEASUREMENT_RECORD Measurement
;
310 EFI_STRING StringPtr
;
311 EFI_STRING StringPtrUnknown
;
314 Status
= EFI_SUCCESS
;
316 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
317 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_RAWTRACE
), NULL
);
318 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
319 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
320 FreePool (StringPtr
);
321 FreePool (StringPtrUnknown
);
324 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR2
), gDpHiiHandle
);
325 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES2
), gDpHiiHandle
);
327 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR
), gDpHiiHandle
);
328 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES
), gDpHiiHandle
);
334 while ( WITHIN_LIMIT(Count
, Limit
) &&
335 ((LogEntryKey
= GetPerformanceMeasurementEx (
340 &Measurement
.StartTimeStamp
,
341 &Measurement
.EndTimeStamp
,
342 &Measurement
.Identifier
)) != 0)
345 ++Index
; // Count every record. First record is 1.
347 if (Measurement
.EndTimeStamp
!= 0) {
348 Duration
= GetDuration (&Measurement
);
349 ElapsedTime
= DurationInMicroSeconds ( Duration
);
351 if ((ElapsedTime
< mInterestThreshold
) ||
352 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
353 ) { // Ignore "uninteresting" or Excluded records
356 ++Count
; // Count the number of records printed
359 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS2
), gDpHiiHandle
,
360 Index
, // 1 based, Which measurement record is being printed
362 Measurement
.StartTimeStamp
,
363 Measurement
.EndTimeStamp
,
366 Measurement
.Identifier
369 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS
), gDpHiiHandle
,
370 Index
, // 1 based, Which measurement record is being printed
372 Measurement
.StartTimeStamp
,
373 Measurement
.EndTimeStamp
,
378 if (ShellGetExecutionBreakFlag ()) {
379 Status
= EFI_ABORTED
;
387 Gather and print Major Phase metrics.
389 @param[in] Ticker The timer value for the END of Shell phase
397 MEASUREMENT_RECORD Measurement
;
398 UINT64 BdsTimeoutValue
;
407 EFI_STRING StringPtr
;
409 EFI_STRING StringPtrUnknown
;
418 // Get Execution Phase Statistics
420 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
421 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PHASES
), NULL
);
422 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
423 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
424 FreePool (StringPtr
);
425 FreePool (StringPtrUnknown
);
428 while ((LogEntryKey
= GetPerformanceMeasurementEx (
433 &Measurement
.StartTimeStamp
,
434 &Measurement
.EndTimeStamp
,
435 &Measurement
.Identifier
)) != 0)
437 if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
438 Measurement
.EndTimeStamp
= Ticker
;
440 if (Measurement
.EndTimeStamp
== 0) { // Skip "incomplete" records
443 Duration
= GetDuration (&Measurement
);
444 if ( Measurement
.Handle
!= NULL
445 && (AsciiStrnCmp (Measurement
.Token
, ALit_BdsTO
, PERF_TOKEN_LENGTH
) == 0)
448 BdsTimeoutValue
= Duration
;
449 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SEC
, PERF_TOKEN_LENGTH
) == 0) {
451 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_PEI
, PERF_TOKEN_LENGTH
) == 0) {
453 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_DXE
, PERF_TOKEN_LENGTH
) == 0) {
455 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_BDS
, PERF_TOKEN_LENGTH
) == 0) {
457 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
458 ShellTime
= Duration
;
464 // print SEC phase duration time
467 ElapsedTime
= DurationInMicroSeconds ( SecTime
); // Calculate elapsed time in microseconds
468 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
469 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SEC_PHASE
), gDpHiiHandle
, ElapsedTime
);
472 // print PEI phase duration time
475 ElapsedTime
= DivU64x32 (
477 (UINT32
)TimerInfo
.Frequency
479 Total
+= ElapsedTime
;
480 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_PEI
, ElapsedTime
);
483 // print DXE phase duration time
486 ElapsedTime
= DivU64x32 (
488 (UINT32
)TimerInfo
.Frequency
490 Total
+= ElapsedTime
;
491 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_DXE
, ElapsedTime
);
494 // print BDS phase duration time
497 ElapsedTime
= DivU64x32 (
499 (UINT32
)TimerInfo
.Frequency
501 Total
+= ElapsedTime
;
502 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_BDS
, ElapsedTime
);
505 if (BdsTimeoutValue
> 0) {
506 ElapsedTime
= DivU64x32 (
508 (UINT32
)TimerInfo
.Frequency
510 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_BDSTO
), gDpHiiHandle
, ALit_BdsTO
, ElapsedTime
);
513 // print SHELL phase duration time
516 ElapsedTime
= DivU64x32 (
518 (UINT32
)TimerInfo
.Frequency
520 Total
+= ElapsedTime
;
521 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_SHELL
, ElapsedTime
);
524 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_TOTAL_DURATION
), gDpHiiHandle
, Total
);
528 Gather and print Handle data.
530 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
532 @retval EFI_SUCCESS The operation was successful.
533 @retval EFI_ABORTED The user aborts the operation.
534 @return Others from a call to gBS->LocateHandleBuffer().
538 IN BOOLEAN ExcludeFlag
541 MEASUREMENT_RECORD Measurement
;
544 EFI_HANDLE
*HandleBuffer
;
545 EFI_STRING StringPtr
;
551 EFI_STRING StringPtrUnknown
;
553 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
554 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_DRIVERS
), NULL
);
555 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
556 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
557 FreePool (StringPtr
);
558 FreePool (StringPtrUnknown
);
560 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
561 if (EFI_ERROR (Status
)) {
562 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), gDpHiiHandle
, Status
);
566 Print (L
"There are %,d Handles defined.\n", (Size
/ sizeof(HandleBuffer
[0])));
570 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION2
), gDpHiiHandle
);
572 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION
), gDpHiiHandle
);
574 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
578 while ((LogEntryKey
= GetPerformanceMeasurementEx (
583 &Measurement
.StartTimeStamp
,
584 &Measurement
.EndTimeStamp
,
585 &Measurement
.Identifier
)) != 0)
588 Duration
= GetDuration (&Measurement
);
589 ElapsedTime
= DurationInMicroSeconds ( Duration
);
590 if ((ElapsedTime
< mInterestThreshold
) ||
591 (Measurement
.EndTimeStamp
== 0) ||
592 (Measurement
.Handle
== NULL
) ||
593 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
594 ) { // Ignore "uninteresting" or excluded records
597 mGaugeString
[0] = 0; // Empty driver name by default
598 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
599 // See if the Handle is in the HandleBuffer
600 for (Index
= 0; Index
< HandleCount
; Index
++) {
601 if (Measurement
.Handle
== HandleBuffer
[Index
]) {
602 DpGetNameFromHandle (HandleBuffer
[Index
]); // Name is put into mGaugeString
606 // Ensure that the argument strings are not too long.
607 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
608 mUnicodeToken
[11] = 0;
609 if (mGaugeString
[0] != 0) {
610 // Display the record if it has a valid handle.
612 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS2
), gDpHiiHandle
,
613 Count
, // 1 based, Which measurement record is being printed
614 Index
+ 1, // 1 based, Which handle is being printed
618 Measurement
.Identifier
621 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS
), gDpHiiHandle
,
622 Count
, // 1 based, Which measurement record is being printed
623 Index
+ 1, // 1 based, Which handle is being printed
630 if (ShellGetExecutionBreakFlag ()) {
631 Status
= EFI_ABORTED
;
636 if (HandleBuffer
!= NULL
) {
637 FreePool (HandleBuffer
);
643 Gather and print PEIM data.
645 Only prints complete PEIM records
647 @retval EFI_SUCCESS The operation was successful.
648 @retval EFI_ABORTED The user aborts the operation.
655 MEASUREMENT_RECORD Measurement
;
658 EFI_STRING StringPtr
;
661 EFI_STRING StringPtrUnknown
;
664 Status
= EFI_SUCCESS
;
666 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
667 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PEIMS
), NULL
);
668 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
669 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
670 FreePool (StringPtr
);
671 FreePool (StringPtrUnknown
);
674 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION2
), gDpHiiHandle
);
676 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION
), gDpHiiHandle
);
678 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
681 while ((LogEntryKey
= GetPerformanceMeasurementEx (
686 &Measurement
.StartTimeStamp
,
687 &Measurement
.EndTimeStamp
,
688 &Measurement
.Identifier
)) != 0)
691 if ((Measurement
.EndTimeStamp
== 0) ||
692 (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) != 0)
697 Duration
= GetDuration (&Measurement
);
698 ElapsedTime
= DurationInMicroSeconds ( Duration
); // Calculate elapsed time in microseconds
699 if (ElapsedTime
>= mInterestThreshold
) {
700 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
702 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS2
), gDpHiiHandle
,
703 TIndex
, // 1 based, Which measurement record is being printed
704 Measurement
.Handle
, // base address
705 Measurement
.Handle
, // file guid
707 Measurement
.Identifier
710 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS
), gDpHiiHandle
,
711 TIndex
, // 1 based, Which measurement record is being printed
712 Measurement
.Handle
, // base address
713 Measurement
.Handle
, // file guid
718 if (ShellGetExecutionBreakFlag ()) {
719 Status
= EFI_ABORTED
;
727 Gather and print global data.
729 Strips out incomplete or "Execution Phase" records
730 Only prints records where Handle is NULL
731 Increment TIndex for every record, even skipped ones, so that we have an
732 indication of every measurement record taken.
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
;
747 UINTN Index
; // Index, or number, of the measurement record being processed
748 EFI_STRING StringPtrUnknown
;
751 Status
= EFI_SUCCESS
;
753 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
754 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_GENERAL
), NULL
);
755 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
756 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
757 FreePool (StringPtr
);
758 FreePool (StringPtrUnknown
);
761 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION2
), gDpHiiHandle
);
763 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION
), gDpHiiHandle
);
765 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
770 while ((LogEntryKey
= GetPerformanceMeasurementEx (
775 &Measurement
.StartTimeStamp
,
776 &Measurement
.EndTimeStamp
,
777 &Measurement
.Identifier
)) != 0)
779 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
);
780 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
781 mGaugeString
[25] = 0;
782 mUnicodeToken
[31] = 0;
783 if ( ! ( IsPhase( &Measurement
) ||
784 (Measurement
.Handle
!= NULL
) ||
785 (Measurement
.EndTimeStamp
== 0)
788 Duration
= GetDuration (&Measurement
);
789 ElapsedTime
= DurationInMicroSeconds ( Duration
);
790 if (ElapsedTime
>= mInterestThreshold
) {
792 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS2
), gDpHiiHandle
,
797 Measurement
.Identifier
800 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS
), gDpHiiHandle
,
809 if (ShellGetExecutionBreakFlag ()) {
810 Status
= EFI_ABORTED
;
819 Gather and print cumulative data.
821 Traverse the measurement records and:<BR>
822 For each record with a Token listed in the CumData array:<BR>
823 - Update the instance count and the total, minimum, and maximum durations.
824 Finally, print the gathered cumulative statistics.
826 @param[in] CustomCumulativeData A pointer to the cumtom cumulative data.
831 IN PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
834 UINT64 AvgDur
; // the computed average duration
838 EFI_STRING StringPtr
;
840 EFI_STRING StringPtrUnknown
;
842 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
843 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE
), NULL
);
844 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
845 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
846 FreePool (StringPtr
);
847 FreePool (StringPtrUnknown
);
849 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1
), gDpHiiHandle
);
850 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2
), gDpHiiHandle
);
851 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
853 for ( TIndex
= 0; TIndex
< NumCum
; ++TIndex
) {
854 if (CumData
[TIndex
].Count
!= 0) {
855 AvgDur
= DivU64x32 (CumData
[TIndex
].Duration
, CumData
[TIndex
].Count
);
856 AvgDur
= DurationInMicroSeconds(AvgDur
);
857 Dur
= DurationInMicroSeconds(CumData
[TIndex
].Duration
);
858 MaxDur
= DurationInMicroSeconds(CumData
[TIndex
].MaxDur
);
859 MinDur
= DurationInMicroSeconds(CumData
[TIndex
].MinDur
);
861 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), gDpHiiHandle
,
862 CumData
[TIndex
].Name
,
863 CumData
[TIndex
].Count
,
873 // Print the custom cumulative data.
875 if (CustomCumulativeData
!= NULL
) {
876 if (CustomCumulativeData
->Count
!= 0) {
877 AvgDur
= DivU64x32 (CustomCumulativeData
->Duration
, CustomCumulativeData
->Count
);
878 AvgDur
= DurationInMicroSeconds (AvgDur
);
879 Dur
= DurationInMicroSeconds (CustomCumulativeData
->Duration
);
880 MaxDur
= DurationInMicroSeconds (CustomCumulativeData
->MaxDur
);
881 MinDur
= DurationInMicroSeconds (CustomCumulativeData
->MinDur
);
888 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), gDpHiiHandle
,
889 CustomCumulativeData
->Name
,
890 CustomCumulativeData
->Count
,