../../AspectXLib/CodeInstrumentation/Profiling/aspects/Profiling.ax
Pointcuts | |
constructor | targetConstructor |
Points to all constructors in the base code | |
class | targetClass |
Points to all classes | |
unit | targetClassImplementationUnit |
Points to all the units (source files) that contain implementations of the methods
defined in the classes specified by the targetClass pointcut | |
function | targetMethod |
Points to all method definitions that are
in the units (source files) specified by the pointcut
targetClassImplementationUnit | |
return | targetMethodReturn |
Points to the return statements that must be modified | |
function | targetMainFunction |
Points to the main() function | |
return | targetMainReturn |
Points to return statements in the main() function | |
Advices | |
add | addProfilingVariables |
Insert declarations to each class | |
before | insertReporterCall |
Insert call of method _profilingReport() at the end of execution of the
main() function | |
begin | insertVariableDeclaration |
Insert the code that reads the current time and saves it
to the local variable _profilingMethodStart | |
before | insertBeforeReturn |
Insert code that computes the time the program spent executing the current method | |
end | insertTraceAtEnd |
Insert code that computes the time the program spent executing the current method | |
add | addInclude |
Add the necessary #include statements | |
add | addProfilingReportMethod |
Insert the definition of _profilingReport() method | |
begin | addProfilingVariableInitialization |
Insert the initialization code of all profiling member variables
to the class constructor |
targetClass
pointcut.
targetClassImplementationUnit
.
Thus, it points to all method definitions (but not to
definitions of constructors, destructors and C functions).
main()
function.main()
function.
Triplet: class add declaration declaration
_profiling_XXX
where XXX
stands for the method name. For example, the name of _profiling_test
member variable
is derived from the name of the test()
method.
Two constructs of the XSL language are used to insert the variables: xsl:for-each
and xsl:value-of
. The xsl:for-each
instruction locates all method
declarations. Then the xsl:value-of
instruction is used to
extract the names of the methods and to write them to the base code.
The advice also inserts the declaration of the public method _profilingReport()
.
Refers to global pointcut: class targetClass
Triplet: return before codeFragment
_profilingReport()
at the end of execution of the
main()
function. More precisely, it inserts the function call before
every return
statement of the main()
function.
Refers to global pointcut: return targetMainReturn
Triplet: function begin codeFragment
_profilingMethodStart
.
Refers to global pointcut: function targetMethod
Triplet: return before codeFragment
_profilingMethodStart
. The computed amount of time is added to
the respective member variable _profiling_XXX
where XXX stands for the name of the current method.
This code is inserted before every return statement.
Refers to global pointcut: return targetMethodReturn
Triplet: function end codeFragment
_profilingMethodStart
. The computed amount of time is added to
the respective member variable _profiling_XXX
where XXX stands for the name of the current method.
This code is inserted at the very end of every class method.
Refers to global pointcut: function targetMethod
Triplet: unit add include
#include
statements.
It adds the header file of MicroTime
class that is used to measure time with accuracy of
one microsecond. It also includes the iostream
library and declares
the std
namespace needed for I/O operations.
Refers to global pointcut: unit targetClassImplementationUnit
Triplet: unit add definition
_profilingReport()
method. The method lists all
methods defined in the class. For every method it outputs the total execution time in microseconds.
Two constructs of the XSL language are used to access the
member variables that stores the execution time for each method: xsl:for-each
and xsl:value-of
. The xsl:for-each
instruction locates all method
definitions. Then the xsl:value-of
instruction is used to
extract the local names of the methods and to write them to the base code.
Refers to global pointcut: unit targetClassImplementationUnit
Triplet: constructor begin codeFragment
xsl:for-each
and xsl:value-of
) are used to set all profiling member variables to zero.
Refers to global pointcut: constructor targetConstructor