Efficiency Aspect
[C-language Group]

This aspect is defined in file: ../../AspectXLib/c/quickSort/aspects/comparisonCounter.ax

Aspect Description

This aspect counts the number of comparisons made by the quick sort algorithm. This can give a measure of efficiency of the algorithm.
Author:
I. Birrer

Pointcuts

blockallIfBlocks
  Points to all if blocks

Advices

beginbeginOfIfBlock
  Increments the comparison counter for each comparison made
addaddComparison definition
  Add comparisonCount declaration
beforebeforeTermination
  Outputs the number of comparisons made by the algorithm, before the program exits

Pointcut Documentation

block allIfBlocks (source)
Points to all if blocks. The poinctut is defined as follows: In srcML if statements are identified by the src:if element. The if part is then identified by a src:then child element whereas the else block is identified as a src:else child element. The if part further can have a src:block child element which contains the block. Hence if we identify all src:block elements with a parent element src:then then we get all blocks of all if statements. Note that if statements without blocks are not affected by weaving!

Advice Documentation

begin beginOfIfBlock (source)

Triplet: block begin codeFragment

Increments the comparison counter for each comparison made. Each if statement in the base code is considered as a comparison.

Refers to global pointcut: block allIfBlocks

add addComparison definition (source)

Triplet: unit add declaration

Add comparisonCount declaration. Since there is no weaving rule defined for adding a declaration at the begin of a unit, the "add include" weaving rule is used. This works just fine for now, as long as the "inlude weaving rules" does not perform any tests whether the added string is an include statement or not.

Local Pointcut: unit (source)

before beforeTermination (source)

Triplet: return before codeFragment

Outputs the number of comparisons made by the algorithm, before the program exits. The programs exits when the main function is left or more precisely when return is called in the main function. To add a statement at the exit of a program therefore means to add a statement before any return apperaing in the main function. The pointcut that points to all return elements appearing within the main function is expressed using a restriction of type within. The instruction that is added to the code prints the value of the comparisonCounter variable.

Local Pointcut: return (source)