Libraries and utilities for instrumenting regions of code and measuring their perform...
[mirror_edk2.git] / PerformancePkg / Dp_App / DpProfile.c
1 /** @file
2 * Measured Profiling reporting for the Dp utility.
3 *
4 * Copyright (c) 2009-2010, Intel Corporation. All rights reserved.<BR>
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
9 *
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.
12 **/
13
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>
25
26 #include <Guid/Performance.h>
27
28 #include "Dp.h"
29 #include "Literals.h"
30 #include "DpInternal.h"
31
32 /** Gather and print ALL Profiling Records.
33 *
34 * Displays all "interesting" Profile measurements in order.
35 * The number of records displayed is controlled by:
36 * - records with a duration less than mInterestThreshold microseconds are not displayed.
37 * - No more than Limit records are displayed. A Limit of zero will not limit the output.
38 * - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
39 * displayed.
40 *
41 * @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
42 * The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
43 * They must not be in use by a calling function.
44 *
45 * @param[in] Limit The number of records to print. Zero is ALL.
46 * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
47 *
48 **/
49 VOID
50 DumpAllProfile(
51 IN UINTN Limit,
52 IN BOOLEAN ExcludeFlag
53 )
54 {
55 EFI_STRING StringPtr;
56
57 StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);
58 PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
59 (StringPtr == NULL) ? ALit_UNKNOWN: StringPtr);
60 return;
61 }
62
63 /** Gather and print Raw Profile Records.
64 *
65 * All Profile measurements with a duration greater than or equal to
66 * mInterestThreshold are printed without interpretation.
67 *
68 * The number of records displayed is controlled by:
69 * - records with a duration less than mInterestThreshold microseconds are not displayed.
70 * - No more than Limit records are displayed. A Limit of zero will not limit the output.
71 * - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
72 * displayed.
73 *
74 * @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
75 *
76 * @param[in] Limit The number of records to print. Zero is ALL.
77 * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
78 *
79 **/
80 VOID
81 DumpRawProfile(
82 IN UINTN Limit,
83 IN BOOLEAN ExcludeFlag
84 )
85 {
86 EFI_STRING StringPtr;
87
88 StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);
89 PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
90 (StringPtr == NULL) ? ALit_UNKNOWN: StringPtr);
91 return;
92 }