Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ execute a build.
<property name="src-core" value="${basedir}/net/adoptopenjdk/bumblebench/core"/>
<property name="src-collections" value="${basedir}/net/adoptopenjdk/bumblebench/collections"/>
<property name="src-crypto" value="${basedir}/net/adoptopenjdk/bumblebench/crypto"/>
<property name="src-class" value="${basedir}/net/adoptopenjdk/bumblebench/casting/isAssignableFrom"/>
<property name="src-examples" value="${basedir}/net/adoptopenjdk/bumblebench/examples"/>
<property name="src-gpu" value="${basedir}/net/adoptopenjdk/bumblebench/gpu"/>
<property name="src-humble" value="${basedir}/net/adoptopenjdk/bumblebench/humble"/>
Expand Down Expand Up @@ -55,6 +56,15 @@ execute a build.
includeantruntime="false"
includes="**/ParallelBench.java">
</javac>
<javac srcdir="${src-class}"
destdir=""
debug="on"
source="1.8"
target="1.8"
includeantruntime="false"
includes="**/*AssignableFromBench.java">
</javac>


<!-- collections -->
<javac srcdir="${src-collections}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*******************************************************************************
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package net.adoptopenjdk.bumblebench.casting.isAssignableFrom;

import java.util.Random;

import net.adoptopenjdk.bumblebench.core.MicroBench;

public final class IsAssignableFromBench extends MicroBench {

interface Barks {}
interface Meows {}
interface Sheds {}
interface LaysEggs {}

class Animal {}
class Plant {}

class Mamal extends Animal {}
class Reptile extends Animal {}
class Canine extends Mamal {}
class Feline extends Mamal {}

class Tree extends Plant {}

class Carniferous extends Tree {}
class Deciduous extends Tree {}

class Maple extends Deciduous {}

class Dog extends Canine implements Barks {}
class Cat extends Feline {}
class Fox extends Canine implements Sheds {}
class Platypus extends Mamal implements LaysEggs {}

class Lab extends Dog implements Sheds {}
class Poodle extends Dog {}
class Calico extends Cat implements Meows, Sheds {}

static Class<?> classes[] = {Barks.class, Meows.class, Sheds.class, LaysEggs.class, Animal.class, Plant.class, Mamal.class, Reptile.class, Canine.class, Feline.class, Tree.class, Carniferous.class, Deciduous.class, Mamal.class,
Dog.class, Cat.class, Fox.class, Platypus.class, Lab.class, Poodle.class, Calico.class};

protected long doBatch(long numIterations) throws InterruptedException {
pauseTimer();


Random r = new Random(1);
int length = classes.length;
boolean b = false;
for (long i = 0; i < numIterations; i++)
{
int first = r.nextInt(length);
int second = r.nextInt(length);
startTimer();
b = b ^ classes[first].isAssignableFrom(classes[second]);
pauseTimer();
}
return numIterations;
}
}

1 change: 1 addition & 0 deletions net/adoptopenjdk/bumblebench/core/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static void runBumbleMainOn(BumbleBench instance) throws NoSuchMethodException,
+ ":net.adoptopenjdk.bumblebench.string"
+ ":net.adoptopenjdk.bumblebench.humble"
+ ":net.adoptopenjdk.bumblebench.arraycopy"
+ ":net.adoptopenjdk.bumblebench.casting.isAssignableFrom"
;

public static Class loadTestClass(String[] packageNames, String name) throws ClassNotFoundException, IOException {
Expand Down