Instrumenting blocks of code or expressions is done by adding a call to CB_INSTR_POINT in the configure.in file and surrounding the code with a macro call. For example, to do high resolution timings of the following code:
for( lpc = 0; lpc < 100; lpc++ )
{
...
}
You would modify the configure.in to include:
CB_INSTR_POINT([my_point], [HRTIME_INSTR], [My instrumentation point])
Where 'my_point' is the name of the instrumentation point, HRTIME_INSTR is the C macro that will record the timings, and 'My instrumentation point' is the description of the point. The result of this call will be two new definitions in the config.h: 'INSTR_my_point' and 'INSTR_my_point_data'. The first C macro is used to surround the code block and the second contains the data used to initialize the instrumentation point structure (iPoint). With these new definitions, we can modify our original code to add instrumentation:
#if defined(INSTR_my_point_data) static struct iPoint IP_my_point = { INSTR_my_point_data }; #endif ... INSTR_my_point(&IP_my_point, ({ for( lpc = 0; lpc < 100; lpc++ ) { ... } }));
(Notice the parentheses around the code block, these are required for things to parse correctly.)
Finally, to enable this instrumentation point, you either need to use --enable-instrumentation to enable all of the points, or --enable-instrumentation="my_point ..." to enable this point and any others named.
Any instrumentation data collected during a run is usually appended to a file iPrintPointsAtExit function.
Definition in file instrumentation.h.
Include dependency graph for instrumentation.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Classes | |
struct | iPoint |
struct | iInstrumentationData |
Defines | |
#define | IPOINT_INIT_HISTORY(history) |
Macro used to statically initialize the ip_History field of the iPoint structure. | |
#define | HRTIME_INSTR(point, block) |
Macro used to perform high-resolution timings of a block of code. | |
#define | LRTIME_INSTR(point, block) |
Macro used to perform low-resolution timings of a block of code. | |
#define | LRCPUTIME_INSTR(point, block) |
Macro used to perform low-resolution CPU timings of a block of code. | |
#define | ACCUM_INSTR(point, expr) |
Macro used to accumulate the value of a numeral expression. | |
#define | NOINSTR(point, block) (void)(block) |
Macro used to avoid instrumenting a block of code. | |
#define | INSTR_FILE_NAME_ENV "CB_INSTR_FILE_NAME" |
The environment variable name to check for the instrumentation output file name. | |
Typedefs | |
typedef unsigned long long | lrtime_t |
Container for low-resolution timer values. | |
typedef unsigned long long | hrtime_t |
Container for high-resolution timer values. | |
Enumerations | |
enum | { IPB_PRINT_HISTORY, IPB_DROP_HISTORY_START } |
enum | { IPF_PRINT_HISTORY = (1L << IPB_PRINT_HISTORY), IPF_DROP_HISTORY_START = (1L << IPB_DROP_HISTORY_START), IPF_MASK } |
Flags for the iPoint structure. More... | |
Functions | |
lrtime_t | lrtime (void) |
lrtime_t | lrcputime (void) |
hrtime_t | hrtime (void) |
void | iPostFloatData (struct iPoint *ip, double value) |
Post a floating point data value to an instrumentation point. | |
void | iPrintPoint (FILE *file, struct iPoint *ip) |
Print the collected values for an instrumentation point. | |
void | iPrintPoints (FILE *file) |
Print all of the instrumentation points that have had data posted to them using iPrintPoint. | |
void | iPrintPointsAtExit (void) |
An atexit(3) function that calls iPrintPoints with a file from one of the following sources (listed in order of precedence):. | |
Variables | |
iInstrumentationData | instrumentation_data |
The global data needed by the instrumentation infrastructure. |
|
Value: { \ iPostFloatData(point, (double)(expr)); \ }
Definition at line 299 of file instrumentation.h. |
|
Value: { \ hrtime_t _start, _end; \ \ _start = hrtime(); \ block; \ _end = hrtime(); \ iPostFloatData(point, (_end - _start)); \ }
Definition at line 248 of file instrumentation.h. |
|
Value: { \ history, \ sizeof(history) / sizeof(double) \ }
Definition at line 235 of file instrumentation.h. |
|
Value: { \ lrtime_t _start, _end; \ \ _start = lrcputime(); \ block; \ _end = lrcputime(); \ iPostFloatData(point, (_end - _start)); \ }
Definition at line 282 of file instrumentation.h. |
|
Value: { \ lrtime_t _start, _end; \ \ _start = lrtime(); \ block; \ _end = lrtime(); \ iPostFloatData(point, (_end - _start)); \ }
Definition at line 265 of file instrumentation.h. |
|
Macro used to avoid instrumenting a block of code.
Definition at line 310 of file instrumentation.h. |
|
Flags for the iPoint structure.
Definition at line 175 of file instrumentation.h. |
|
Definition at line 155 of file instrumentation.h. References hrtime_t. |
|
Post a floating point data value to an instrumentation point.
Definition at line 86 of file instrumentation.c. References iInitPoint(), IP_HISTORY_START_ADD, and require. |
Here is the call graph for this function:
|
Print the collected values for an instrumentation point. The summary data printed depends on whether or not a history array has been provided: no history means the summary covers all of the posted data; otherwise the summary covers only the data held in the history.
Definition at line 126 of file instrumentation.c. References IP_HISTORY_START_ADD, IPF_MASK, and require. Referenced by iPrintPoints(). |
|
Print all of the instrumentation points that have had data posted to them using iPrintPoint.
Definition at line 231 of file instrumentation.c. References instrumentation_data, iPrintPoint(), and require. Referenced by iPrintPointsAtExit(). |
Here is the call graph for this function:
|
An atexit(3) function that calls iPrintPoints with a file from one of the following sources (listed in order of precedence):.
Definition at line 246 of file instrumentation.c. References DEFAULT_INSTRUMENTATION_FILE_NAME, INSTR_FILE_NAME_ENV, instrumentation_data, and iPrintPoints(). Referenced by main(), and ManagerImpl::ManagerImpl(). |
Here is the call graph for this function:
|
Definition at line 118 of file instrumentation.h. References lrtime_t. |
|
Definition at line 97 of file instrumentation.h. References lrtime_t. |