2 Trace reporting for the Dp utility.
4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2015 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
;
149 const CHAR16
*IncFlag
;
155 EFI_HANDLE
*HandleBuffer
;
157 EFI_HANDLE TempHandle
;
159 EFI_STRING StringPtrUnknown
;
161 StringPtrUnknown
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
162 IncFlag
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_DP_SECTION_ALL
), NULL
);
163 PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER
),
164 (IncFlag
== NULL
) ? StringPtrUnknown
: IncFlag
);
165 FreePool (StringPtrUnknown
);
167 // Get Handle information
170 HandleBuffer
= &TempHandle
;
171 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, &TempHandle
);
172 if (Status
== EFI_BUFFER_TOO_SMALL
) {
173 HandleBuffer
= AllocatePool (Size
);
174 ASSERT (HandleBuffer
!= NULL
);
175 if (HandleBuffer
== NULL
) {
178 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, HandleBuffer
);
180 if (EFI_ERROR (Status
)) {
181 PrintToken (STRING_TOKEN (STR_DP_HANDLES_ERROR
), Status
);
184 // We have successfully populated the HandleBuffer
185 // Display ALL Measurement Records
186 // Up to Limit lines displayed
187 // Display only records with Elapsed times >= mInterestThreshold
188 // Display driver names in Module field for records with Handles.
191 PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR2
) );
192 PrintToken (STRING_TOKEN (STR_DP_ALL_DASHES2
) );
194 PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR
) );
195 PrintToken (STRING_TOKEN (STR_DP_DASHES
) );
201 while ( WITHIN_LIMIT(Count
, Limit
) &&
202 ((LogEntryKey
= GetPerformanceMeasurementEx (
207 &Measurement
.StartTimeStamp
,
208 &Measurement
.EndTimeStamp
,
209 &Measurement
.Identifier
)) != 0)
212 ++Index
; // Count every record. First record is 1.
214 SafeFreePool ((VOID
*) IncFlag
);
215 if (Measurement
.EndTimeStamp
!= 0) {
216 Duration
= GetDuration (&Measurement
);
217 ElapsedTime
= DurationInMicroSeconds ( Duration
);
218 IncFlag
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_DP_COMPLETE
), NULL
);
221 IncFlag
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_DP_INCOMPLETE
), NULL
); // Mark incomplete records
223 if (((Measurement
.EndTimeStamp
!= 0) && (ElapsedTime
< mInterestThreshold
)) ||
224 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
225 ) { // Ignore "uninteresting" or excluded records
228 ++Count
; // Count the number of records printed
230 // If Handle is non-zero, see if we can determine a name for the driver
231 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
); // Use Module by default
232 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
233 if (Measurement
.Handle
!= NULL
) {
234 // See if the Handle is in the HandleBuffer
235 for (TIndex
= 0; TIndex
< (Size
/ sizeof(HandleBuffer
[0])); TIndex
++) {
236 if (Measurement
.Handle
== HandleBuffer
[TIndex
]) {
237 GetNameFromHandle (HandleBuffer
[TIndex
]);
243 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
244 UnicodeSPrint (mGaugeString
, sizeof (mGaugeString
), L
"%g", Measurement
.Handle
);
247 // Ensure that the argument strings are not too long.
248 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
249 mUnicodeToken
[13] = 0;
252 PrintToken( STRING_TOKEN (STR_DP_ALL_VARS2
),
253 Index
, // 1 based, Which measurement record is being printed
259 Measurement
.Identifier
262 PrintToken( STRING_TOKEN (STR_DP_ALL_VARS
),
263 Index
, // 1 based, Which measurement record is being printed
273 if (HandleBuffer
!= &TempHandle
) {
274 FreePool (HandleBuffer
);
276 SafeFreePool ((VOID
*) IncFlag
);
280 Gather and print Raw Trace Records.
282 All Trace measurements with a duration greater than or equal to
283 mInterestThreshold are printed without interpretation.
285 The number of records displayed is controlled by:
286 - records with a duration less than mInterestThreshold microseconds are not displayed.
287 - No more than Limit records are displayed. A Limit of zero will not limit the output.
288 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
291 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
293 @param[in] Limit The number of records to print. Zero is ALL.
294 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
300 IN BOOLEAN ExcludeFlag
303 MEASUREMENT_RECORD Measurement
;
310 EFI_STRING StringPtr
;
311 EFI_STRING StringPtrUnknown
;
313 StringPtrUnknown
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
314 StringPtr
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_DP_SECTION_RAWTRACE
), NULL
);
315 PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER
),
316 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
317 FreePool (StringPtr
);
318 FreePool (StringPtrUnknown
);
321 PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR2
) );
322 PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES2
) );
324 PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR
) );
325 PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES
) );
331 while ( WITHIN_LIMIT(Count
, Limit
) &&
332 ((LogEntryKey
= GetPerformanceMeasurementEx (
337 &Measurement
.StartTimeStamp
,
338 &Measurement
.EndTimeStamp
,
339 &Measurement
.Identifier
)) != 0)
342 ++Index
; // Count every record. First record is 1.
344 if (Measurement
.EndTimeStamp
!= 0) {
345 Duration
= GetDuration (&Measurement
);
346 ElapsedTime
= DurationInMicroSeconds ( Duration
);
348 if ((ElapsedTime
< mInterestThreshold
) ||
349 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
350 ) { // Ignore "uninteresting" or Excluded records
353 ++Count
; // Count the number of records printed
356 PrintToken (STRING_TOKEN (STR_DP_RAW_VARS2
),
357 Index
, // 1 based, Which measurement record is being printed
359 Measurement
.StartTimeStamp
,
360 Measurement
.EndTimeStamp
,
363 Measurement
.Identifier
366 PrintToken (STRING_TOKEN (STR_DP_RAW_VARS
),
367 Index
, // 1 based, Which measurement record is being printed
369 Measurement
.StartTimeStamp
,
370 Measurement
.EndTimeStamp
,
379 Gather and print Major Phase metrics.
381 @param[in] Ticker The timer value for the END of Shell phase
389 MEASUREMENT_RECORD Measurement
;
390 UINT64 BdsTimeoutValue
;
399 EFI_STRING StringPtr
;
401 EFI_STRING StringPtrUnknown
;
410 // Get Execution Phase Statistics
412 StringPtrUnknown
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
413 StringPtr
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PHASES
), NULL
);
414 PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER
),
415 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
416 FreePool (StringPtr
);
417 FreePool (StringPtrUnknown
);
420 while ((LogEntryKey
= GetPerformanceMeasurementEx (
425 &Measurement
.StartTimeStamp
,
426 &Measurement
.EndTimeStamp
,
427 &Measurement
.Identifier
)) != 0)
429 if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
430 Measurement
.EndTimeStamp
= Ticker
;
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) {
449 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
450 ShellTime
= Duration
;
456 // print SEC phase duration time
459 ElapsedTime
= DurationInMicroSeconds ( SecTime
); // Calculate elapsed time in microseconds
460 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
461 PrintToken (STRING_TOKEN (STR_DP_SEC_PHASE
), ElapsedTime
);
464 // print PEI phase duration time
467 ElapsedTime
= DivU64x32 (
469 (UINT32
)TimerInfo
.Frequency
471 Total
+= ElapsedTime
;
472 PrintToken (STRING_TOKEN (STR_DP_PHASE_DURATION
), ALit_PEI
, ElapsedTime
);
475 // print DXE phase duration time
478 ElapsedTime
= DivU64x32 (
480 (UINT32
)TimerInfo
.Frequency
482 Total
+= ElapsedTime
;
483 PrintToken (STRING_TOKEN (STR_DP_PHASE_DURATION
), ALit_DXE
, ElapsedTime
);
486 // print BDS phase duration time
489 ElapsedTime
= DivU64x32 (
491 (UINT32
)TimerInfo
.Frequency
493 Total
+= ElapsedTime
;
494 PrintToken (STRING_TOKEN (STR_DP_PHASE_DURATION
), ALit_BDS
, ElapsedTime
);
497 if (BdsTimeoutValue
> 0) {
498 ElapsedTime
= DivU64x32 (
500 (UINT32
)TimerInfo
.Frequency
502 PrintToken (STRING_TOKEN (STR_DP_PHASE_BDSTO
), ALit_BdsTO
, ElapsedTime
);
505 // print SHELL phase duration time
508 ElapsedTime
= DivU64x32 (
510 (UINT32
)TimerInfo
.Frequency
512 Total
+= ElapsedTime
;
513 PrintToken (STRING_TOKEN (STR_DP_PHASE_DURATION
), ALit_SHELL
, ElapsedTime
);
516 PrintToken (STRING_TOKEN (STR_DP_TOTAL_DURATION
), Total
);
520 Gather and print Handle data.
522 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
524 @return Status from a call to gBS->LocateHandle().
528 IN BOOLEAN ExcludeFlag
531 MEASUREMENT_RECORD Measurement
;
534 EFI_HANDLE
*HandleBuffer
;
535 EFI_STRING StringPtr
;
540 EFI_HANDLE TempHandle
;
542 EFI_STRING StringPtrUnknown
;
544 StringPtrUnknown
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
545 StringPtr
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_DP_SECTION_DRIVERS
), NULL
);
546 PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER
),
547 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
548 FreePool (StringPtr
);
549 FreePool (StringPtrUnknown
);
552 HandleBuffer
= &TempHandle
;
553 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, &TempHandle
);
554 if (Status
== EFI_BUFFER_TOO_SMALL
) {
555 HandleBuffer
= AllocatePool (Size
);
556 ASSERT (HandleBuffer
!= NULL
);
557 if (HandleBuffer
== NULL
) {
560 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, HandleBuffer
);
562 if (EFI_ERROR (Status
)) {
563 PrintToken (STRING_TOKEN (STR_DP_HANDLES_ERROR
), Status
);
567 Print (L
"There are %,d Handles defined.\n", (Size
/ sizeof(HandleBuffer
[0])));
571 PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION2
) );
573 PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION
) );
575 PrintToken (STRING_TOKEN (STR_DP_DASHES
) );
579 while ((LogEntryKey
= GetPerformanceMeasurementEx (
584 &Measurement
.StartTimeStamp
,
585 &Measurement
.EndTimeStamp
,
586 &Measurement
.Identifier
)) != 0)
589 Duration
= GetDuration (&Measurement
);
590 ElapsedTime
= DurationInMicroSeconds ( Duration
);
591 if ((ElapsedTime
< mInterestThreshold
) ||
592 (Measurement
.EndTimeStamp
== 0) ||
593 (Measurement
.Handle
== NULL
) ||
594 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
595 ) { // Ignore "uninteresting" or excluded records
598 mGaugeString
[0] = 0; // Empty driver name by default
599 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
600 // See if the Handle is in the HandleBuffer
601 for (Index
= 0; Index
< (Size
/ sizeof(HandleBuffer
[0])); Index
++) {
602 if (Measurement
.Handle
== HandleBuffer
[Index
]) {
603 GetNameFromHandle (HandleBuffer
[Index
]); // Name is put into mGaugeString
607 // Ensure that the argument strings are not too long.
608 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
609 mUnicodeToken
[11] = 0;
610 if (mGaugeString
[0] != 0) {
611 // Display the record if it has a valid handle.
614 STRING_TOKEN (STR_DP_HANDLE_VARS2
),
615 Count
, // 1 based, Which measurement record is being printed
616 Index
+ 1, // 1 based, Which handle is being printed
620 Measurement
.Identifier
624 STRING_TOKEN (STR_DP_HANDLE_VARS
),
625 Count
, // 1 based, Which measurement record is being printed
626 Index
+ 1, // 1 based, Which handle is being printed
635 if (HandleBuffer
!= &TempHandle
) {
636 FreePool (HandleBuffer
);
642 Gather and print PEIM data.
644 Only prints complete PEIM records
652 MEASUREMENT_RECORD Measurement
;
655 EFI_STRING StringPtr
;
658 EFI_STRING StringPtrUnknown
;
660 StringPtrUnknown
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
661 StringPtr
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PEIMS
), NULL
);
662 PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER
),
663 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
664 FreePool (StringPtr
);
665 FreePool (StringPtrUnknown
);
668 PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION2
));
670 PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION
));
672 PrintToken (STRING_TOKEN (STR_DP_DASHES
));
675 while ((LogEntryKey
= GetPerformanceMeasurementEx (
680 &Measurement
.StartTimeStamp
,
681 &Measurement
.EndTimeStamp
,
682 &Measurement
.Identifier
)) != 0)
685 if ((Measurement
.EndTimeStamp
== 0) ||
686 (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) != 0)
691 Duration
= GetDuration (&Measurement
);
692 ElapsedTime
= DurationInMicroSeconds ( Duration
); // Calculate elapsed time in microseconds
693 if (ElapsedTime
>= mInterestThreshold
) {
694 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
696 PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS2
),
697 TIndex
, // 1 based, Which measurement record is being printed
698 Measurement
.Handle
, // base address
699 Measurement
.Handle
, // file guid
701 Measurement
.Identifier
704 PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS
),
705 TIndex
, // 1 based, Which measurement record is being printed
706 Measurement
.Handle
, // base address
707 Measurement
.Handle
, // file guid
716 Gather and print global data.
718 Strips out incomplete or "Execution Phase" records
719 Only prints records where Handle is NULL
720 Increment TIndex for every record, even skipped ones, so that we have an
721 indication of every measurement record taken.
729 MEASUREMENT_RECORD Measurement
;
732 EFI_STRING StringPtr
;
734 UINTN Index
; // Index, or number, of the measurement record being processed
735 EFI_STRING StringPtrUnknown
;
737 StringPtrUnknown
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
738 StringPtr
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_DP_SECTION_GENERAL
), NULL
);
739 PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER
),
740 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
741 FreePool (StringPtr
);
742 FreePool (StringPtrUnknown
);
745 PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION2
));
747 PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION
));
749 PrintToken (STRING_TOKEN (STR_DP_DASHES
));
754 while ((LogEntryKey
= GetPerformanceMeasurementEx (
759 &Measurement
.StartTimeStamp
,
760 &Measurement
.EndTimeStamp
,
761 &Measurement
.Identifier
)) != 0)
763 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
);
764 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
765 mGaugeString
[25] = 0;
766 mUnicodeToken
[31] = 0;
767 if ( ! ( IsPhase( &Measurement
) ||
768 (Measurement
.Handle
!= NULL
) ||
769 (Measurement
.EndTimeStamp
== 0)
772 Duration
= GetDuration (&Measurement
);
773 ElapsedTime
= DurationInMicroSeconds ( Duration
);
774 if (ElapsedTime
>= mInterestThreshold
) {
777 STRING_TOKEN (STR_DP_GLOBAL_VARS2
),
782 Measurement
.Identifier
786 STRING_TOKEN (STR_DP_GLOBAL_VARS
),
800 Gather and print cumulative data.
802 Traverse the measurement records and:<BR>
803 For each record with a Token listed in the CumData array:<BR>
804 - Update the instance count and the total, minimum, and maximum durations.
805 Finally, print the gathered cumulative statistics.
807 @param[in] CustomCumulativeData A pointer to the cumtom cumulative data.
812 IN PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
815 UINT64 AvgDur
; // the computed average duration
819 EFI_STRING StringPtr
;
821 EFI_STRING StringPtrUnknown
;
823 StringPtrUnknown
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
824 StringPtr
= HiiGetString (gHiiHandle
, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE
), NULL
);
825 PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER
),
826 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
827 FreePool (StringPtr
);
828 FreePool (StringPtrUnknown
);
830 PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1
));
831 PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2
));
832 PrintToken (STRING_TOKEN (STR_DP_DASHES
));
834 for ( TIndex
= 0; TIndex
< NumCum
; ++TIndex
) {
835 if (CumData
[TIndex
].Count
!= 0) {
836 AvgDur
= DivU64x32 (CumData
[TIndex
].Duration
, CumData
[TIndex
].Count
);
837 AvgDur
= DurationInMicroSeconds(AvgDur
);
838 Dur
= DurationInMicroSeconds(CumData
[TIndex
].Duration
);
839 MaxDur
= DurationInMicroSeconds(CumData
[TIndex
].MaxDur
);
840 MinDur
= DurationInMicroSeconds(CumData
[TIndex
].MinDur
);
842 PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_STATS
),
843 CumData
[TIndex
].Name
,
844 CumData
[TIndex
].Count
,
854 // Print the custom cumulative data.
856 if (CustomCumulativeData
!= NULL
) {
857 if (CustomCumulativeData
->Count
!= 0) {
858 AvgDur
= DivU64x32 (CustomCumulativeData
->Duration
, CustomCumulativeData
->Count
);
859 AvgDur
= DurationInMicroSeconds (AvgDur
);
860 Dur
= DurationInMicroSeconds (CustomCumulativeData
->Duration
);
861 MaxDur
= DurationInMicroSeconds (CustomCumulativeData
->MaxDur
);
862 MinDur
= DurationInMicroSeconds (CustomCumulativeData
->MinDur
);
869 PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_STATS
),
870 CustomCumulativeData
->Name
,
871 CustomCumulativeData
->Count
,