2 Trace reporting for the Dp utility.
4 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #include <Library/BaseLib.h>
15 #include <Library/BaseMemoryLib.h>
16 #include <Library/MemoryAllocationLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/UefiBootServicesTableLib.h>
19 #include <Library/TimerLib.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.
51 MEASUREMENT_RECORD Measurement
;
57 while ((LogEntryKey
= GetPerformanceMeasurementEx (
62 &Measurement
.StartTimeStamp
,
63 &Measurement
.EndTimeStamp
,
64 &Measurement
.Identifier
)) != 0)
66 ++SummaryData
.NumTrace
; // Count the number of TRACE Measurement records
67 if (Measurement
.EndTimeStamp
== 0) {
68 ++SummaryData
.NumIncomplete
; // Count the incomplete records
72 if (Measurement
.Handle
!= NULL
) {
73 ++SummaryData
.NumHandles
; // Count the number of measurements with non-NULL handles
76 if (IsPhase( &Measurement
)) {
77 ++SummaryData
.NumSummary
; // Count the number of major phases
79 else { // !IsPhase(...
80 if(Measurement
.Handle
== NULL
) {
81 ++SummaryData
.NumGlobal
;
85 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
86 ++SummaryData
.NumPEIMs
; // Count PEIM measurements
89 Duration
= GetDuration (&Measurement
);
90 TIndex
= GetCumulativeItem (&Measurement
);
92 CumData
[TIndex
].Duration
+= Duration
;
93 CumData
[TIndex
].Count
++;
94 if ( Duration
< CumData
[TIndex
].MinDur
) {
95 CumData
[TIndex
].MinDur
= Duration
;
97 if ( Duration
> CumData
[TIndex
].MaxDur
) {
98 CumData
[TIndex
].MaxDur
= Duration
;
105 Gather and print ALL Trace Records.
107 Displays all "interesting" Trace measurements in order.<BR>
108 The number of records displayed is controlled by:
109 - records with a duration less than mInterestThreshold microseconds are not displayed.
110 - No more than Limit records are displayed. A Limit of zero will not limit the output.
111 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
114 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
115 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
116 They must not be in use by a calling function.
118 @param[in] Limit The number of records to print. Zero is ALL.
119 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
125 IN BOOLEAN ExcludeFlag
128 MEASUREMENT_RECORD Measurement
;
137 EFI_HANDLE
*HandleBuffer
;
139 EFI_HANDLE TempHandle
;
141 EFI_STRING StringPtrUnknown
;
143 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
144 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_ALL
), NULL
);
145 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
146 (IncFlag
== NULL
) ? StringPtrUnknown
: IncFlag
);
147 FreePool (StringPtrUnknown
);
149 // Get Handle information
152 HandleBuffer
= &TempHandle
;
153 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, &TempHandle
);
154 if (Status
== EFI_BUFFER_TOO_SMALL
) {
155 HandleBuffer
= AllocatePool (Size
);
156 ASSERT (HandleBuffer
!= NULL
);
157 if (HandleBuffer
== NULL
) {
160 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, HandleBuffer
);
162 if (EFI_ERROR (Status
)) {
163 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), gDpHiiHandle
, Status
);
166 // We have successfully populated the HandleBuffer
167 // Display ALL Measurement Records
168 // Up to Limit lines displayed
169 // Display only records with Elapsed times >= mInterestThreshold
170 // Display driver names in Module field for records with Handles.
173 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR2
), gDpHiiHandle
);
174 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_DASHES2
), gDpHiiHandle
);
176 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR
), gDpHiiHandle
);
177 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
183 while ( WITHIN_LIMIT(Count
, Limit
) &&
184 ((LogEntryKey
= GetPerformanceMeasurementEx (
189 &Measurement
.StartTimeStamp
,
190 &Measurement
.EndTimeStamp
,
191 &Measurement
.Identifier
)) != 0)
194 ++Index
; // Count every record. First record is 1.
196 SHELL_FREE_NON_NULL (IncFlag
);
197 if (Measurement
.EndTimeStamp
!= 0) {
198 Duration
= GetDuration (&Measurement
);
199 ElapsedTime
= DurationInMicroSeconds ( Duration
);
200 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_COMPLETE
), NULL
);
203 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_INCOMPLETE
), NULL
); // Mark incomplete records
205 if (((Measurement
.EndTimeStamp
!= 0) && (ElapsedTime
< mInterestThreshold
)) ||
206 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
207 ) { // Ignore "uninteresting" or excluded records
210 ++Count
; // Count the number of records printed
212 // If Handle is non-zero, see if we can determine a name for the driver
213 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
); // Use Module by default
214 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
215 if (Measurement
.Handle
!= NULL
) {
216 // See if the Handle is in the HandleBuffer
217 for (TIndex
= 0; TIndex
< (Size
/ sizeof(HandleBuffer
[0])); TIndex
++) {
218 if (Measurement
.Handle
== HandleBuffer
[TIndex
]) {
219 GetNameFromHandle (HandleBuffer
[TIndex
]);
225 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
226 UnicodeSPrint (mGaugeString
, sizeof (mGaugeString
), L
"%g", Measurement
.Handle
);
229 // Ensure that the argument strings are not too long.
230 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
231 mUnicodeToken
[13] = 0;
234 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS2
), gDpHiiHandle
,
235 Index
, // 1 based, Which measurement record is being printed
241 Measurement
.Identifier
244 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS
), gDpHiiHandle
,
245 Index
, // 1 based, Which measurement record is being printed
255 if (HandleBuffer
!= &TempHandle
) {
256 FreePool (HandleBuffer
);
258 SHELL_FREE_NON_NULL (IncFlag
);
262 Gather and print Raw Trace Records.
264 All Trace measurements with a duration greater than or equal to
265 mInterestThreshold are printed without interpretation.
267 The number of records displayed is controlled by:
268 - records with a duration less than mInterestThreshold microseconds are not displayed.
269 - No more than Limit records are displayed. A Limit of zero will not limit the output.
270 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
273 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
275 @param[in] Limit The number of records to print. Zero is ALL.
276 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
282 IN BOOLEAN ExcludeFlag
285 MEASUREMENT_RECORD Measurement
;
292 EFI_STRING StringPtr
;
293 EFI_STRING StringPtrUnknown
;
295 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
296 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_RAWTRACE
), NULL
);
297 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
298 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
299 FreePool (StringPtr
);
300 FreePool (StringPtrUnknown
);
303 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR2
), gDpHiiHandle
);
304 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES2
), gDpHiiHandle
);
306 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR
), gDpHiiHandle
);
307 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES
), gDpHiiHandle
);
313 while ( WITHIN_LIMIT(Count
, Limit
) &&
314 ((LogEntryKey
= GetPerformanceMeasurementEx (
319 &Measurement
.StartTimeStamp
,
320 &Measurement
.EndTimeStamp
,
321 &Measurement
.Identifier
)) != 0)
324 ++Index
; // Count every record. First record is 1.
326 if (Measurement
.EndTimeStamp
!= 0) {
327 Duration
= GetDuration (&Measurement
);
328 ElapsedTime
= DurationInMicroSeconds ( Duration
);
330 if ((ElapsedTime
< mInterestThreshold
) ||
331 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
332 ) { // Ignore "uninteresting" or Excluded records
335 ++Count
; // Count the number of records printed
338 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS2
), gDpHiiHandle
,
339 Index
, // 1 based, Which measurement record is being printed
341 Measurement
.StartTimeStamp
,
342 Measurement
.EndTimeStamp
,
345 Measurement
.Identifier
348 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS
), gDpHiiHandle
,
349 Index
, // 1 based, Which measurement record is being printed
351 Measurement
.StartTimeStamp
,
352 Measurement
.EndTimeStamp
,
361 Gather and print Major Phase metrics.
363 @param[in] Ticker The timer value for the END of Shell phase
371 MEASUREMENT_RECORD Measurement
;
372 UINT64 BdsTimeoutValue
;
381 EFI_STRING StringPtr
;
383 EFI_STRING StringPtrUnknown
;
392 // Get Execution Phase Statistics
394 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
395 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PHASES
), NULL
);
396 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
397 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
398 FreePool (StringPtr
);
399 FreePool (StringPtrUnknown
);
402 while ((LogEntryKey
= GetPerformanceMeasurementEx (
407 &Measurement
.StartTimeStamp
,
408 &Measurement
.EndTimeStamp
,
409 &Measurement
.Identifier
)) != 0)
411 if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
412 Measurement
.EndTimeStamp
= Ticker
;
414 if (Measurement
.EndTimeStamp
== 0) { // Skip "incomplete" records
417 Duration
= GetDuration (&Measurement
);
418 if ( Measurement
.Handle
!= NULL
419 && (AsciiStrnCmp (Measurement
.Token
, ALit_BdsTO
, PERF_TOKEN_LENGTH
) == 0)
422 BdsTimeoutValue
= Duration
;
423 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SEC
, PERF_TOKEN_LENGTH
) == 0) {
425 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_PEI
, PERF_TOKEN_LENGTH
) == 0) {
427 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_DXE
, PERF_TOKEN_LENGTH
) == 0) {
429 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_BDS
, PERF_TOKEN_LENGTH
) == 0) {
431 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
432 ShellTime
= Duration
;
438 // print SEC phase duration time
441 ElapsedTime
= DurationInMicroSeconds ( SecTime
); // Calculate elapsed time in microseconds
442 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
443 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SEC_PHASE
), gDpHiiHandle
, ElapsedTime
);
446 // print PEI phase duration time
449 ElapsedTime
= DivU64x32 (
451 (UINT32
)TimerInfo
.Frequency
453 Total
+= ElapsedTime
;
454 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_PEI
, ElapsedTime
);
457 // print DXE phase duration time
460 ElapsedTime
= DivU64x32 (
462 (UINT32
)TimerInfo
.Frequency
464 Total
+= ElapsedTime
;
465 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_DXE
, ElapsedTime
);
468 // print BDS phase duration time
471 ElapsedTime
= DivU64x32 (
473 (UINT32
)TimerInfo
.Frequency
475 Total
+= ElapsedTime
;
476 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_BDS
, ElapsedTime
);
479 if (BdsTimeoutValue
> 0) {
480 ElapsedTime
= DivU64x32 (
482 (UINT32
)TimerInfo
.Frequency
484 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_BDSTO
), gDpHiiHandle
, ALit_BdsTO
, ElapsedTime
);
487 // print SHELL phase duration time
490 ElapsedTime
= DivU64x32 (
492 (UINT32
)TimerInfo
.Frequency
494 Total
+= ElapsedTime
;
495 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_SHELL
, ElapsedTime
);
498 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_TOTAL_DURATION
), gDpHiiHandle
, Total
);
502 Gather and print Handle data.
504 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
506 @return Status from a call to gBS->LocateHandle().
510 IN BOOLEAN ExcludeFlag
513 MEASUREMENT_RECORD Measurement
;
516 EFI_HANDLE
*HandleBuffer
;
517 EFI_STRING StringPtr
;
522 EFI_HANDLE TempHandle
;
524 EFI_STRING StringPtrUnknown
;
526 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
527 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_DRIVERS
), NULL
);
528 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
529 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
530 FreePool (StringPtr
);
531 FreePool (StringPtrUnknown
);
534 HandleBuffer
= &TempHandle
;
535 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, &TempHandle
);
536 if (Status
== EFI_BUFFER_TOO_SMALL
) {
537 HandleBuffer
= AllocatePool (Size
);
538 ASSERT (HandleBuffer
!= NULL
);
539 if (HandleBuffer
== NULL
) {
542 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, HandleBuffer
);
544 if (EFI_ERROR (Status
)) {
545 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), gDpHiiHandle
, Status
);
549 Print (L
"There are %,d Handles defined.\n", (Size
/ sizeof(HandleBuffer
[0])));
553 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION2
), gDpHiiHandle
);
555 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION
), gDpHiiHandle
);
557 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
561 while ((LogEntryKey
= GetPerformanceMeasurementEx (
566 &Measurement
.StartTimeStamp
,
567 &Measurement
.EndTimeStamp
,
568 &Measurement
.Identifier
)) != 0)
571 Duration
= GetDuration (&Measurement
);
572 ElapsedTime
= DurationInMicroSeconds ( Duration
);
573 if ((ElapsedTime
< mInterestThreshold
) ||
574 (Measurement
.EndTimeStamp
== 0) ||
575 (Measurement
.Handle
== NULL
) ||
576 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
577 ) { // Ignore "uninteresting" or excluded records
580 mGaugeString
[0] = 0; // Empty driver name by default
581 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
582 // See if the Handle is in the HandleBuffer
583 for (Index
= 0; Index
< (Size
/ sizeof(HandleBuffer
[0])); Index
++) {
584 if (Measurement
.Handle
== HandleBuffer
[Index
]) {
585 GetNameFromHandle (HandleBuffer
[Index
]); // Name is put into mGaugeString
589 // Ensure that the argument strings are not too long.
590 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
591 mUnicodeToken
[11] = 0;
592 if (mGaugeString
[0] != 0) {
593 // Display the record if it has a valid handle.
595 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS2
), gDpHiiHandle
,
596 Count
, // 1 based, Which measurement record is being printed
597 Index
+ 1, // 1 based, Which handle is being printed
601 Measurement
.Identifier
604 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS
), gDpHiiHandle
,
605 Count
, // 1 based, Which measurement record is being printed
606 Index
+ 1, // 1 based, Which handle is being printed
615 if (HandleBuffer
!= &TempHandle
) {
616 FreePool (HandleBuffer
);
622 Gather and print PEIM data.
624 Only prints complete PEIM records
632 MEASUREMENT_RECORD Measurement
;
635 EFI_STRING StringPtr
;
638 EFI_STRING StringPtrUnknown
;
640 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
641 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PEIMS
), NULL
);
642 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
643 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
644 FreePool (StringPtr
);
645 FreePool (StringPtrUnknown
);
648 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION2
), gDpHiiHandle
);
650 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION
), gDpHiiHandle
);
652 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
655 while ((LogEntryKey
= GetPerformanceMeasurementEx (
660 &Measurement
.StartTimeStamp
,
661 &Measurement
.EndTimeStamp
,
662 &Measurement
.Identifier
)) != 0)
665 if ((Measurement
.EndTimeStamp
== 0) ||
666 (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) != 0)
671 Duration
= GetDuration (&Measurement
);
672 ElapsedTime
= DurationInMicroSeconds ( Duration
); // Calculate elapsed time in microseconds
673 if (ElapsedTime
>= mInterestThreshold
) {
674 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
676 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS2
), gDpHiiHandle
,
677 TIndex
, // 1 based, Which measurement record is being printed
678 Measurement
.Handle
, // base address
679 Measurement
.Handle
, // file guid
681 Measurement
.Identifier
684 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS
), gDpHiiHandle
,
685 TIndex
, // 1 based, Which measurement record is being printed
686 Measurement
.Handle
, // base address
687 Measurement
.Handle
, // file guid
696 Gather and print global data.
698 Strips out incomplete or "Execution Phase" records
699 Only prints records where Handle is NULL
700 Increment TIndex for every record, even skipped ones, so that we have an
701 indication of every measurement record taken.
709 MEASUREMENT_RECORD Measurement
;
712 EFI_STRING StringPtr
;
714 UINTN Index
; // Index, or number, of the measurement record being processed
715 EFI_STRING StringPtrUnknown
;
717 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
718 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_GENERAL
), NULL
);
719 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
720 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
721 FreePool (StringPtr
);
722 FreePool (StringPtrUnknown
);
725 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION2
), gDpHiiHandle
);
727 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION
), gDpHiiHandle
);
729 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
734 while ((LogEntryKey
= GetPerformanceMeasurementEx (
739 &Measurement
.StartTimeStamp
,
740 &Measurement
.EndTimeStamp
,
741 &Measurement
.Identifier
)) != 0)
743 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
);
744 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
745 mGaugeString
[25] = 0;
746 mUnicodeToken
[31] = 0;
747 if ( ! ( IsPhase( &Measurement
) ||
748 (Measurement
.Handle
!= NULL
) ||
749 (Measurement
.EndTimeStamp
== 0)
752 Duration
= GetDuration (&Measurement
);
753 ElapsedTime
= DurationInMicroSeconds ( Duration
);
754 if (ElapsedTime
>= mInterestThreshold
) {
756 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS2
), gDpHiiHandle
,
761 Measurement
.Identifier
764 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS
), gDpHiiHandle
,
778 Gather and print cumulative data.
780 Traverse the measurement records and:<BR>
781 For each record with a Token listed in the CumData array:<BR>
782 - Update the instance count and the total, minimum, and maximum durations.
783 Finally, print the gathered cumulative statistics.
791 UINT64 AvgDur
; // the computed average duration
795 EFI_STRING StringPtr
;
797 EFI_STRING StringPtrUnknown
;
799 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
800 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE
), NULL
);
801 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
802 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
803 FreePool (StringPtr
);
804 FreePool (StringPtrUnknown
);
806 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1
), gDpHiiHandle
);
807 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2
), gDpHiiHandle
);
808 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
810 for ( TIndex
= 0; TIndex
< NumCum
; ++TIndex
) {
811 if (CumData
[TIndex
].Count
!= 0) {
812 AvgDur
= DivU64x32 (CumData
[TIndex
].Duration
, CumData
[TIndex
].Count
);
813 AvgDur
= DurationInMicroSeconds(AvgDur
);
814 Dur
= DurationInMicroSeconds(CumData
[TIndex
].Duration
);
815 MaxDur
= DurationInMicroSeconds(CumData
[TIndex
].MaxDur
);
816 MinDur
= DurationInMicroSeconds(CumData
[TIndex
].MinDur
);
818 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), gDpHiiHandle
,
819 CumData
[TIndex
].Name
,
820 CumData
[TIndex
].Count
,