Hello.apc
probe thread
{
probe "hello.c":"SayHello()"
{
ap_TimeT EntryTime;
ap_TimeT ExitTime;
ap_TimeT TimeDifference;
on_entry
EntryTime = ap_GetCurrentTime();
on_exit
// Get the time on exit
ExitTime = ap_GetCurrentTime();
// calculate the execution time of the subprogram
TimeDifference = ap_SubTime(ExitTime, EntryTime);
// log the time difference
log("SayHello() completed in => ", TimeDifference);
}
}
Note the use of probe variables: EntryTime, ExitTime, and TimeDifference. They were declared inside the subprogram probe, so these variables will be alive only for the duration of the probe's target. This means that they are created for each call to "SayHello", and cease to exist after exiting from it. These variables could therefore be viewed as extensions of the local variable declaration list for the subprogram "SayHello".
This probe also takes advantage of a number of standard Aprobe types and functions defined in aprobe.h and described in Appendix C of the Aprobe User's Guide. Also see Chapter 3, Time Support for a discussion of the timing support functions and types.
SayHello() completed in => 00:00:00.000681861
Modify "hello.apc" to compute and log time measurement overhead on entry to program. You can do this by capturing the value of the current time twice in succession, and subtracting the difference. Since no real action has been performed during this period of time, the resulting value should represent the time measurement overhead.