public class ClassByImplementationBenchmark extends Object
This benchmark dynamically creates a class which implements ExampleInterface
which overrides all methods to invoke the direct super class's implementation. The benchmark furthermore creates an
instance of this class since some code generation frameworks rely on this property.
Note that this class defines all values that are accessed by benchmark methods as instance fields. This way, the JIT compiler's capability of constant folding is limited in order to produce more comparable test results.
| Modifier and Type | Field and Description |
|---|---|
static Class<? extends ExampleInterface> |
BASE_CLASS
The base class to be subclassed in all benchmarks.
|
static boolean |
DEFAULT_BOOLEAN_VALUE
The default
boolean value. |
static byte |
DEFAULT_BYTE_VALUE
The default
byte value. |
static char |
DEFAULT_CHAR_VALUE
The default
char value. |
static double |
DEFAULT_DOUBLE_VALUE
The default
double value. |
static float |
DEFAULT_FLOAT_VALUE
The default
float value. |
static int |
DEFAULT_INT_VALUE
The default
int value. |
static long |
DEFAULT_LONG_VALUE
The default
long value. |
static String |
DEFAULT_REFERENCE_VALUE
The default reference value.
|
static short |
DEFAULT_SHORT_VALUE
The default
short value. |
| Constructor and Description |
|---|
ClassByImplementationBenchmark() |
| Modifier and Type | Method and Description |
|---|---|
ExampleInterface |
baseline()
Creates a baseline for the benchmark.
|
ExampleInterface |
benchmarkByteBuddy()
Performs a benchmark of an interface implementation using Byte Buddy.
|
ExampleInterface |
benchmarkByteBuddyWithTypePool()
Performs a benchmark of an interface implementation using Byte Buddy.
|
ExampleInterface |
benchmarkCglib()
Performs a benchmark of an interface implementation using cglib.
|
ExampleInterface |
benchmarkJavassist()
Performs a benchmark of an interface implementation using javassist proxies.
|
ExampleInterface |
benchmarkJdkProxy()
Performs a benchmark of an interface implementation using the Java Class Library's utilities.
|
void |
setup()
Sets up this benchmark.
|
public static final Class<? extends ExampleInterface> BASE_CLASS
@AlwaysNull public static final String DEFAULT_REFERENCE_VALUE
public static final boolean DEFAULT_BOOLEAN_VALUE
boolean value.public static final byte DEFAULT_BYTE_VALUE
byte value.public static final short DEFAULT_SHORT_VALUE
short value.public static final char DEFAULT_CHAR_VALUE
char value.public static final int DEFAULT_INT_VALUE
int value.public static final long DEFAULT_LONG_VALUE
long value.public static final float DEFAULT_FLOAT_VALUE
float value.public static final double DEFAULT_DOUBLE_VALUE
double value.public void setup()
public ExampleInterface baseline()
public ExampleInterface benchmarkByteBuddy() throws Exception
Exception - If the reflective invocation causes an exception.public ExampleInterface benchmarkByteBuddyWithTypePool() throws Exception
Exception - If the reflective invocation causes an exception.public ExampleInterface benchmarkCglib()
public ExampleInterface benchmarkJavassist() throws Exception
Exception - If the reflective invocation causes an exception.public ExampleInterface benchmarkJdkProxy() throws Exception
Exception - If the reflective invocation causes an exception.Copyright © 2014–2023. All rights reserved.