Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Very Slow Fields Cut

I've just tried your program, first on a 1.5 VM.   I also changed your
benchmark code to do the run three times in the main() method so the
JIT has a chance to be 'warmed up' with the code paths.

Super:106
Normal:16
Super:80
Normal:16
Super:82
Normal:16

I then tried it with a 1.6VM:
Super:63
Normal:9
Super:33
Normal:9
Super:32
Normal:9

Not brilliant, I know, but not as bad as you seem to be seeing.  Even
though you are only doing proceed() from your advice at the moment,
the code is all in place for obtaining the aspect instance at each
join point and then invoking the advice.  So if you did more in your
advice body, it won't be a further large performance impact, it is
purely getting to the advice that is the big impact.  For the case
where proceed() is all you do in the advice we could optimize it all
away and do no weaving, but that is the rather uncommon case...

cheers,
Andy.

2008/5/9 nnaass <alaamurad@xxxxxxxxx>:
>
> Hi everyone,
> I'm trying to cut across all fields sets and gets in my class but aspectj is
> delivering very low performance even while I'm just directly calling the
> proceed() in the point cut.
>
> I created 2 classes, one with aspectj (SuperCar) and one just POJO (Car) the
> SuperCar has a pointcut in  all the fields (for now only the "model" field
> ).
>
> ////////////////////////////////////////////////////////
> public class Car {
>    private int model=0;
>    public int getModel() {
>        return model;
>    }
>    public void setModel(int model) {
>        this.model = model;
>    }
> }
>
> ////////////////////////////////////////////////////////
>
> /**
> * This will cut all get & set in the SuperCar ( But as you can see that I'm
> doing nothing only passing it again using proceed )
> */
> public privileged aspect SuperObjectController{
>    pointcut getProperty(SuperObject o): this(o) && get(@SuperProperty * *)
> && target(SuperObject+);
>    Object around(SuperObject o):
>    getProperty(o)
>    {
>        return proceed(o);
>    }
>    pointcut setProperty(SuperObject o,Object v): this(o) && args(v) &&
> set(@SuperProperty * *) && target(SuperObject+) ;
>    void around(SuperObject o,Object v):
>    setProperty(o,v)
>    {
>        proceed(o,v);
>    }
> }
>
> ///////////////////////////////////////////////////////
>
> @Retention(RetentionPolicy.RUNTIME)
> @Target(ElementType.FIELD)
>
> public @interface SuperProperty {
>    boolean ensureGroupValue() default false;
> }
>
> /////////////////////////////////////////////////////
> public class SuperObject {
> }
> /////////////////////////////////////////////////////
> public class SuperCar extends SuperObject{
>    @SuperProperty private int model=0;
>
>    public int getModel() {
>        return model;
>    }
>
>    public void setModel(int model) {
>        this.model = model;
>    }
>
> }
> ///////////////////////////////////////////////////////
> public static void main(String[] args) {
>        // TODO code application logic here
>        int LOOP=1000000;
>        long lastTime,currentTime;
>        int out;
>        lastTime=System.currentTimeMillis();
>        SuperCar superCar=new SuperCar();
>        superCar.setModel(0);
>        for (int i=0;i<LOOP;i++){
>            //Set
>            superCar.setModel(i);
>            //Get
>            out=superCar.getModel();
>        }
>        currentTime=System.currentTimeMillis()-lastTime;
>        System.out.println("Super:"+currentTime);
>        lastTime=System.currentTimeMillis();
>        Car car=new Car();
>        for (int i=0;i<LOOP;i++){
>            //Set
>            car.setModel(i);
>            //Get
>            out=car.getModel();
>        }
>        currentTime=System.currentTimeMillis()-lastTime;
>        System.out.println("Normal:"+currentTime);
> }
> ///////////////////////////////////////////////////////
> this is the output for both classes.
>
> Super:414
> Normal:35
>
> As you can see that the Super toke 0.414 second  to set and get while the
> POJO toke only 0.035 , I don't understand why aspectj it to slow ? How it's
> being compile ?
>
> POJO  is about 11.4 times faster without aspectJ cuts. I was thinking it
> would be 50% slower for the extra call but not 8 % !.
>
>
> Thanks in advance
> --
> View this message in context: http://www.nabble.com/Very-Slow-Fields-Cut-tp17139141p17139141.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top