Commit b4cd55bb authored by Eric Bruneton's avatar Eric Bruneton

Add ASM 6.2 and HEAD to the benchmarks. Also update the Gradle and JMH plugin versions.

parent be1d31b9
Pipeline #2642 passed with stage
in 7 minutes and 40 seconds
image: gradle:4.8-jdk8-alpine
image: gradle:4.9-jdk8-alpine
variables:
# Set the location of the dependency cache to a local directory, so that it
......
......@@ -49,8 +49,10 @@ public abstract class AbstractBenchmark {
private static final String ASM4_0 = BUILD_DIR + "asm4.0/";
private static final String ASM5_0 = BUILD_DIR + "asm5.0.1/";
private static final String ASM6_0 = BUILD_DIR + "asm6.0/";
private static final String ASM_CORE_6_1 = "/asm/build/classes/java/main/";
private static final String ASM_TREE_6_1 = "/asm-tree/build/classes/java/main/";
private static final String ASM6_1 = BUILD_DIR + "asm6.1.1/";
private static final String ASM6_2 = BUILD_DIR + "asm6.2.1/";
private static final String ASM_CORE_CURRENT = "/asm/build/classes/java/main/";
private static final String ASM_TREE_CURRENT = "/asm-tree/build/classes/java/main/";
private final String asmBenchmarkClass;
private final String userDir;
......@@ -63,7 +65,9 @@ public abstract class AbstractBenchmark {
V4_0,
V5_0,
V6_0,
V6_1;
V6_1,
V6_2,
V_CURRENT;
URL[] getUrls(final String baseUrl) throws MalformedURLException {
switch (this) {
......@@ -74,7 +78,13 @@ public abstract class AbstractBenchmark {
case V6_0:
return new URL[] {new URL(baseUrl + ASM6_0)};
case V6_1:
return new URL[] {new URL(baseUrl + ASM_CORE_6_1), new URL(baseUrl + ASM_TREE_6_1)};
return new URL[] {new URL(baseUrl + ASM6_1)};
case V6_2:
return new URL[] {new URL(baseUrl + ASM6_2)};
case V_CURRENT:
return new URL[] {
new URL(baseUrl + ASM_CORE_CURRENT), new URL(baseUrl + ASM_TREE_CURRENT)
};
default:
throw new AssertionError();
}
......@@ -94,8 +104,8 @@ public abstract class AbstractBenchmark {
/** Creates and populates {@link #classFiles} with some class files read from disk. */
protected void prepareClasses() throws IOException {
classFiles = new ArrayList<byte[]>();
findClasses(new File(userDir + ASM_CORE_6_1), classFiles);
findClasses(new File(userDir + ASM_TREE_6_1), classFiles);
findClasses(new File(userDir + ASM_CORE_CURRENT), classFiles);
findClasses(new File(userDir + ASM_TREE_CURRENT), classFiles);
}
private static void findClasses(final File directory, final ArrayList<byte[]> classFiles)
......@@ -134,8 +144,7 @@ public abstract class AbstractBenchmark {
/**
* Constructs an {@link AsmBenchmarkFactory}.
*
* @param asmDirectories the directories where the ASM library classes can be found.
* @param asmBenchmarkClass the class that must be instantiated by this factory.
* @param asmVersion the ASM version to use.
* @throws MalformedURLException
*/
AsmBenchmarkFactory(final AsmVersion asmVersion) throws MalformedURLException {
......@@ -147,7 +156,6 @@ public abstract class AbstractBenchmark {
* @throws ClassNotFoundException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws Exception
*/
public Object newAsmBenchmark()
throws InstantiationException, IllegalAccessException, ClassNotFoundException {
......
......@@ -53,6 +53,8 @@ public class AdapterBenchmark extends AbstractBenchmark {
private Adapter asm5_0;
private Adapter asm6_0;
private Adapter asm6_1;
private Adapter asm6_2;
private Adapter asmCurrent;
private Adapter aspectJBcel;
private Adapter bcel;
private Adapter javassist;
......@@ -74,6 +76,8 @@ public class AdapterBenchmark extends AbstractBenchmark {
asm5_0 = (Adapter) new AsmBenchmarkFactory(AsmVersion.V5_0).newAsmBenchmark();
asm6_0 = (Adapter) new AsmBenchmarkFactory(AsmVersion.V6_0).newAsmBenchmark();
asm6_1 = (Adapter) new AsmBenchmarkFactory(AsmVersion.V6_1).newAsmBenchmark();
asm6_2 = (Adapter) new AsmBenchmarkFactory(AsmVersion.V6_2).newAsmBenchmark();
asmCurrent = (Adapter) new AsmBenchmarkFactory(AsmVersion.V_CURRENT).newAsmBenchmark();
aspectJBcel = new AspectJBCELAdapter();
bcel = new BCELAdapter();
javassist = new JavassistAdapter();
......@@ -83,7 +87,9 @@ public class AdapterBenchmark extends AbstractBenchmark {
if (!asm4_0.getVersion().equals("ASM4")
|| !asm5_0.getVersion().equals("ASM5")
|| !asm6_0.getVersion().equals("ASM6")
|| !asm6_1.getVersion().equals("ASM6")) {
|| !asm6_1.getVersion().equals("ASM6")
|| !asm6_2.getVersion().equals("ASM6")
|| !asmCurrent.getVersion().equals("ASM6")) {
throw new IllegalStateException();
}
......@@ -118,6 +124,20 @@ public class AdapterBenchmark extends AbstractBenchmark {
}
}
@Benchmark
public void getClassInfo_asm6_2(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asm6_2.getClassInfo(classFile));
}
}
@Benchmark
public void getClassInfo_asmCurrent(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asmCurrent.getClassInfo(classFile));
}
}
@Benchmark
public void getClassObjectModel_asm4_0(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
......@@ -146,6 +166,20 @@ public class AdapterBenchmark extends AbstractBenchmark {
}
}
@Benchmark
public void getClassObjectModel_asm6_2(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asm6_2.getClassObjectModel(classFile));
}
}
@Benchmark
public void getClassObjectModel_asmCurrent(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asmCurrent.getClassObjectModel(classFile));
}
}
@Benchmark
public void read_asm4_0(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
......@@ -174,6 +208,20 @@ public class AdapterBenchmark extends AbstractBenchmark {
}
}
@Benchmark
public void read_asm6_2(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asm6_2.read(classFile));
}
}
@Benchmark
public void read_asmCurrent(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asmCurrent.read(classFile));
}
}
@Benchmark
public void readAndWrite_asm4_0(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
......@@ -202,6 +250,20 @@ public class AdapterBenchmark extends AbstractBenchmark {
}
}
@Benchmark
public void readAndWrite_asm6_2(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asm6_2.readAndWrite(classFile, /* computeMaxs = */ false));
}
}
@Benchmark
public void readAndWrite_asmCurrent(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asmCurrent.readAndWrite(classFile, /* computeMaxs = */ false));
}
}
@Benchmark
public void readAndWrite_aspectJBcel(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
......@@ -258,6 +320,20 @@ public class AdapterBenchmark extends AbstractBenchmark {
}
}
@Benchmark
public void readAndWriteWithComputeFrames_asm6_2(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asm6_2.readAndWriteWithComputeFrames(classFile));
}
}
@Benchmark
public void readAndWriteWithComputeFrames_asmCurrent(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asmCurrent.readAndWriteWithComputeFrames(classFile));
}
}
@Benchmark
public void readAndWriteWithComputeMaxs_asm4_0(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
......@@ -286,6 +362,20 @@ public class AdapterBenchmark extends AbstractBenchmark {
}
}
@Benchmark
public void readAndWriteWithComputeMaxs_asm6_2(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asm6_2.readAndWrite(classFile, /* computeMaxs = */ true));
}
}
@Benchmark
public void readAndWriteWithComputeMaxs_asmCurrent(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asmCurrent.readAndWrite(classFile, /* computeMaxs = */ true));
}
}
@Benchmark
public void readAndWriteWithComputeMaxs_aspectJBcel(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
......@@ -335,6 +425,20 @@ public class AdapterBenchmark extends AbstractBenchmark {
}
}
@Benchmark
public void readAndWriteWithCopyPool_asm6_2(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asm6_2.readAndWriteWithCopyPool(classFile));
}
}
@Benchmark
public void readAndWriteWithCopyPool_asmCurrent(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asmCurrent.readAndWriteWithCopyPool(classFile));
}
}
@Benchmark
public void readAndWriteWithObjectModel_asm4_0(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
......@@ -362,4 +466,18 @@ public class AdapterBenchmark extends AbstractBenchmark {
blackhole.consume(asm6_1.readAndWriteWithObjectModel(classFile));
}
}
@Benchmark
public void readAndWriteWithObjectModel_asm6_2(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asm6_2.readAndWriteWithObjectModel(classFile));
}
}
@Benchmark
public void readAndWriteWithObjectModel_asmCurrent(final Blackhole blackhole) {
for (byte[] classFile : classFiles) {
blackhole.consume(asmCurrent.readAndWriteWithObjectModel(classFile));
}
}
}
......@@ -52,6 +52,8 @@ public class GeneratorBenchmark extends AbstractBenchmark {
private Generator asm5_0;
private Generator asm6_0;
private Generator asm6_1;
private Generator asm6_2;
private Generator asmCurrent;
private Generator aspectJBcel;
private Generator bcel;
private Generator cojen;
......@@ -76,6 +78,8 @@ public class GeneratorBenchmark extends AbstractBenchmark {
asm5_0 = (Generator) new AsmBenchmarkFactory(AsmVersion.V5_0).newAsmBenchmark();
asm6_0 = (Generator) new AsmBenchmarkFactory(AsmVersion.V6_0).newAsmBenchmark();
asm6_1 = (Generator) new AsmBenchmarkFactory(AsmVersion.V6_1).newAsmBenchmark();
asm6_2 = (Generator) new AsmBenchmarkFactory(AsmVersion.V6_2).newAsmBenchmark();
asmCurrent = (Generator) new AsmBenchmarkFactory(AsmVersion.V_CURRENT).newAsmBenchmark();
aspectJBcel = new AspectJBCELGenerator();
bcel = new BCELGenerator();
cojen = new CojenGenerator();
......@@ -89,7 +93,9 @@ public class GeneratorBenchmark extends AbstractBenchmark {
if (!asm4_0.getVersion().equals("ASM4")
|| !asm5_0.getVersion().equals("ASM5")
|| !asm6_0.getVersion().equals("ASM6")
|| !asm6_1.getVersion().equals("ASM6")) {
|| !asm6_1.getVersion().equals("ASM6")
|| !asm6_2.getVersion().equals("ASM6")
|| !asmCurrent.getVersion().equals("ASM6")) {
throw new IllegalStateException();
}
}
......@@ -114,6 +120,16 @@ public class GeneratorBenchmark extends AbstractBenchmark {
return asm6_1.generateClass();
}
@Benchmark
public byte[] asm6_2() {
return asm6_2.generateClass();
}
@Benchmark
public byte[] asmCurrent() {
return asmCurrent.generateClass();
}
@Benchmark
public byte[] aspectJBcel() {
return aspectJBcel.generateClass();
......
......@@ -52,6 +52,8 @@ public class MemoryBenchmark extends AbstractBenchmark {
private Factory asm5_0;
private Factory asm6_0;
private Factory asm6_1;
private Factory asm6_2;
private Factory asmCurrent;
public MemoryBenchmark() {
super("org.objectweb.asm.benchmarks.ASMFactory");
......@@ -69,12 +71,16 @@ public class MemoryBenchmark extends AbstractBenchmark {
asm5_0 = (Factory) new AsmBenchmarkFactory(AsmVersion.V5_0).newAsmBenchmark();
asm6_0 = (Factory) new AsmBenchmarkFactory(AsmVersion.V6_0).newAsmBenchmark();
asm6_1 = (Factory) new AsmBenchmarkFactory(AsmVersion.V6_1).newAsmBenchmark();
asm6_2 = (Factory) new AsmBenchmarkFactory(AsmVersion.V6_2).newAsmBenchmark();
asmCurrent = (Factory) new AsmBenchmarkFactory(AsmVersion.V_CURRENT).newAsmBenchmark();
// Check that the correct versions of ASM have been loaded.
if (!asm4_0.getVersion().equals("ASM4")
|| !asm5_0.getVersion().equals("ASM5")
|| !asm6_0.getVersion().equals("ASM6")
|| !asm6_1.getVersion().equals("ASM6")) {
|| !asm6_1.getVersion().equals("ASM6")
|| !asm6_2.getVersion().equals("ASM6")
|| !asmCurrent.getVersion().equals("ASM6")) {
throw new IllegalStateException();
}
......@@ -109,6 +115,20 @@ public class MemoryBenchmark extends AbstractBenchmark {
}
}
@Benchmark
public void newClass_asm6_2() {
for (byte[] classFile : classFiles) {
MemoryProfiler.keepReference(asm6_2.newClass(classFile));
}
}
@Benchmark
public void newClass_asmCurrent() {
for (byte[] classFile : classFiles) {
MemoryProfiler.keepReference(asmCurrent.newClass(classFile));
}
}
@Benchmark
public void newClassNode_asm4_0() {
for (byte[] classFile : classFiles) {
......@@ -136,4 +156,18 @@ public class MemoryBenchmark extends AbstractBenchmark {
MemoryProfiler.keepReference(asm6_1.newClassNode(classFile));
}
}
@Benchmark
public void newClassNode_asm6_2() {
for (byte[] classFile : classFiles) {
MemoryProfiler.keepReference(asm6_2.newClassNode(classFile));
}
}
@Benchmark
public void newClassNode_asmCurrent() {
for (byte[] classFile : classFiles) {
MemoryProfiler.keepReference(asmCurrent.newClassNode(classFile));
}
}
}
......@@ -32,7 +32,7 @@ buildscript {
plugins { id 'biz.aQute.bnd.builder' version '3.3.0' apply false }
plugins { id 'com.github.sherter.google-java-format' version '0.7.1' apply false }
plugins { id 'me.champeau.gradle.jmh' version '0.4.5' apply false }
plugins { id 'me.champeau.gradle.jmh' version '0.4.7' apply false }
plugins { id 'org.sonarqube' version '2.6.2' apply false }
description = 'ASM, a very small and fast Java bytecode manipulation framework'
......@@ -128,7 +128,7 @@ project(':benchmarks') {
'org.javassist:javassist:3.21.0-GA',
'org.mozilla:rhino:1.7.7.1'
]
['4.0', '5.0.1', '6.0'].each { version ->
['4.0', '5.0.1', '6.0', '6.1.1', '6.2.1'].each { version ->
configurations.create("asm${version}")
dependencies.add("asm${version}", "org.ow2.asm:asm:${version}@jar")
dependencies.add("asm${version}", "org.ow2.asm:asm-tree:${version}@jar")
......@@ -139,7 +139,7 @@ project(':benchmarks') {
classes.dependsOn "asm${version}"
}
jmh {
jmhVersion = '1.20'
resultFormat = 'CSV'
profilers = ['org.objectweb.asm.benchmarks.MemoryProfiler']
if (rootProject.hasProperty('jmhInclude')) {
include = [jmhInclude]
......
......@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment