[jboss-cvs] JBossAS SVN: r106765 - in projects/cl-benchmark/trunk: src/test/java and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 15 13:43:38 EDT 2010
Author: kabir.khan at jboss.com
Date: 2010-07-15 13:43:38 -0400 (Thu, 15 Jul 2010)
New Revision: 106765
Added:
projects/cl-benchmark/trunk/src/test/java/org/
projects/cl-benchmark/trunk/src/test/java/org/jboss/
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmark.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderBenchmarkTestDelegate.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassPathElementInfo.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/LoadingResult.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOwnLoaderBenchmarkTestCase.java
projects/cl-benchmark/trunk/src/test/resources/org/
projects/cl-benchmark/trunk/src/test/resources/org/jboss/
projects/cl-benchmark/trunk/src/test/resources/org/jboss/test/
projects/cl-benchmark/trunk/src/test/resources/org/jboss/test/cl/
projects/cl-benchmark/trunk/src/test/resources/org/jboss/test/cl/benchmark/
projects/cl-benchmark/trunk/src/test/resources/org/jboss/test/cl/benchmark/Common.xml
Modified:
projects/cl-benchmark/trunk/pom.xml
Log:
Do more things during setup
Modified: projects/cl-benchmark/trunk/pom.xml
===================================================================
--- projects/cl-benchmark/trunk/pom.xml 2010-07-15 17:29:57 UTC (rev 106764)
+++ projects/cl-benchmark/trunk/pom.xml 2010-07-15 17:43:38 UTC (rev 106765)
@@ -10,4 +10,70 @@
<name>JBoss Classloading Benchmark</name>
<version>0.0.1-SNAPSHOT</version>
<description>Benchmarks of the jboss-cl project</description>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/kernel/trunk/</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/kernel/trunk/</developerConnection>
+ <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/kernel/trunk/</url>
+ </scm>
+
+ <properties>
+ <version.jboss.jbossas>6.0.0.20100429-M3</version.jboss.jbossas>
+ <version.org.jboss.test>1.1.5.GA</version.org.jboss.test>
+ <version.junit>4.4</version.junit>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-depchain</artifactId>
+ <version>${version.jboss.jbossas}</version>
+ <type>pom</type>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-aop-mc-int</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-jmx-mc-int</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>${version.org.jboss.test}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId></groupId>
+ <artifactId></artifactId>
+ <version>${}</version>
+ </dependency -->
+ </dependencies>
+
</project>
\ No newline at end of file
Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmark.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmark.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmark.java 2010-07-15 17:43:38 UTC (rev 106765)
@@ -0,0 +1,108 @@
+/*
+* 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.cl.benchmark;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.test.AbstractTestCaseWithSetup;
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractClassLoaderBenchmark extends AbstractTestCaseWithSetup
+{
+ protected static final int NUM_CLASSES_TO_LOAD = 5;
+
+ public AbstractClassLoaderBenchmark(String name)
+ {
+ super(name);
+ }
+
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ return new ClassLoaderBenchmarkTestDelegate(clazz);
+ }
+
+ protected ClassLoaderBenchmarkTestDelegate getBenchmarkTestDelegate()
+ {
+ return (ClassLoaderBenchmarkTestDelegate)getDelegate();
+ }
+
+ public static ClassLoaderSystem getClassLoaderSystem()
+ {
+ DefaultClassLoaderSystem system = new DefaultClassLoaderSystem();
+ ClassLoaderDomain defaultDomain = system.getDefaultDomain();
+ defaultDomain.setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY);
+ return system;
+ }
+
+ private void trim(List<ClassLoaderInfo> infos)
+ {
+ for (Iterator<ClassLoaderInfo> it = infos.iterator() ; it.hasNext() ; )
+ {
+ if (it.next().getClassNames().size() == 0)
+ it.remove();
+ }
+ }
+
+ protected void runBenchmark(BenchmarkScenario scenario) throws Exception
+ {
+ List<ClassLoaderInfo> classLoaderInfos = scenario.createFactories(getBenchmarkTestDelegate().getClassPathElements());
+
+ System.out.println("Starting run. " + classLoaderInfos.size() + " jars indexed, will attempt to load " + NUM_CLASSES_TO_LOAD + " class from each.");
+ trim (classLoaderInfos);
+ System.out.println("Trimmed the empty jars, " + classLoaderInfos.size() + " to deploy.");
+
+ LoadingResult result = new LoadingResult();
+
+ long start = System.currentTimeMillis();
+ for (ClassLoaderInfo info : classLoaderInfos) {
+ info.initialize(result, getBenchmarkTestDelegate().install(info.getFactory()), NUM_CLASSES_TO_LOAD);
+ }
+ long time = System.currentTimeMillis() - start;
+ System.out.println("Creating " + classLoaderInfos.size() + " class loaders took." + time + "ms");
+
+ System.out.println("Load classes...");
+
+ start = System.currentTimeMillis();
+ scenario.loadClasses(classLoaderInfos);
+ time = System.currentTimeMillis() - start;
+ System.out.println("Loading classes took." + time + "ms");
+ System.out.println("\n");
+ System.out.println("================================");
+ System.out.println("Stats:");
+ System.out.println("================================");
+ System.out.println("Successful classes: " + result.getSuccess());
+ System.out.println("Failed classes: " + result.getFailed());
+ System.out.println("Wrong loader (filter): " + result.getBadFilter());
+
+
+ }
+}
Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java 2010-07-15 17:43:38 UTC (rev 106765)
@@ -0,0 +1,36 @@
+/*
+* 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.cl.benchmark;
+
+import java.util.List;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface BenchmarkScenario
+{
+ List<ClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos);
+
+ void loadClasses(List<ClassLoaderInfo> infos);
+}
Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderBenchmarkTestDelegate.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderBenchmarkTestDelegate.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderBenchmarkTestDelegate.java 2010-07-15 17:43:38 UTC (rev 106765)
@@ -0,0 +1,115 @@
+/*
+* 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.cl.benchmark;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.resource.spi.IllegalStateException;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassLoaderBenchmarkTestDelegate extends MicrocontainerTestDelegate
+{
+ private List<ClassPathElementInfo> classPathElements = new ArrayList<ClassPathElementInfo>();
+
+ public ClassLoaderBenchmarkTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ String classpath = System.getProperty("java.class.path");
+ String[] jars = classpath.split(File.pathSeparator);
+
+ int packages = 0;
+ int classes = 0;
+ int excluded = 0;
+ for (String jar : jars)
+ {
+ if (ClassPathElementInfo.isJar(jar))
+ {
+ ClassPathElementInfo info = ClassPathElementInfo.of(jar);
+ if (info != null)
+ {
+ classPathElements.add(info);
+ packages += info.getPackageNames().size();
+ classes += info.getClassNames().size();
+ }
+ else
+ excluded++;
+ }
+ }
+
+ System.out.println(classPathElements.size() + " jars indexed. Classes: " + classes + ". Packages: " + packages + ". Excluded: " + excluded);
+
+ URL commonUrl = getClass().getResource("/org/jboss/test/cl/benchmark/Common.xml");
+ if (commonUrl == null)
+ throw new IllegalStateException("Null common url");
+ deploy(commonUrl);
+ }
+
+ List<ClassPathElementInfo> getClassPathElements()
+ {
+ return Collections.unmodifiableList(classPathElements);
+ }
+
+ ClassLoader install(VFSClassLoaderFactory factory) throws Exception
+ {
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName(factory.getName() + ":" + factory.getVersion());
+ deployment.setBeanFactories(Collections.singletonList((BeanMetaDataFactory) factory));
+ deploy(deployment);
+
+ Object object = getBean(getContextName(factory), ControllerState.INSTALLED);
+ if (object instanceof ClassLoader == false)
+ throw new AssertionFailedError(object + " is not a classloader");
+
+ return (ClassLoader)object;
+ }
+
+ protected String getContextName(VFSClassLoaderFactory factory)
+ {
+ String contextName = factory.getContextName();
+ if (contextName == null)
+ contextName = factory.getName() + ":" + factory.getVersion();
+ return contextName;
+ }
+}
Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java 2010-07-15 17:43:38 UTC (rev 106765)
@@ -0,0 +1,127 @@
+/*
+* 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.cl.benchmark;
+
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassLoaderInfo
+{
+ private static final ClassLoader SYSTEM = ClassLoader.getSystemClassLoader();
+
+ private final ClassPathElementInfo elementInfo;
+ private final VFSClassLoaderFactory factory;
+ private ClassLoader loader;
+ private LoadingResult result;
+ private String[] classesToLoad;
+
+ public ClassLoaderInfo(ClassPathElementInfo info, VFSClassLoaderFactory factory)
+ {
+ this.elementInfo = info;
+ this.factory = factory;
+ }
+
+ public VFSClassLoaderFactory getFactory()
+ {
+ return factory;
+ }
+
+ void initialize(LoadingResult result, ClassLoader loader, int num)
+ {
+ this.loader = loader;
+ this.result = result;
+
+ if (classesToLoad != null)
+ return;
+
+ List<String> all = elementInfo.getClassNames();
+
+ if (all.size() <= num)
+ classesToLoad = all.toArray(new String[all.size()]);
+ else
+ {
+ int index = all.size() / 2;
+ classesToLoad = new String[num];
+ for (int i = 0 ; i < num ; i++)
+ {
+ index += i * (i % 2 == 1 ? -1 : +1);
+ //int j = (i * (i % 2 == 1 ? -1 : +1) + index);
+ classesToLoad[i] = all.get(index);
+ }
+ }
+
+ }
+
+ public void loadClass(String className)
+ {
+ try
+ {
+ Class<?> clazz = loader.loadClass(className);
+ if (clazz.getClassLoader() == SYSTEM)
+ result.incrementBadFilter();
+ else
+ result.incrementSuccess();
+ }
+ catch(ClassNotFoundException e)
+ {
+ result.incrementFailed();
+ }
+ catch(NoClassDefFoundError e)
+ {
+ result.incrementFailed();
+ }
+
+ }
+
+ List<String> getClassNames()
+ {
+ return elementInfo.getClassNames();
+ }
+
+ public String getName()
+ {
+ return elementInfo.getName();
+ }
+
+ public List<String> getPackageNames()
+ {
+ return elementInfo.getPackageNames();
+ }
+
+ public URL getUrl()
+ {
+ return elementInfo.getUrl();
+ }
+
+ public String[] getClassesToLoad()
+ {
+ return classesToLoad;
+ }
+
+}
Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassPathElementInfo.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassPathElementInfo.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassPathElementInfo.java 2010-07-15 17:43:38 UTC (rev 106765)
@@ -0,0 +1,148 @@
+/*
+* 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.cl.benchmark;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassPathElementInfo
+{
+ //Exclude
+ private static final String[] EXCLUDED_JARS = new String[]{"-client",
+ "aspects",
+ "jboss-metadata-ejb",
+ "jboss-integration",
+ "ejb3",
+ "jboss-as-connector",
+ ".osgi.",
+ "-osgi-",
+ "pax-web-extender",
+ "pax-swissbox",
+ "-jmx-adaptor-plugin",
+ "-jboss.jar",
+ "jasper",
+ "-jboss-web-service.jar",
+ "jboss-web-deployer.jar",
+ "-srp.jar",
+ "wstx-asl",
+ "hibernate-3.2",
+ "quartz",
+ "slf4j",
+ "stax-ex-1.2"};
+
+ private final String name;
+ private final URL url;
+ private final List<String> packageNames;
+ private final List<String> classNames;
+
+ private ClassPathElementInfo(String name, URL url, List<String> packageNames, List<String> classNames)
+ {
+ this.name = name;
+ this.packageNames = packageNames;
+ this.classNames = classNames;
+ this.url = url;
+ }
+
+ public static ClassPathElementInfo of(String name) throws Exception
+ {
+ if (!isJar(name))
+ throw new IllegalArgumentException("Not a jar " + name);
+
+ File file = new File(name);
+ if (!file.exists())
+ throw new IllegalArgumentException("Could not find " + file);
+
+ if (isExcluded(name))
+ return null;
+
+
+ List<String> packages = new ArrayList<String>();
+ List<String> classes = new ArrayList<String>();
+ try
+ {
+ JarFile jar = new JarFile(file);
+ for (Enumeration<JarEntry> e = jar.entries() ; e.hasMoreElements() ; )
+ {
+ JarEntry entry = e.nextElement();
+
+ //TODO - replace '/' with '.'?
+ if (entry.getName().endsWith("/"))
+ packages.add(entry.getName().replace('/', '.'));
+ else if (entry.getName().endsWith(".class"))
+ classes.add(entry.getName().substring(0, entry.getName().indexOf(".class")).replace('/', '.'));
+ }
+
+ return new ClassPathElementInfo(name, new File(name).toURI().toURL(), packages, classes);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public List<String> getPackageNames()
+ {
+ return packageNames;
+ }
+
+ public List<String> getClassNames()
+ {
+ return classNames;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public URL getUrl()
+ {
+ return url;
+ }
+
+ static boolean isJar(String name)
+ {
+ return name.endsWith(".jar");
+ }
+
+ private static boolean isExcluded(String name)
+ {
+ for (String excluded : EXCLUDED_JARS)
+ {
+ if (name.contains(excluded))
+ return true;
+ }
+ return false;
+ }
+
+}
Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/LoadingResult.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/LoadingResult.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/LoadingResult.java 2010-07-15 17:43:38 UTC (rev 106765)
@@ -0,0 +1,69 @@
+/*
+* 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.cl.benchmark;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LoadingResult
+{
+ int success;
+ int failed;
+ int badFilter;
+
+ LoadingResult()
+ {
+
+ }
+
+ void incrementSuccess()
+ {
+ success++;
+ }
+
+ void incrementFailed()
+ {
+ failed++;
+ }
+
+ void incrementBadFilter()
+ {
+ badFilter++;
+ }
+
+ public int getSuccess()
+ {
+ return success;
+ }
+
+ public int getFailed()
+ {
+ return failed;
+ }
+
+ public int getBadFilter()
+ {
+ return badFilter;
+ }
+}
Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOwnLoaderBenchmarkTestCase.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOwnLoaderBenchmarkTestCase.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOwnLoaderBenchmarkTestCase.java 2010-07-15 17:43:38 UTC (rev 106765)
@@ -0,0 +1,85 @@
+/*
+* 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.cl.benchmark.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.test.cl.benchmark.AbstractClassLoaderBenchmark;
+import org.jboss.test.cl.benchmark.BenchmarkScenario;
+import org.jboss.test.cl.benchmark.ClassPathElementInfo;
+import org.jboss.test.cl.benchmark.ClassLoaderInfo;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ImportExportAllOwnLoaderBenchmarkTestCase extends AbstractClassLoaderBenchmark
+{
+ public ImportExportAllOwnLoaderBenchmarkTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testSanity() throws Exception
+ {
+ runBenchmark(new BenchmarkScenario()
+ {
+
+ public List<ClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
+ {
+ List<ClassLoaderInfo> deploymentInfos = new ArrayList<ClassLoaderInfo>();
+
+ for (ClassPathElementInfo info : infos)
+ {
+ VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+ factory.setExportAll(ExportAll.NON_EMPTY);
+ factory.setImportAll(true);
+ factory.getRoots().add(info.getUrl().toString());
+ //Needed???
+ //factory.setIncludedPackages()
+
+ deploymentInfos.add(new ClassLoaderInfo(info, factory));
+ }
+
+ return deploymentInfos;
+ }
+
+ public void loadClasses(List<ClassLoaderInfo> infos)
+ {
+ for (ClassLoaderInfo info : infos)
+ {
+ String[] names = info.getClassesToLoad();
+
+ for (int i = 0 ; i < names.length ; i++)
+ {
+ info.loadClass(names[i]);
+ }
+ }
+ }
+
+ });
+ }
+}
Added: projects/cl-benchmark/trunk/src/test/resources/org/jboss/test/cl/benchmark/Common.xml
===================================================================
--- projects/cl-benchmark/trunk/src/test/resources/org/jboss/test/cl/benchmark/Common.xml (rev 0)
+++ projects/cl-benchmark/trunk/src/test/resources/org/jboss/test/cl/benchmark/Common.xml 2010-07-15 17:43:38 UTC (rev 106765)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="ClassLoaderSystem" class="org.jboss.classloader.spi.ClassLoaderSystem">
+ <constructor factoryClass="org.jboss.test.cl.benchmark.AbstractClassLoaderBenchmark" factoryMethod="getClassLoaderSystem"/>
+ </bean>
+
+ <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
+ <incallback method="addModule" state="Configured"/>
+ <incallback method="addGlobalCapabilitiesProvider" state="Configured"/>
+ <uncallback method="removeModule" state="Configured"/>
+ <uncallback method="removeGlobalCapabilitiesProvider" state="Configured"/>
+ </bean>
+
+ <bean name="SchemaResolverConfig" class="org.jboss.xb.binding.sunday.unmarshalling.SchemaResolverConfig">
+ <property name="bindingClasses">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>urn:jboss:classloader:1.0</key>
+ <value>org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10</value>
+ </entry>
+ <entry>
+ <key>urn:jboss:classloading:1.0</key>
+ <value>org.jboss.classloading.spi.metadata.ClassLoadingMetaData10</value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+</deployment>
More information about the jboss-cvs-commits
mailing list