2 Base Performance Library which provides no service.
4 Copyright (c) 2006 - 2008, Intel Corporation<BR>
5 All rights reserved. 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.
19 #include <Library/PerformanceLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/PcdLib.h>
24 Creates a record for the beginning of a performance measurement.
26 Creates a record that contains the Handle, Token, and Module.
27 If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
28 If TimeStamp is zero, then this function reads the current time stamp
29 and adds that time stamp value to the record as the start time.
31 @param Handle Pointer to environment specific context used
32 to identify the component being measured.
33 @param Token Pointer to a Null-terminated ASCII string
34 that identifies the component being measured.
35 @param Module Pointer to a Null-terminated ASCII string
36 that identifies the module being measured.
37 @param TimeStamp 64-bit time stamp.
39 @retval RETURN_SUCCESS The start of the measurement was recorded.
40 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
41 @retval RETURN_DEVICE_ERROR A device error reading the time stamp.
46 StartPerformanceMeasurement (
47 IN CONST VOID
*Handle
, OPTIONAL
48 IN CONST CHAR8
*Token
, OPTIONAL
49 IN CONST CHAR8
*Module
, OPTIONAL
53 return RETURN_SUCCESS
;
57 Fills in the end time of a performance measurement.
59 Looks up the record that matches Handle, Token, and Module.
60 If the record can not be found then return RETURN_NOT_FOUND.
61 If the record is found and TimeStamp is not zero,
62 then TimeStamp is added to the record as the end time.
63 If the record is found and TimeStamp is zero, then this function reads
64 the current time stamp and adds that time stamp value to the record as the end time.
65 If this function is called multiple times for the same record, then the end time is overwritten.
67 @param Handle Pointer to environment specific context used
68 to identify the component being measured.
69 @param Token Pointer to a Null-terminated ASCII string
70 that identifies the component being measured.
71 @param Module Pointer to a Null-terminated ASCII string
72 that identifies the module being measured.
73 @param TimeStamp 64-bit time stamp.
75 @retval RETURN_SUCCESS The end of the measurement was recorded.
76 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
77 @retval RETURN_DEVICE_ERROR A device error reading the time stamp.
82 EndPerformanceMeasurement (
83 IN CONST VOID
*Handle
, OPTIONAL
84 IN CONST CHAR8
*Token
, OPTIONAL
85 IN CONST CHAR8
*Module
, OPTIONAL
89 return RETURN_SUCCESS
;
93 Attempts to retrieve a performance measurement log entry from the performance measurement log.
95 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
96 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
97 and the key for the second entry in the log is returned. If the performance log is empty,
98 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
99 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
100 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
101 retrieved and an implementation specific non-zero key value that specifies the end of the performance
102 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
103 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
104 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
105 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
106 If Handle is NULL, then ASSERT().
107 If Token is NULL, then ASSERT().
108 If Module is NULL, then ASSERT().
109 If StartTimeStamp is NULL, then ASSERT().
110 If EndTimeStamp is NULL, then ASSERT().
112 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
113 0, then the first performance measurement log entry is retrieved.
114 On exit, the key of the next performance lof entry entry.
115 @param Handle Pointer to environment specific context used to identify the component
117 @param Token Pointer to a Null-terminated ASCII string that identifies the component
119 @param Module Pointer to a Null-terminated ASCII string that identifies the module
121 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
123 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
126 @return The key for the next performance log entry (in general case).
131 GetPerformanceMeasurement (
132 IN UINTN LogEntryKey
,
133 OUT CONST VOID
**Handle
,
134 OUT CONST CHAR8
**Token
,
135 OUT CONST CHAR8
**Module
,
136 OUT UINT64
*StartTimeStamp
,
137 OUT UINT64
*EndTimeStamp
140 ASSERT (Handle
!= NULL
);
141 ASSERT (Token
!= NULL
);
142 ASSERT (Module
!= NULL
);
143 ASSERT (StartTimeStamp
!= NULL
);
144 ASSERT (EndTimeStamp
!= NULL
);
150 Returns TRUE if the performance measurement macros are enabled.
152 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
153 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
155 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
156 PcdPerformanceLibraryPropertyMask is set.
157 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
158 PcdPerformanceLibraryPropertyMask is clear.
163 PerformanceMeasurementEnabled (
167 return (BOOLEAN
) ((PcdGet8(PcdPerformanceLibraryPropertyMask
) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
) != 0);