diff options
author | acolyer <acolyer> | 2006-01-20 12:28:01 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2006-01-20 12:28:01 +0000 |
commit | 17865f45b709f5b8adf86acff50dd5d05ea4a4f0 (patch) | |
tree | 206c74e8fb7aa6326fb8b3a30153cc03b41a6d5e /tests/profiling/ltw-app | |
parent | 7a9a69e5c82ee9ee59f94cc68d69a3c25c36b5ff (diff) | |
download | aspectj-17865f45b709f5b8adf86acff50dd5d05ea4a4f0.tar.gz aspectj-17865f45b709f5b8adf86acff50dd5d05ea4a4f0.zip |
ant script for running profiling tests against aspectj with ajc source compile, binary weaving, load-time weaving, and AJDT simulation. Can configure target application and source of compiler (workspace or pre-built jars).
Diffstat (limited to 'tests/profiling/ltw-app')
-rw-r--r-- | tests/profiling/ltw-app/META-INF/aop.xml | 5 | ||||
-rw-r--r-- | tests/profiling/ltw-app/src/org/aspectj/profiling/LTWApp.java | 74 |
2 files changed, 79 insertions, 0 deletions
diff --git a/tests/profiling/ltw-app/META-INF/aop.xml b/tests/profiling/ltw-app/META-INF/aop.xml new file mode 100644 index 000000000..782ed75ca --- /dev/null +++ b/tests/profiling/ltw-app/META-INF/aop.xml @@ -0,0 +1,5 @@ +<aspectj> + <weaver> + <include within="org.springframework..*"/> + </weaver> +</aspectj>
\ No newline at end of file diff --git a/tests/profiling/ltw-app/src/org/aspectj/profiling/LTWApp.java b/tests/profiling/ltw-app/src/org/aspectj/profiling/LTWApp.java new file mode 100644 index 000000000..a247fb10b --- /dev/null +++ b/tests/profiling/ltw-app/src/org/aspectj/profiling/LTWApp.java @@ -0,0 +1,74 @@ +/* ******************************************************************* + * Copyright (c) 2006 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Adrian Colyer Initial implementation + * ******************************************************************/ +package org.aspectj.profiling; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +/** + * Application that takes a single argument containing the name of a + * jar file, and performs Class.forName on every class within it. + */ +public class LTWApp { + + private File inJar; + private int numLoaded = 0; + + public static void main(String[] args) throws IOException { + if (args.length != 1) { + throw new IllegalArgumentException("Expecting a single jar file argument"); + } + new LTWApp(args[0]).run(); + } + + public LTWApp(String jarFileName) { + inJar = new File(jarFileName); + if (!inJar.exists() || !inJar.canRead()) { + throw new IllegalArgumentException("File '" + jarFileName + + "' does not exist or cannot be read"); + } + } + + public void run() throws IOException { + ZipInputStream inStream = new ZipInputStream(new FileInputStream(inJar)); + long startTime = System.currentTimeMillis(); + while (true) { + ZipEntry entry = inStream.getNextEntry(); + if (entry == null) break; + + if (entry.isDirectory() || !entry.getName().endsWith(".class")) { + continue; + } + + loadClass(entry.getName()); + } + long endTime = System.currentTimeMillis(); + System.out.println("Loaded " + numLoaded + " classes in " + (endTime - startTime) + " milliseconds"); + } + + private void loadClass(String classFileName) { + String className = classFileName.substring(0,(classFileName.length() - ".class".length())); + className = className.replace('/','.'); + try { + Class c = Class.forName(className); + } + catch(ClassNotFoundException ex) { + throw new IllegalStateException("Unable to load class defined in input jar file, check that jar is also on the classpath!"); + } + numLoaded++; + } +}
\ No newline at end of file |