Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Re: [aspectj-users] Using AOP to implement double dispatching technique

Hi -

I was surprised by the result and confused by your AOP code.

Using a straightforward aspect to implement double-dispatch,
I got better performance using AOP than your hand coding:

----
Testing display of points using immediate method dispatching:31
Testing display of points using double dispatching:218
Testing display of graphical elements using instanceof and casting:125
Testing display of graphical elements using AOP:188
----

Attached is the full code base.  I did change the original code
to separate out the observer utility from the observer aspect
(no performance gain here, better modularized)[1] so I could
swap different aspect implementations in and out.  Then I wrote
both direct-dispatch and double-dispatch aspects.  Use the .lst
files to compile the different implementations and see the
different performance numbers.

Here is the aspect.  Is it correct by your standards?
It works when declaring methods on classes or interfaces.

(Readers take note that the double-dispatch uses
Screen.display({for each dispatching type})):

---------
package be.dc.aop.testing;

/** implement double-dispatch using aspects */
public aspect DoubleDispatchDisplayElements {
    public void GraphicalElement.displayOn(Screen screen) {
        screen.display(this);
    }

    void around (Screen screen, GraphicalElement graphicalElement):
           !withincode(void GraphicalElement.displayOn(Screen)) &&
            target (screen) &&
            call (void display(GraphicalElement)) &&
            args (graphicalElement) {
        graphicalElement.displayOn(screen);
    }

    // these could be in separate aspects

    public void Line.displayOn(Screen screen) {
        screen.display(this);
    }
    public void Point.displayOn(Screen screen) {
        screen.display(this);
    }
}
---------

If you get a nontrivial performance difference using AspectJ,
it's a safe bet that your aspects should be rewritten.

Wes

[1] The observer contributes only about 10ms to all;
-- perhaps there are no listeners.

Vankeirsbilck, Rudi. (BE - Merelbeke) wrote:

It is the result of the "introduction"-code.
You say that the introductions are really "inserted", are you sure that
ajc does not wrap them with other infrastructural code? That could
explain the difference in performance.

After applying the redesign to introduce an interface Screen performance
has decreased again:
Testing display of points using immediate method dispatching:70
Testing display of points using double dispatching:230
Testing display of graphical elements using instanceof and casting:230
Testing display of graphical elements using AOP:621

Therefor, I am really convinced that ajc does some wrapping somewhere.
Decompiling the code confirms this. There are a number of (static
however) methods that wrap around the calls.

Rudi.

-----Original Message-----
From: Stefan Hanenberg [mailto:shanenbe@xxxxxxxxxxxxxxxxxxxxxxx] Sent: donderdag 10 juli 2003 15:47
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Using AOP to implement double dispatching
technique



Testing display of points using immediate method dispatching:70 Testing display of points using double dispatching:240 Testing display


of graphical elements using instanceof and casting:250 Testing display


of graphical elements using AOP:351


just a question:

Is this measurement the result of the "around"- or the
"introduction"-code?

From my point of view the introduction code's performance cannot distinguish from the double-dispatch, because it is exactly the same code (introductions are really just "inserted").

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
This message (including any attachments) contains confidential
information intended for a specific individual and purpose, and is
protected by law.  If you are not the intended recipient, you should
delete this message.  Any disclosure, copying, or distribution of this
message, or the taking of any action based on it, is strictly
prohibited.


-----------------------------------------------------------------------


This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law.  If you are not the intended recipient, you should delete this message.  Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users

Attachment: ddUsingAOP-correct.zip
Description: Zip compressed data


Back to the top