2 Trace reporting for the Dp utility.
4 Copyright (c) 2009 - 2013, 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.
143 IN BOOLEAN ExcludeFlag
146 MEASUREMENT_RECORD Measurement
;
155 EFI_HANDLE
*HandleBuffer
;
158 EFI_STRING StringPtrUnknown
;
160 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
161 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_ALL
), NULL
);
162 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
163 (IncFlag
== NULL
) ? StringPtrUnknown
: IncFlag
);
164 FreePool (StringPtrUnknown
);
166 // Get Handle information
168 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
169 if (EFI_ERROR (Status
)) {
170 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), gDpHiiHandle
, Status
);
173 // We have successfully populated the HandleBuffer
174 // Display ALL Measurement Records
175 // Up to Limit lines displayed
176 // Display only records with Elapsed times >= mInterestThreshold
177 // Display driver names in Module field for records with Handles.
180 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR2
), gDpHiiHandle
);
181 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_DASHES2
), gDpHiiHandle
);
183 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR
), gDpHiiHandle
);
184 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
190 while ( WITHIN_LIMIT(Count
, Limit
) &&
191 ((LogEntryKey
= GetPerformanceMeasurementEx (
196 &Measurement
.StartTimeStamp
,
197 &Measurement
.EndTimeStamp
,
198 &Measurement
.Identifier
)) != 0)
201 ++Index
; // Count every record. First record is 1.
203 SHELL_FREE_NON_NULL (IncFlag
);
204 if (Measurement
.EndTimeStamp
!= 0) {
205 Duration
= GetDuration (&Measurement
);
206 ElapsedTime
= DurationInMicroSeconds ( Duration
);
207 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_COMPLETE
), NULL
);
210 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_INCOMPLETE
), NULL
); // Mark incomplete records
212 if (((Measurement
.EndTimeStamp
!= 0) && (ElapsedTime
< mInterestThreshold
)) ||
213 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
214 ) { // Ignore "uninteresting" or excluded records
217 ++Count
; // Count the number of records printed
219 // If Handle is non-zero, see if we can determine a name for the driver
220 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
); // Use Module by default
221 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
222 if (Measurement
.Handle
!= NULL
) {
223 // See if the Handle is in the HandleBuffer
224 for (TIndex
= 0; TIndex
< HandleCount
; TIndex
++) {
225 if (Measurement
.Handle
== HandleBuffer
[TIndex
]) {
226 DpGetNameFromHandle (HandleBuffer
[TIndex
]);
232 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
233 UnicodeSPrint (mGaugeString
, sizeof (mGaugeString
), L
"%g", Measurement
.Handle
);
236 // Ensure that the argument strings are not too long.
237 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
238 mUnicodeToken
[13] = 0;
241 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS2
), gDpHiiHandle
,
242 Index
, // 1 based, Which measurement record is being printed
248 Measurement
.Identifier
251 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS
), gDpHiiHandle
,
252 Index
, // 1 based, Which measurement record is being printed
262 if (HandleBuffer
!= NULL
) {
263 FreePool (HandleBuffer
);
265 SHELL_FREE_NON_NULL (IncFlag
);
269 Gather and print Raw Trace Records.
271 All Trace measurements with a duration greater than or equal to
272 mInterestThreshold are printed without interpretation.
274 The number of records displayed is controlled by:
275 - records with a duration less than mInterestThreshold microseconds are not displayed.
276 - No more than Limit records are displayed. A Limit of zero will not limit the output.
277 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
280 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
282 @param[in] Limit The number of records to print. Zero is ALL.
283 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
289 IN BOOLEAN ExcludeFlag
292 MEASUREMENT_RECORD Measurement
;
299 EFI_STRING StringPtr
;
300 EFI_STRING StringPtrUnknown
;
302 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
303 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_RAWTRACE
), NULL
);
304 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
305 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
306 FreePool (StringPtr
);
307 FreePool (StringPtrUnknown
);
310 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR2
), gDpHiiHandle
);
311 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES2
), gDpHiiHandle
);
313 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR
), gDpHiiHandle
);
314 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES
), gDpHiiHandle
);
320 while ( WITHIN_LIMIT(Count
, Limit
) &&
321 ((LogEntryKey
= GetPerformanceMeasurementEx (
326 &Measurement
.StartTimeStamp
,
327 &Measurement
.EndTimeStamp
,
328 &Measurement
.Identifier
)) != 0)
331 ++Index
; // Count every record. First record is 1.
333 if (Measurement
.EndTimeStamp
!= 0) {
334 Duration
= GetDuration (&Measurement
);
335 ElapsedTime
= DurationInMicroSeconds ( Duration
);
337 if ((ElapsedTime
< mInterestThreshold
) ||
338 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
339 ) { // Ignore "uninteresting" or Excluded records
342 ++Count
; // Count the number of records printed
345 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS2
), gDpHiiHandle
,
346 Index
, // 1 based, Which measurement record is being printed
348 Measurement
.StartTimeStamp
,
349 Measurement
.EndTimeStamp
,
352 Measurement
.Identifier
355 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS
), gDpHiiHandle
,
356 Index
, // 1 based, Which measurement record is being printed
358 Measurement
.StartTimeStamp
,
359 Measurement
.EndTimeStamp
,
368 Gather and print Major Phase metrics.
370 @param[in] Ticker The timer value for the END of Shell phase
378 MEASUREMENT_RECORD Measurement
;
379 UINT64 BdsTimeoutValue
;
388 EFI_STRING StringPtr
;
390 EFI_STRING StringPtrUnknown
;
399 // Get Execution Phase Statistics
401 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
402 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PHASES
), NULL
);
403 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
404 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
405 FreePool (StringPtr
);
406 FreePool (StringPtrUnknown
);
409 while ((LogEntryKey
= GetPerformanceMeasurementEx (
414 &Measurement
.StartTimeStamp
,
415 &Measurement
.EndTimeStamp
,
416 &Measurement
.Identifier
)) != 0)
418 if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
419 Measurement
.EndTimeStamp
= Ticker
;
421 if (Measurement
.EndTimeStamp
== 0) { // Skip "incomplete" records
424 Duration
= GetDuration (&Measurement
);
425 if ( Measurement
.Handle
!= NULL
426 && (AsciiStrnCmp (Measurement
.Token
, ALit_BdsTO
, PERF_TOKEN_LENGTH
) == 0)
429 BdsTimeoutValue
= Duration
;
430 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SEC
, PERF_TOKEN_LENGTH
) == 0) {
432 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_PEI
, PERF_TOKEN_LENGTH
) == 0) {
434 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_DXE
, PERF_TOKEN_LENGTH
) == 0) {
436 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_BDS
, PERF_TOKEN_LENGTH
) == 0) {
438 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
439 ShellTime
= Duration
;
445 // print SEC phase duration time
448 ElapsedTime
= DurationInMicroSeconds ( SecTime
); // Calculate elapsed time in microseconds
449 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
450 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SEC_PHASE
), gDpHiiHandle
, ElapsedTime
);
453 // print PEI phase duration time
456 ElapsedTime
= DivU64x32 (
458 (UINT32
)TimerInfo
.Frequency
460 Total
+= ElapsedTime
;
461 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_PEI
, ElapsedTime
);
464 // print DXE phase duration time
467 ElapsedTime
= DivU64x32 (
469 (UINT32
)TimerInfo
.Frequency
471 Total
+= ElapsedTime
;
472 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_DXE
, ElapsedTime
);
475 // print BDS phase duration time
478 ElapsedTime
= DivU64x32 (
480 (UINT32
)TimerInfo
.Frequency
482 Total
+= ElapsedTime
;
483 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_BDS
, ElapsedTime
);
486 if (BdsTimeoutValue
> 0) {
487 ElapsedTime
= DivU64x32 (
489 (UINT32
)TimerInfo
.Frequency
491 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_BDSTO
), gDpHiiHandle
, ALit_BdsTO
, ElapsedTime
);
494 // print SHELL 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_SHELL
, ElapsedTime
);
505 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_TOTAL_DURATION
), gDpHiiHandle
, Total
);
509 Gather and print Handle data.
511 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
513 @return Status from a call to gBS->LocateHandle().
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 AsciiStrToUnicodeStr (Measurement
.Token
, 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
611 if (HandleBuffer
!= NULL
) {
612 FreePool (HandleBuffer
);
618 Gather and print PEIM data.
620 Only prints complete PEIM records
628 MEASUREMENT_RECORD Measurement
;
631 EFI_STRING StringPtr
;
634 EFI_STRING StringPtrUnknown
;
636 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
637 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PEIMS
), NULL
);
638 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
639 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
640 FreePool (StringPtr
);
641 FreePool (StringPtrUnknown
);
644 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION2
), gDpHiiHandle
);
646 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION
), gDpHiiHandle
);
648 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
651 while ((LogEntryKey
= GetPerformanceMeasurementEx (
656 &Measurement
.StartTimeStamp
,
657 &Measurement
.EndTimeStamp
,
658 &Measurement
.Identifier
)) != 0)
661 if ((Measurement
.EndTimeStamp
== 0) ||
662 (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) != 0)
667 Duration
= GetDuration (&Measurement
);
668 ElapsedTime
= DurationInMicroSeconds ( Duration
); // Calculate elapsed time in microseconds
669 if (ElapsedTime
>= mInterestThreshold
) {
670 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
672 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS2
), gDpHiiHandle
,
673 TIndex
, // 1 based, Which measurement record is being printed
674 Measurement
.Handle
, // base address
675 Measurement
.Handle
, // file guid
677 Measurement
.Identifier
680 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS
), gDpHiiHandle
,
681 TIndex
, // 1 based, Which measurement record is being printed
682 Measurement
.Handle
, // base address
683 Measurement
.Handle
, // file guid
692 Gather and print global data.
694 Strips out incomplete or "Execution Phase" records
695 Only prints records where Handle is NULL
696 Increment TIndex for every record, even skipped ones, so that we have an
697 indication of every measurement record taken.
705 MEASUREMENT_RECORD Measurement
;
708 EFI_STRING StringPtr
;
710 UINTN Index
; // Index, or number, of the measurement record being processed
711 EFI_STRING StringPtrUnknown
;
713 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
714 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_GENERAL
), NULL
);
715 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
716 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
717 FreePool (StringPtr
);
718 FreePool (StringPtrUnknown
);
721 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION2
), gDpHiiHandle
);
723 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION
), gDpHiiHandle
);
725 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
730 while ((LogEntryKey
= GetPerformanceMeasurementEx (
735 &Measurement
.StartTimeStamp
,
736 &Measurement
.EndTimeStamp
,
737 &Measurement
.Identifier
)) != 0)
739 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
);
740 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
741 mGaugeString
[25] = 0;
742 mUnicodeToken
[31] = 0;
743 if ( ! ( IsPhase( &Measurement
) ||
744 (Measurement
.Handle
!= NULL
) ||
745 (Measurement
.EndTimeStamp
== 0)
748 Duration
= GetDuration (&Measurement
);
749 ElapsedTime
= DurationInMicroSeconds ( Duration
);
750 if (ElapsedTime
>= mInterestThreshold
) {
752 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS2
), gDpHiiHandle
,
757 Measurement
.Identifier
760 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS
), gDpHiiHandle
,
774 Gather and print cumulative data.
776 Traverse the measurement records and:<BR>
777 For each record with a Token listed in the CumData array:<BR>
778 - Update the instance count and the total, minimum, and maximum durations.
779 Finally, print the gathered cumulative statistics.
781 @param[in] CustomCumulativeData A pointer to the cumtom cumulative data.
786 IN PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
789 UINT64 AvgDur
; // the computed average duration
793 EFI_STRING StringPtr
;
795 EFI_STRING StringPtrUnknown
;
797 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
798 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE
), NULL
);
799 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
800 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
801 FreePool (StringPtr
);
802 FreePool (StringPtrUnknown
);
804 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1
), gDpHiiHandle
);
805 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2
), gDpHiiHandle
);
806 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
808 for ( TIndex
= 0; TIndex
< NumCum
; ++TIndex
) {
809 if (CumData
[TIndex
].Count
!= 0) {
810 AvgDur
= DivU64x32 (CumData
[TIndex
].Duration
, CumData
[TIndex
].Count
);
811 AvgDur
= DurationInMicroSeconds(AvgDur
);
812 Dur
= DurationInMicroSeconds(CumData
[TIndex
].Duration
);
813 MaxDur
= DurationInMicroSeconds(CumData
[TIndex
].MaxDur
);
814 MinDur
= DurationInMicroSeconds(CumData
[TIndex
].MinDur
);
816 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), gDpHiiHandle
,
817 CumData
[TIndex
].Name
,
818 CumData
[TIndex
].Count
,
828 // Print the custom cumulative data.
830 if (CustomCumulativeData
!= NULL
) {
831 if (CustomCumulativeData
->Count
!= 0) {
832 AvgDur
= DivU64x32 (CustomCumulativeData
->Duration
, CustomCumulativeData
->Count
);
833 AvgDur
= DurationInMicroSeconds (AvgDur
);
834 Dur
= DurationInMicroSeconds (CustomCumulativeData
->Duration
);
835 MaxDur
= DurationInMicroSeconds (CustomCumulativeData
->MaxDur
);
836 MinDur
= DurationInMicroSeconds (CustomCumulativeData
->MinDur
);
843 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), gDpHiiHandle
,
844 CustomCumulativeData
->Name
,
845 CustomCumulativeData
->Count
,