2 Trace reporting for the Dp utility.
4 Copyright (c) 2009 - 2017, 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/PeCoffGetEntryPointLib.h>
21 #include <Library/PerformanceLib.h>
22 #include <Library/PrintLib.h>
23 #include <Library/HiiLib.h>
24 #include <Library/PcdLib.h>
26 #include <Guid/Performance.h>
30 #include "DpInternal.h"
33 Collect verbose statistics about the logged performance measurements.
35 General Summary information for all Trace measurements is gathered and
36 stored within the SummaryData structure. This information is both
37 used internally by subsequent reporting functions, and displayed
38 at the end of verbose reports.
40 @pre The SummaryData and CumData structures must be initialized
41 prior to calling this function.
43 @post The SummaryData and CumData structures contain statistics for the
44 current performance logs.
46 @param[in, out] CustomCumulativeData A pointer to the cumtom cumulative data.
51 IN OUT PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
54 MEASUREMENT_RECORD Measurement
;
60 while ((LogEntryKey
= GetPerformanceMeasurementEx (
65 &Measurement
.StartTimeStamp
,
66 &Measurement
.EndTimeStamp
,
67 &Measurement
.Identifier
)) != 0)
69 ++SummaryData
.NumTrace
; // Count the number of TRACE Measurement records
70 if (Measurement
.EndTimeStamp
== 0) {
71 ++SummaryData
.NumIncomplete
; // Count the incomplete records
75 if (Measurement
.Handle
!= NULL
) {
76 ++SummaryData
.NumHandles
; // Count the number of measurements with non-NULL handles
79 if (IsPhase( &Measurement
)) {
80 ++SummaryData
.NumSummary
; // Count the number of major phases
82 else { // !IsPhase(...
83 if(Measurement
.Handle
== NULL
) {
84 ++SummaryData
.NumGlobal
;
88 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
89 ++SummaryData
.NumPEIMs
; // Count PEIM measurements
92 Duration
= GetDuration (&Measurement
);
93 TIndex
= GetCumulativeItem (&Measurement
);
95 CumData
[TIndex
].Duration
+= Duration
;
96 CumData
[TIndex
].Count
++;
97 if ( Duration
< CumData
[TIndex
].MinDur
) {
98 CumData
[TIndex
].MinDur
= Duration
;
100 if ( Duration
> CumData
[TIndex
].MaxDur
) {
101 CumData
[TIndex
].MaxDur
= Duration
;
106 // Collect the data for custom cumulative data.
108 if ((CustomCumulativeData
!= NULL
) && (AsciiStrCmp (Measurement
.Token
, CustomCumulativeData
->Name
) == 0)) {
109 CustomCumulativeData
->Duration
+= Duration
;
110 CustomCumulativeData
->Count
++;
111 if (Duration
< CustomCumulativeData
->MinDur
) {
112 CustomCumulativeData
->MinDur
= Duration
;
114 if (Duration
> CustomCumulativeData
->MaxDur
) {
115 CustomCumulativeData
->MaxDur
= Duration
;
122 Gather and print ALL Trace Records.
124 Displays all "interesting" Trace measurements in order.<BR>
125 The number of records displayed is controlled by:
126 - records with a duration less than mInterestThreshold microseconds are not displayed.
127 - No more than Limit records are displayed. A Limit of zero will not limit the output.
128 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
131 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
132 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
133 They must not be in use by a calling function.
135 @param[in] Limit The number of records to print. Zero is ALL.
136 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
138 @retval EFI_SUCCESS The operation was successful.
139 @retval EFI_ABORTED The user aborts the operation.
140 @return Others from a call to gBS->LocateHandleBuffer().
145 IN BOOLEAN ExcludeFlag
148 MEASUREMENT_RECORD Measurement
;
157 EFI_HANDLE
*HandleBuffer
;
160 EFI_STRING StringPtrUnknown
;
162 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
163 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_ALL
), NULL
);
164 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
165 (IncFlag
== NULL
) ? StringPtrUnknown
: IncFlag
);
166 FreePool (StringPtrUnknown
);
168 // Get Handle information
170 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
171 if (EFI_ERROR (Status
)) {
172 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), gDpHiiHandle
, Status
);
175 // We have successfully populated the HandleBuffer
176 // Display ALL Measurement Records
177 // Up to Limit lines displayed
178 // Display only records with Elapsed times >= mInterestThreshold
179 // Display driver names in Module field for records with Handles.
182 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR2
), gDpHiiHandle
);
183 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_DASHES2
), gDpHiiHandle
);
185 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR
), gDpHiiHandle
);
186 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
192 while ( WITHIN_LIMIT(Count
, Limit
) &&
193 ((LogEntryKey
= GetPerformanceMeasurementEx (
198 &Measurement
.StartTimeStamp
,
199 &Measurement
.EndTimeStamp
,
200 &Measurement
.Identifier
)) != 0)
203 ++Index
; // Count every record. First record is 1.
205 SHELL_FREE_NON_NULL (IncFlag
);
206 if (Measurement
.EndTimeStamp
!= 0) {
207 Duration
= GetDuration (&Measurement
);
208 ElapsedTime
= DurationInMicroSeconds ( Duration
);
209 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_COMPLETE
), NULL
);
212 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_INCOMPLETE
), NULL
); // Mark incomplete records
214 if (((Measurement
.EndTimeStamp
!= 0) && (ElapsedTime
< mInterestThreshold
)) ||
215 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
216 ) { // Ignore "uninteresting" or excluded records
219 ++Count
; // Count the number of records printed
221 // If Handle is non-zero, see if we can determine a name for the driver
222 AsciiStrToUnicodeStrS (Measurement
.Module
, mGaugeString
, ARRAY_SIZE (mGaugeString
)); // Use Module by default
223 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
224 if (Measurement
.Handle
!= NULL
) {
225 // See if the Handle is in the HandleBuffer
226 for (TIndex
= 0; TIndex
< HandleCount
; TIndex
++) {
227 if (Measurement
.Handle
== HandleBuffer
[TIndex
]) {
228 DpGetNameFromHandle (HandleBuffer
[TIndex
]);
234 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
235 UnicodeSPrint (mGaugeString
, sizeof (mGaugeString
), L
"%g", Measurement
.Handle
);
238 // Ensure that the argument strings are not too long.
239 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
240 mUnicodeToken
[13] = 0;
243 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS2
), gDpHiiHandle
,
244 Index
, // 1 based, Which measurement record is being printed
250 Measurement
.Identifier
253 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS
), gDpHiiHandle
,
254 Index
, // 1 based, Which measurement record is being printed
262 if (ShellGetExecutionBreakFlag ()) {
263 Status
= EFI_ABORTED
;
268 if (HandleBuffer
!= NULL
) {
269 FreePool (HandleBuffer
);
271 SHELL_FREE_NON_NULL (IncFlag
);
277 Gather and print Raw Trace Records.
279 All Trace measurements with a duration greater than or equal to
280 mInterestThreshold are printed without interpretation.
282 The number of records displayed is controlled by:
283 - records with a duration less than mInterestThreshold microseconds are not displayed.
284 - No more than Limit records are displayed. A Limit of zero will not limit the output.
285 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
288 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
290 @param[in] Limit The number of records to print. Zero is ALL.
291 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
293 @retval EFI_SUCCESS The operation was successful.
294 @retval EFI_ABORTED The user aborts the operation.
299 IN BOOLEAN ExcludeFlag
302 MEASUREMENT_RECORD Measurement
;
309 EFI_STRING StringPtr
;
310 EFI_STRING StringPtrUnknown
;
313 Status
= EFI_SUCCESS
;
315 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
316 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_RAWTRACE
), NULL
);
317 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
318 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
319 FreePool (StringPtr
);
320 FreePool (StringPtrUnknown
);
323 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR2
), gDpHiiHandle
);
324 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES2
), gDpHiiHandle
);
326 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR
), gDpHiiHandle
);
327 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES
), gDpHiiHandle
);
333 while ( WITHIN_LIMIT(Count
, Limit
) &&
334 ((LogEntryKey
= GetPerformanceMeasurementEx (
339 &Measurement
.StartTimeStamp
,
340 &Measurement
.EndTimeStamp
,
341 &Measurement
.Identifier
)) != 0)
344 ++Index
; // Count every record. First record is 1.
346 if (Measurement
.EndTimeStamp
!= 0) {
347 Duration
= GetDuration (&Measurement
);
348 ElapsedTime
= DurationInMicroSeconds ( Duration
);
350 if ((ElapsedTime
< mInterestThreshold
) ||
351 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
352 ) { // Ignore "uninteresting" or Excluded records
355 ++Count
; // Count the number of records printed
358 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS2
), gDpHiiHandle
,
359 Index
, // 1 based, Which measurement record is being printed
361 Measurement
.StartTimeStamp
,
362 Measurement
.EndTimeStamp
,
365 Measurement
.Identifier
368 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS
), gDpHiiHandle
,
369 Index
, // 1 based, Which measurement record is being printed
371 Measurement
.StartTimeStamp
,
372 Measurement
.EndTimeStamp
,
377 if (ShellGetExecutionBreakFlag ()) {
378 Status
= EFI_ABORTED
;
386 Gather and print Major Phase metrics.
394 MEASUREMENT_RECORD Measurement
;
395 UINT64 BdsTimeoutValue
;
403 EFI_STRING StringPtr
;
405 EFI_STRING StringPtrUnknown
;
413 // Get Execution Phase Statistics
415 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
416 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PHASES
), NULL
);
417 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
418 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
419 FreePool (StringPtr
);
420 FreePool (StringPtrUnknown
);
423 while ((LogEntryKey
= GetPerformanceMeasurementEx (
428 &Measurement
.StartTimeStamp
,
429 &Measurement
.EndTimeStamp
,
430 &Measurement
.Identifier
)) != 0)
432 if (Measurement
.EndTimeStamp
== 0) { // Skip "incomplete" records
435 Duration
= GetDuration (&Measurement
);
436 if ( Measurement
.Handle
!= NULL
437 && (AsciiStrnCmp (Measurement
.Token
, ALit_BdsTO
, PERF_TOKEN_LENGTH
) == 0)
440 BdsTimeoutValue
= Duration
;
441 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SEC
, PERF_TOKEN_LENGTH
) == 0) {
443 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_PEI
, PERF_TOKEN_LENGTH
) == 0) {
445 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_DXE
, PERF_TOKEN_LENGTH
) == 0) {
447 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_BDS
, PERF_TOKEN_LENGTH
) == 0) {
454 // print SEC phase duration time
457 ElapsedTime
= DurationInMicroSeconds ( SecTime
); // Calculate elapsed time in microseconds
458 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
459 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SEC_PHASE
), gDpHiiHandle
, ElapsedTime
);
462 // print PEI phase duration time
465 ElapsedTime
= DivU64x32 (
467 (UINT32
)TimerInfo
.Frequency
469 Total
+= ElapsedTime
;
470 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_PEI
, ElapsedTime
);
473 // print DXE phase duration time
476 ElapsedTime
= DivU64x32 (
478 (UINT32
)TimerInfo
.Frequency
480 Total
+= ElapsedTime
;
481 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_DXE
, ElapsedTime
);
484 // print BDS phase duration time
487 ElapsedTime
= DivU64x32 (
489 (UINT32
)TimerInfo
.Frequency
491 Total
+= ElapsedTime
;
492 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_BDS
, ElapsedTime
);
495 if (BdsTimeoutValue
> 0) {
496 ElapsedTime
= DivU64x32 (
498 (UINT32
)TimerInfo
.Frequency
500 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_BDSTO
), gDpHiiHandle
, ALit_BdsTO
, ElapsedTime
);
503 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_TOTAL_DURATION
), gDpHiiHandle
, Total
);
507 Gather and print Handle data.
509 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
511 @retval EFI_SUCCESS The operation was successful.
512 @retval EFI_ABORTED The user aborts the operation.
513 @return Others from a call to gBS->LocateHandleBuffer().
517 IN BOOLEAN ExcludeFlag
520 MEASUREMENT_RECORD Measurement
;
523 EFI_HANDLE
*HandleBuffer
;
524 EFI_STRING StringPtr
;
530 EFI_STRING StringPtrUnknown
;
532 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
533 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_DRIVERS
), NULL
);
534 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
535 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
536 FreePool (StringPtr
);
537 FreePool (StringPtrUnknown
);
539 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
540 if (EFI_ERROR (Status
)) {
541 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), gDpHiiHandle
, Status
);
545 Print (L
"There are %,d Handles defined.\n", (Size
/ sizeof(HandleBuffer
[0])));
549 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION2
), gDpHiiHandle
);
551 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION
), gDpHiiHandle
);
553 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
557 while ((LogEntryKey
= GetPerformanceMeasurementEx (
562 &Measurement
.StartTimeStamp
,
563 &Measurement
.EndTimeStamp
,
564 &Measurement
.Identifier
)) != 0)
567 Duration
= GetDuration (&Measurement
);
568 ElapsedTime
= DurationInMicroSeconds ( Duration
);
569 if ((ElapsedTime
< mInterestThreshold
) ||
570 (Measurement
.EndTimeStamp
== 0) ||
571 (Measurement
.Handle
== NULL
) ||
572 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
573 ) { // Ignore "uninteresting" or excluded records
576 mGaugeString
[0] = 0; // Empty driver name by default
577 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
578 // See if the Handle is in the HandleBuffer
579 for (Index
= 0; Index
< HandleCount
; Index
++) {
580 if (Measurement
.Handle
== HandleBuffer
[Index
]) {
581 DpGetNameFromHandle (HandleBuffer
[Index
]); // Name is put into mGaugeString
585 // Ensure that the argument strings are not too long.
586 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
587 mUnicodeToken
[11] = 0;
588 if (mGaugeString
[0] != 0) {
589 // Display the record if it has a valid handle.
591 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS2
), gDpHiiHandle
,
592 Count
, // 1 based, Which measurement record is being printed
593 Index
+ 1, // 1 based, Which handle is being printed
597 Measurement
.Identifier
600 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS
), gDpHiiHandle
,
601 Count
, // 1 based, Which measurement record is being printed
602 Index
+ 1, // 1 based, Which handle is being printed
609 if (ShellGetExecutionBreakFlag ()) {
610 Status
= EFI_ABORTED
;
615 if (HandleBuffer
!= NULL
) {
616 FreePool (HandleBuffer
);
622 Gather and print PEIM data.
624 Only prints complete PEIM records
626 @retval EFI_SUCCESS The operation was successful.
627 @retval EFI_ABORTED The user aborts the operation.
634 MEASUREMENT_RECORD Measurement
;
637 EFI_STRING StringPtr
;
640 EFI_STRING StringPtrUnknown
;
643 Status
= EFI_SUCCESS
;
645 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
646 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PEIMS
), NULL
);
647 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
648 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
649 FreePool (StringPtr
);
650 FreePool (StringPtrUnknown
);
653 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION2
), gDpHiiHandle
);
655 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION
), gDpHiiHandle
);
657 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
660 while ((LogEntryKey
= GetPerformanceMeasurementEx (
665 &Measurement
.StartTimeStamp
,
666 &Measurement
.EndTimeStamp
,
667 &Measurement
.Identifier
)) != 0)
670 if ((Measurement
.EndTimeStamp
== 0) ||
671 (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) != 0)
676 Duration
= GetDuration (&Measurement
);
677 ElapsedTime
= DurationInMicroSeconds ( Duration
); // Calculate elapsed time in microseconds
678 if (ElapsedTime
>= mInterestThreshold
) {
679 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
681 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS2
), gDpHiiHandle
,
682 TIndex
, // 1 based, Which measurement record is being printed
683 Measurement
.Handle
, // base address
684 Measurement
.Handle
, // file guid
686 Measurement
.Identifier
689 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS
), gDpHiiHandle
,
690 TIndex
, // 1 based, Which measurement record is being printed
691 Measurement
.Handle
, // base address
692 Measurement
.Handle
, // file guid
697 if (ShellGetExecutionBreakFlag ()) {
698 Status
= EFI_ABORTED
;
706 Gather and print global data.
708 Strips out incomplete or "Execution Phase" records
709 Only prints records where Handle is NULL
710 Increment TIndex for every record, even skipped ones, so that we have an
711 indication of every measurement record taken.
713 @retval EFI_SUCCESS The operation was successful.
714 @retval EFI_ABORTED The user aborts the operation.
721 MEASUREMENT_RECORD Measurement
;
724 EFI_STRING StringPtr
;
726 UINTN Index
; // Index, or number, of the measurement record being processed
727 EFI_STRING StringPtrUnknown
;
730 Status
= EFI_SUCCESS
;
732 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
733 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_GENERAL
), NULL
);
734 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
735 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
736 FreePool (StringPtr
);
737 FreePool (StringPtrUnknown
);
740 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION2
), gDpHiiHandle
);
742 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION
), gDpHiiHandle
);
744 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
749 while ((LogEntryKey
= GetPerformanceMeasurementEx (
754 &Measurement
.StartTimeStamp
,
755 &Measurement
.EndTimeStamp
,
756 &Measurement
.Identifier
)) != 0)
758 AsciiStrToUnicodeStrS (Measurement
.Module
, mGaugeString
, ARRAY_SIZE (mGaugeString
));
759 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
760 mGaugeString
[25] = 0;
761 mUnicodeToken
[31] = 0;
762 if ( ! ( IsPhase( &Measurement
) ||
763 (Measurement
.Handle
!= NULL
) ||
764 (Measurement
.EndTimeStamp
== 0)
767 Duration
= GetDuration (&Measurement
);
768 ElapsedTime
= DurationInMicroSeconds ( Duration
);
769 if (ElapsedTime
>= mInterestThreshold
) {
771 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS2
), gDpHiiHandle
,
776 Measurement
.Identifier
779 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS
), gDpHiiHandle
,
788 if (ShellGetExecutionBreakFlag ()) {
789 Status
= EFI_ABORTED
;
798 Gather and print cumulative data.
800 Traverse the measurement records and:<BR>
801 For each record with a Token listed in the CumData array:<BR>
802 - Update the instance count and the total, minimum, and maximum durations.
803 Finally, print the gathered cumulative statistics.
805 @param[in] CustomCumulativeData A pointer to the cumtom cumulative data.
810 IN PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
813 UINT64 AvgDur
; // the computed average duration
817 EFI_STRING StringPtr
;
819 EFI_STRING StringPtrUnknown
;
821 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
822 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE
), NULL
);
823 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
824 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
825 FreePool (StringPtr
);
826 FreePool (StringPtrUnknown
);
828 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1
), gDpHiiHandle
);
829 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2
), gDpHiiHandle
);
830 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
832 for ( TIndex
= 0; TIndex
< NumCum
; ++TIndex
) {
833 if (CumData
[TIndex
].Count
!= 0) {
834 AvgDur
= DivU64x32 (CumData
[TIndex
].Duration
, CumData
[TIndex
].Count
);
835 AvgDur
= DurationInMicroSeconds(AvgDur
);
836 Dur
= DurationInMicroSeconds(CumData
[TIndex
].Duration
);
837 MaxDur
= DurationInMicroSeconds(CumData
[TIndex
].MaxDur
);
838 MinDur
= DurationInMicroSeconds(CumData
[TIndex
].MinDur
);
840 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), gDpHiiHandle
,
841 CumData
[TIndex
].Name
,
842 CumData
[TIndex
].Count
,
852 // Print the custom cumulative data.
854 if (CustomCumulativeData
!= NULL
) {
855 if (CustomCumulativeData
->Count
!= 0) {
856 AvgDur
= DivU64x32 (CustomCumulativeData
->Duration
, CustomCumulativeData
->Count
);
857 AvgDur
= DurationInMicroSeconds (AvgDur
);
858 Dur
= DurationInMicroSeconds (CustomCumulativeData
->Duration
);
859 MaxDur
= DurationInMicroSeconds (CustomCumulativeData
->MaxDur
);
860 MinDur
= DurationInMicroSeconds (CustomCumulativeData
->MinDur
);
867 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), gDpHiiHandle
,
868 CustomCumulativeData
->Name
,
869 CustomCumulativeData
->Count
,