[jboss-cvs] JBossAS SVN: r74523 - in projects/aop/trunk/aop/src: resources/test/benchmark and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 13 04:12:32 EDT 2008


Author: stalep
Date: 2008-06-13 04:12:32 -0400 (Fri, 13 Jun 2008)
New Revision: 74523

Added:
   projects/aop/trunk/aop/src/resources/test/benchmark/
   projects/aop/trunk/aop/src/resources/test/benchmark/jboss-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/DynamicAddRemoveBenchTester.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/Interceptor1.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/POJO.java
Log:
[JBAOP-578]
A simple benchmarktest for adding/removing advicebindings


Added: projects/aop/trunk/aop/src/resources/test/benchmark/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/benchmark/jboss-aop.xml	                        (rev 0)
+++ projects/aop/trunk/aop/src/resources/test/benchmark/jboss-aop.xml	2008-06-13 08:12:32 UTC (rev 74523)
@@ -0,0 +1,3 @@
+<aop>
+   <prepare expr="all(org.jboss.test.aop.benchmark.POJO)"/>
+</aop>

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/DynamicAddRemoveBenchTester.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/DynamicAddRemoveBenchTester.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/DynamicAddRemoveBenchTester.java	2008-06-13 08:12:32 UTC (rev 74523)
@@ -0,0 +1,88 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.aop.benchmark;
+
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.AdviceBinding;
+import org.jboss.aop.pointcut.ast.ParseException;
+import org.jboss.test.aop.AOPTestWithSetup;
+import org.jboss.test.aop.dynamic.Interceptor1;
+
+/**
+ * A DynamicAddRemoveBenchTester.
+ * 
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class DynamicAddRemoveBenchTester extends AOPTestWithSetup
+{
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("DynamicAddRemoveBenchTester");
+      suite.addTestSuite(DynamicAddRemoveBenchTester.class);
+      return suite;
+   }
+   
+   public DynamicAddRemoveBenchTester(String name)
+   {
+      super(name);
+   }
+   
+   public void testPerformance() throws ParseException
+   {
+      int size = 50000;
+      ArrayList<AdviceBinding> bindings = new ArrayList<AdviceBinding>(size);
+      long time = System.currentTimeMillis();
+      for(int i = 0; i < size; i++)
+      {
+         AdviceBinding binding = new AdviceBinding( 
+               "execution(public void org.jboss.test.aop.dynamic.POJO->i())", null); 
+         binding.setName("method"+size);
+         binding.addInterceptor(Interceptor1.class);
+      }
+      System.out.println("Creating the bindings took: "+(System.currentTimeMillis()-time));
+      
+      time = System.currentTimeMillis();
+      for(AdviceBinding ab : bindings)
+      {
+         AspectManager.instance().addBinding(ab);
+      }
+      System.out.println("Adding the bindings took: "+(System.currentTimeMillis()-time));
+      
+      time = System.currentTimeMillis();
+      for(AdviceBinding ab : bindings)
+      {
+         AspectManager.instance().removeBinding(ab.getName());
+      }
+      System.out.println("Removing the bindings took: "+(System.currentTimeMillis()-time));
+      
+      
+      assertTrue(true);
+   }
+
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/Interceptor1.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/Interceptor1.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/Interceptor1.java	2008-06-13 08:12:32 UTC (rev 74523)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.benchmark;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Interceptor1 implements Interceptor
+{
+   public static boolean intercepted;
+   public static int numberOfInterceptions = 0;
+   
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      intercepted = true;
+      numberOfInterceptions++;
+      return invocation.invokeNext();
+   }
+   
+   public static void clear()
+   {
+      numberOfInterceptions = 0;
+   }
+
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/POJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/POJO.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/benchmark/POJO.java	2008-06-13 08:12:32 UTC (rev 74523)
@@ -0,0 +1,48 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.aop.benchmark;
+
+/**
+ * A POJO.
+ * 
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJO
+{
+   
+   private int i;
+   private int j;
+   
+   public POJO() { }
+   
+   public void foo()
+   {
+      
+   }
+   
+   public void bar(int i)
+   {
+      this.i = i;
+   }
+
+}




More information about the jboss-cvs-commits mailing list