[jboss-cvs] JBossAS SVN: r101404 - in projects/kernel/trunk: kernel/src/test/java/org/jboss/test/kernel/benchmark/support and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 24 10:20:15 EST 2010


Author: kabir.khan at jboss.com
Date: 2010-02-24 10:20:14 -0500 (Wed, 24 Feb 2010)
New Revision: 101404

Added:
   projects/kernel/trunk/dependency/src/test/java/org/jboss/test/dependency/controller/benchmark/AbstractContextRegistryBenchmark.java
   projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/support/SimpleBean.java
   projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/support/SimpleBeanCallback.java
   projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/test/CallbackBenchmark.java
Log:
Add a few more benchmarks

Added: projects/kernel/trunk/dependency/src/test/java/org/jboss/test/dependency/controller/benchmark/AbstractContextRegistryBenchmark.java
===================================================================
--- projects/kernel/trunk/dependency/src/test/java/org/jboss/test/dependency/controller/benchmark/AbstractContextRegistryBenchmark.java	                        (rev 0)
+++ projects/kernel/trunk/dependency/src/test/java/org/jboss/test/dependency/controller/benchmark/AbstractContextRegistryBenchmark.java	2010-02-24 15:20:14 UTC (rev 101404)
@@ -0,0 +1,96 @@
+/*
+* 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.dependency.controller.benchmark;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.plugins.tracker.AbstractContextRegistry;
+import org.jboss.dependency.plugins.tracker.AbstractContextRegistry2;
+import org.jboss.dependency.spi.ControllerContext;
+
+import junit.framework.TestCase;
+
+/**
+ * In normal operation each context gets added once and removed once, then getExposedClasses() is called 14 times as we resolve callbacks on install/uninstall 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractContextRegistryBenchmark extends TestCase
+{
+   int iterations = 50;
+   int count = 10000;
+   
+   Object o;
+   
+   public void testContextRegistry()
+   {
+      AbstractContextRegistry registry = new AbstractContextRegistry(new AbstractController());
+//      AbstractContextRegistry2 registry = new AbstractContextRegistry2(new AbstractController());
+      
+      List<ControllerContext> contexts = createContexts();
+      
+      long start = System.currentTimeMillis();
+      
+      
+      for (int k = 0 ; k < iterations ; k++)
+      {
+         for (int i = 0 ; i < count ; i++)
+         {
+            ControllerContext ctx = contexts.get(0);
+            registry.addInstantiatedContext(ctx);
+            for (int j = 0 ; j < 14 ; j++)
+            {
+               o = registry.getExposedClasses(ctx);
+            }
+            registry.removeInstantiatedContext(ctx);
+         }
+      }
+      
+      System.out.println("=========> " + (System.currentTimeMillis() - start));
+   }
+   
+   private List<ControllerContext> createContexts()
+   {
+      Object[] objects = new Object[] {
+            new A0(),
+            new A1(),
+            new A2(),
+            new A3(),
+            new A4()};
+      List<ControllerContext> contexts = new ArrayList<ControllerContext>();
+      for (int i = 0 ; i < count ; i++)
+      {
+         ControllerContext ctx = new AbstractControllerContext("Bean" + i, objects[i % 5]);
+         contexts.add(ctx);
+      }
+      return contexts;
+   }
+   
+   static class A0{}
+   static class A1 extends A0{}
+   static class A2 extends A1{}
+   static class A3 extends A2{}
+   static class A4 extends A3{}
+}

Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/support/SimpleBean.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/support/SimpleBean.java	                        (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/support/SimpleBean.java	2010-02-24 15:20:14 UTC (rev 101404)
@@ -0,0 +1,32 @@
+/*
+* 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.kernel.benchmark.support;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleBean
+{
+
+}

Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/support/SimpleBeanCallback.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/support/SimpleBeanCallback.java	                        (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/support/SimpleBeanCallback.java	2010-02-24 15:20:14 UTC (rev 101404)
@@ -0,0 +1,46 @@
+/*
+* 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.kernel.benchmark.support;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleBeanCallback
+{
+   int count;
+   public void addBean(SimpleBean bean)
+   {
+      count++;
+   }
+   
+   public void removeBean(SimpleBean bean)
+   {
+      count--;
+   }
+   
+   public int getCount()
+   {
+      return count;
+   }
+}

Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/test/CallbackBenchmark.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/test/CallbackBenchmark.java	                        (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/benchmark/test/CallbackBenchmark.java	2010-02-24 15:20:14 UTC (rev 101404)
@@ -0,0 +1,79 @@
+   
+/*
+* 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.kernel.benchmark.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.test.kernel.benchmark.support.SimpleBean;
+import org.jboss.test.kernel.benchmark.support.SimpleBeanCallback;
+import org.jboss.test.kernel.benchmark.support.ObjectWithLotsOfProperties;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class CallbackBenchmark extends AbstractBenchmark
+{
+   int callbacks = 3;
+   public CallbackBenchmark(String name)
+   {
+      super(name);
+      super.iterations = 50;
+   }
+
+   @Override
+   protected List<BeanMetaData> setupContexts()
+   {
+      List<BeanMetaData> beans = new ArrayList<BeanMetaData>(iterations);
+      
+      for (int i = 0 ; i < callbacks ; i++)
+      {
+        BeanMetaDataBuilder callbackBuilder = BeanMetaDataBuilder.createBuilder("Callback" + i, SimpleBeanCallback.class.getName());
+        callbackBuilder.addMethodInstallCallback("addBean");
+        callbackBuilder.addMethodUninstallCallback("removeBean");
+        beans.add(callbackBuilder.getBeanMetaData());
+      }
+      
+      for (int i = callbacks ; i < iterations ; i++)
+      {
+         BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("Bean" + i, SimpleBean.class.getName());
+         beans.add(builder.getBeanMetaData());
+      }
+      return beans;
+   }
+   
+   @Override
+   protected void extraCheck(ControllerContext ctx)
+   {
+      if (((String)ctx.getName()).startsWith("Callback"))
+      {
+         SimpleBeanCallback obj = (SimpleBeanCallback)ctx.getTarget();
+         assertEquals(iterations - callbacks , obj.getCount());
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list