+++ /dev/null
-/** @file\r
- Library that provides services to measure module execution performance\r
-\r
- Copyright (c) 2006, Intel Corporation.\r
- All rights reserved. This program and the accompanying materials \r
- are licensed and made available under the terms and conditions of the BSD License \r
- which accompanies this distribution. The full text of the license may be found at \r
- http://opensource.org/licenses/bsd-license.php \r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
- Module Name: PerformanceLib.h\r
-\r
-**/\r
-\r
-#ifndef __PERFORMANCE_LIB_H__\r
-#define __PERFORMANCE_LIB_H__\r
-\r
-//\r
-// Performance library propery mask bits\r
-//\r
-#define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED 0x00000001\r
-\r
-/**\r
- Creates a record for the beginning of a performance measurement. \r
- \r
- Creates a record that contains the Handle, Token, and Module.\r
- If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r
- If TimeStamp is zero, then this function reads the current time stamp\r
- and adds that time stamp value to the record as the start time.\r
-\r
- @param Handle Pointer to environment specific context used\r
- to identify the component being measured.\r
- @param Token Pointer to a Null-terminated ASCII string\r
- that identifies the component being measured.\r
- @param Module Pointer to a Null-terminated ASCII string\r
- that identifies the module being measured.\r
- @param TimeStamp 64-bit time stamp.\r
-\r
- @retval RETURN_SUCCESS The start of the measurement was recorded.\r
- @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-StartPerformanceMeasurement (\r
- IN CONST VOID *Handle, OPTIONAL\r
- IN CONST CHAR8 *Token, OPTIONAL\r
- IN CONST CHAR8 *Module, OPTIONAL\r
- IN UINT64 TimeStamp\r
- );\r
-\r
-/**\r
- Fills in the end time of a performance measurement. \r
- \r
- Looks up the record that matches Handle, Token, and Module.\r
- If the record can not be found then return RETURN_NOT_FOUND.\r
- If the record is found and TimeStamp is not zero,\r
- then TimeStamp is added to the record as the end time.\r
- If the record is found and TimeStamp is zero, then this function reads\r
- the current time stamp and adds that time stamp value to the record as the end time.\r
- If this function is called multiple times for the same record, then the end time is overwritten.\r
-\r
- @param Handle Pointer to environment specific context used\r
- to identify the component being measured.\r
- @param Token Pointer to a Null-terminated ASCII string\r
- that identifies the component being measured.\r
- @param Module Pointer to a Null-terminated ASCII string\r
- that identifies the module being measured.\r
- @param TimeStamp 64-bit time stamp.\r
-\r
- @retval RETURN_SUCCESS The end of the measurement was recorded.\r
- @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-EndPerformanceMeasurement (\r
- IN CONST VOID *Handle, OPTIONAL\r
- IN CONST CHAR8 *Token, OPTIONAL\r
- IN CONST CHAR8 *Module, OPTIONAL\r
- IN UINT64 TimeStamp\r
- );\r
-\r
-/**\r
- Attempts to retrieve a performance measurement log entry from the performance measurement log. \r
- \r
- Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r
- zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
- and the key for the second entry in the log is returned. If the performance log is empty,\r
- then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r
- log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
- returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
- retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
- log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
- is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r
- the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r
- If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
- If Handle is NULL, then ASSERT().\r
- If Token is NULL, then ASSERT().\r
- If Module is NULL, then ASSERT().\r
- If StartTimeStamp is NULL, then ASSERT().\r
- If EndTimeStamp is NULL, then ASSERT().\r
-\r
- @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r
- 0, then the first performance measurement log entry is retrieved.\r
- On exit, the key of the next performance lof entry entry.\r
- @param Handle Pointer to environment specific context used to identify the component\r
- being measured. \r
- @param Token Pointer to a Null-terminated ASCII string that identifies the component\r
- being measured. \r
- @param Module Pointer to a Null-terminated ASCII string that identifies the module\r
- being measured.\r
- @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
- was started.\r
- @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
- was ended.\r
-\r
- @return The key for the next performance log entry (in general case).\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-GetPerformanceMeasurement (\r
- IN UINTN LogEntryKey, \r
- OUT CONST VOID **Handle,\r
- OUT CONST CHAR8 **Token,\r
- OUT CONST CHAR8 **Module,\r
- OUT UINT64 *StartTimeStamp,\r
- OUT UINT64 *EndTimeStamp\r
- );\r
-\r
-/**\r
- Returns TRUE if the performance measurement macros are enabled. \r
- \r
- This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
- PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.\r
-\r
- @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
- PcdPerformanceLibraryPropertyMask is set.\r
- @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
- PcdPerformanceLibraryPropertyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-PerformanceMeasurementEnabled (\r
- VOID\r
- );\r
-\r
-/**\r
- Macro that calls EndPerformanceMeasurement().\r
-\r
- If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
- then EndPerformanceMeasurement() is called.\r
-\r
-**/\r
-#define PERF_END(Handle, Token, Module, TimeStamp) \\r
- do { \\r
- if (PerformanceMeasurementEnabled ()) { \\r
- EndPerformanceMeasurement (Handle, Token, Module, TimeStamp); \\r
- } \\r
- } while (FALSE)\r
-\r
-/**\r
- Macro that calls StartPerformanceMeasurement().\r
-\r
- If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
- then StartPerformanceMeasurement() is called.\r
-\r
-**/\r
-#define PERF_START(Handle, Token, Module, TimeStamp) \\r
- do { \\r
- if (PerformanceMeasurementEnabled ()) { \\r
- StartPerformanceMeasurement (Handle, Token, Module, TimeStamp); \\r
- } \\r
- } while (FALSE)\r
-\r
-/**\r
- Macro that marks the beginning of performance measurement source code.\r
-\r
- If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
- then this macro marks the beginning of source code that is included in a module.\r
- Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.\r
-\r
-**/\r
-#define PERF_CODE_BEGIN() do { if (PerformanceMeasurementEnabled ()) { UINT8 __PerformanceCodeLocal\r
-\r
-/**\r
- Macro that marks the end of performance measurement source code.\r
-\r
- If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
- then this macro marks the end of source code that is included in a module.\r
- Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.\r
-\r
-**/\r
-#define PERF_CODE_END() __PerformanceCodeLocal = 0; __PerformanceCodeLocal++; } } while (FALSE)\r
-\r
-/**\r
- Macro that declares a section of performance measurement source code.\r
-\r
- If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
- then the source code specified by Expression is included in a module.\r
- Otherwise, the source specified by Expression is not included in a module.\r
-\r
- @param Expression Performance measurement source code to include in a module.\r
-\r
-**/\r
-#define PERF_CODE(Expression) \\r
- PERF_CODE_BEGIN (); \\r
- Expression \\r
- PERF_CODE_END ()\r
-\r
-\r
-#endif\r