]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Library that provides services to measure module execution performance\r | |
3 | \r | |
4 | Copyright (c) 2004, Intel Corporation \r | |
5 | All rights reserved. This program and the accompanying materials \r | |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
12 | \r | |
13 | Module Name: PerformanceLib.h\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef __PERFORMANCE_LIB_H__\r | |
18 | #define __PERFORMANCE_LIB_H__\r | |
19 | \r | |
20 | //\r | |
21 | // Performance library propery mask bits\r | |
22 | //\r | |
23 | #define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED 0x00000001\r | |
24 | \r | |
25 | /**\r | |
26 | Creates a record for the beginning of a performance measurement. \r | |
27 | \r | |
28 | Creates a record that contains the Handle, Token, and Module.\r | |
29 | If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r | |
30 | If TimeStamp is zero, then this function reads the current time stamp\r | |
31 | and adds that time stamp value to the record as the start time.\r | |
32 | \r | |
33 | @param Handle Pointer to environment specific context used\r | |
34 | to identify the component being measured.\r | |
35 | @param Token Pointer to a Null-terminated ASCII string\r | |
36 | that identifies the component being measured.\r | |
37 | @param Module Pointer to a Null-terminated ASCII string\r | |
38 | that identifies the module being measured.\r | |
39 | @param TimeStamp 64-bit time stamp.\r | |
40 | \r | |
41 | @retval RETURN_SUCCESS The start of the measurement was recorded.\r | |
42 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r | |
43 | \r | |
44 | **/\r | |
45 | RETURN_STATUS\r | |
46 | EFIAPI\r | |
47 | StartPerformanceMeasurement (\r | |
48 | IN CONST VOID *Handle, OPTIONAL\r | |
49 | IN CONST CHAR8 *Token, OPTIONAL\r | |
50 | IN CONST CHAR8 *Module, OPTIONAL\r | |
51 | IN UINT64 TimeStamp\r | |
52 | );\r | |
53 | \r | |
54 | /**\r | |
55 | Fills in the end time of a performance measurement. \r | |
56 | \r | |
57 | Looks up the record that matches Handle, Token, and Module.\r | |
58 | If the record can not be found then return RETURN_NOT_FOUND.\r | |
59 | If the record is found and TimeStamp is not zero,\r | |
60 | then TimeStamp is added to the record as the end time.\r | |
61 | If the record is found and TimeStamp is zero, then this function reads\r | |
62 | the current time stamp and adds that time stamp value to the record as the end time.\r | |
63 | If this function is called multiple times for the same record, then the end time is overwritten.\r | |
64 | \r | |
65 | @param Handle Pointer to environment specific context used\r | |
66 | to identify the component being measured.\r | |
67 | @param Token Pointer to a Null-terminated ASCII string\r | |
68 | that identifies the component being measured.\r | |
69 | @param Module Pointer to a Null-terminated ASCII string\r | |
70 | that identifies the module being measured.\r | |
71 | @param TimeStamp 64-bit time stamp.\r | |
72 | \r | |
73 | @retval RETURN_SUCCESS The end of the measurement was recorded.\r | |
74 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r | |
75 | \r | |
76 | **/\r | |
77 | RETURN_STATUS\r | |
78 | EFIAPI\r | |
79 | EndPerformanceMeasurement (\r | |
80 | IN CONST VOID *Handle, OPTIONAL\r | |
81 | IN CONST CHAR8 *Token, OPTIONAL\r | |
82 | IN CONST CHAR8 *Module, OPTIONAL\r | |
83 | IN UINT64 TimeStamp\r | |
84 | );\r | |
85 | \r | |
86 | /**\r | |
87 | Retrieves a previously logged performance measurement. \r | |
88 | \r | |
89 | Looks up the record that matches Handle, Token, and Module.\r | |
90 | If the record can not be found then return RETURN_NOT_FOUND.\r | |
91 | If the record is found then the start of the measurement is returned in StartTimeStamp,\r | |
92 | and the end of the measurement is returned in EndTimeStamp.\r | |
93 | \r | |
94 | @param LogEntryKey The key for the previous performance measurement log entry.\r | |
95 | If 0, then the first performance measurement log entry is retrieved.\r | |
96 | @param Handle Pointer to environment specific context used\r | |
97 | to identify the component being measured.\r | |
98 | @param Token Pointer to a Null-terminated ASCII string\r | |
99 | that identifies the component being measured.\r | |
100 | @param Module Pointer to a Null-terminated ASCII string\r | |
101 | that identifies the module being measured.\r | |
102 | @param StartTimeStamp The 64-bit time stamp that was recorded when the measurement was started.\r | |
103 | @param EndTimeStamp The 64-bit time stamp that was recorded when the measurement was ended.\r | |
104 | \r | |
105 | @return The key for the current performance log entry.\r | |
106 | \r | |
107 | **/\r | |
108 | UINTN\r | |
109 | EFIAPI\r | |
110 | GetPerformanceMeasurement (\r | |
111 | UINTN LogEntryKey, \r | |
112 | OUT CONST VOID **Handle,\r | |
113 | OUT CONST CHAR8 **Token,\r | |
114 | OUT CONST CHAR8 **Module,\r | |
115 | OUT UINT64 *StartTimeStamp,\r | |
116 | OUT UINT64 *EndTimeStamp\r | |
117 | );\r | |
118 | \r | |
119 | /**\r | |
120 | Returns TRUE if the performance measurement macros are enabled. \r | |
121 | \r | |
122 | This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
123 | PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.\r | |
124 | \r | |
125 | @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
126 | PcdPerformanceLibraryPropertyMask is set.\r | |
127 | @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
128 | PcdPerformanceLibraryPropertyMask is clear.\r | |
129 | \r | |
130 | **/\r | |
131 | BOOLEAN\r | |
132 | EFIAPI\r | |
133 | PerformanceMeasurementEnabled (\r | |
134 | VOID\r | |
135 | );\r | |
136 | \r | |
137 | /**\r | |
138 | Macro that calls EndPerformanceMeasurement().\r | |
139 | \r | |
140 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
141 | then EndPerformanceMeasurement() is called.\r | |
142 | \r | |
143 | **/\r | |
144 | #define PERF_END(Handle, Token, Module, TimeStamp) \\r | |
145 | do { \\r | |
146 | if (PerformanceMeasurementEnabled ()) { \\r | |
147 | EndPerformanceMeasurement (Handle, Token, Module, TimeStamp); \\r | |
148 | } \\r | |
149 | } while (FALSE)\r | |
150 | \r | |
151 | /**\r | |
152 | Macro that calls StartPerformanceMeasurement().\r | |
153 | \r | |
154 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
155 | then StartPerformanceMeasurement() is called.\r | |
156 | \r | |
157 | **/\r | |
158 | #define PERF_START(Handle, Token, Module, TimeStamp) \\r | |
159 | do { \\r | |
160 | if (PerformanceMeasurementEnabled ()) { \\r | |
161 | StartPerformanceMeasurement (Handle, Token, Module, TimeStamp); \\r | |
162 | } \\r | |
163 | } while (FALSE)\r | |
164 | \r | |
165 | /**\r | |
166 | Macro that marks the beginning of performance measurement source code.\r | |
167 | \r | |
168 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
169 | then this macro marks the beginning of source code that is included in a module.\r | |
170 | Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.\r | |
171 | \r | |
172 | **/\r | |
173 | #define PERF_CODE_BEGIN() do { if (PerformanceMeasurementEnabled ()) { UINT8 __PerformanceCodeLocal\r | |
174 | \r | |
175 | /**\r | |
176 | Macro that marks the end of performance measurement source code.\r | |
177 | \r | |
178 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
179 | then this macro marks the end of source code that is included in a module.\r | |
180 | Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.\r | |
181 | \r | |
182 | **/\r | |
183 | #define PERF_CODE_END() __PerformanceCodeLocal = 0; } } while (FALSE)\r | |
184 | \r | |
185 | /**\r | |
186 | Macro that declares a section of performance measurement source code.\r | |
187 | \r | |
188 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
189 | then the source code specified by Expression is included in a module.\r | |
190 | Otherwise, the source specified by Expression is not included in a module.\r | |
191 | \r | |
192 | @param Expression Performance measurement source code to include in a module.\r | |
193 | \r | |
194 | **/\r | |
195 | #define PERF_CODE(Expression) \\r | |
196 | PERF_CODE_BEGIN (); \\r | |
197 | Expression \\r | |
198 | PERF_CODE_END ()\r | |
199 | \r | |
200 | \r | |
201 | #endif\r |