@Test public void testBaseline() throws Exception { ExampleInterface instance = classByImplementationBenchmark.baseline(); assertThat(Arrays.asList(instance.getClass().getInterfaces()), hasItem(ClassByImplementationBenchmark.BASE_CLASS)); assertThat(instance.getClass().getSuperclass(), CoreMatchers.<Class<?>>is(Object.class)); assertThat(classByImplementationBenchmark.benchmarkByteBuddy().getClass(), not(CoreMatchers.<Class<?>>is(instance.getClass()))); assertReturnValues(instance); }
@Benchmark public ExampleInterface baseline() { return new ExampleInterface() { public boolean method(boolean arg) { return false; } public byte method(byte arg) { return 0; } public short method(short arg) { return 0; } public int method(int arg) { return 0; } public char method(char arg) { return 0; } public long method(long arg) { return 0; } public float method(float arg) { return 0; } public double method(double arg) { return 0; } public Object method(Object arg) { return null; } public boolean[] method(boolean arg1, boolean arg2, boolean arg3) { return null; } public byte[] method(byte arg1, byte arg2, byte arg3) { return null; } public short[] method(short arg1, short arg2, short arg3) { return null; } public int[] method(int arg1, int arg2, int arg3) { return null; } public char[] method(char arg1, char arg2, char arg3) { return null; } public long[] method(long arg1, long arg2, long arg3) { return null; } public float[] method(float arg1, float arg2, float arg3) { return null; } public double[] method(double arg1, double arg2, double arg3) { return null; } public Object[] method(Object arg1, Object arg2, Object arg3) { return null; } }; }
ClassByImplementationBenchmark { @Benchmark public ExampleInterface baseline() { return new ExampleInterface() { public boolean method(boolean arg) { return false; } public byte method(byte arg) { return 0; } public short method(short arg) { return 0; } public int method(int arg) { return 0; } public char method(char arg) { return 0; } public long method(long arg) { return 0; } public float method(float arg) { return 0; } public double method(double arg) { return 0; } public Object method(Object arg) { return null; } public boolean[] method(boolean arg1, boolean arg2, boolean arg3) { return null; } public byte[] method(byte arg1, byte arg2, byte arg3) { return null; } public short[] method(short arg1, short arg2, short arg3) { return null; } public int[] method(int arg1, int arg2, int arg3) { return null; } public char[] method(char arg1, char arg2, char arg3) { return null; } public long[] method(long arg1, long arg2, long arg3) { return null; } public float[] method(float arg1, float arg2, float arg3) { return null; } public double[] method(double arg1, double arg2, double arg3) { return null; } public Object[] method(Object arg1, Object arg2, Object arg3) { return null; } }; } }
ClassByImplementationBenchmark { @Benchmark public ExampleInterface baseline() { return new ExampleInterface() { public boolean method(boolean arg) { return false; } public byte method(byte arg) { return 0; } public short method(short arg) { return 0; } public int method(int arg) { return 0; } public char method(char arg) { return 0; } public long method(long arg) { return 0; } public float method(float arg) { return 0; } public double method(double arg) { return 0; } public Object method(Object arg) { return null; } public boolean[] method(boolean arg1, boolean arg2, boolean arg3) { return null; } public byte[] method(byte arg1, byte arg2, byte arg3) { return null; } public short[] method(short arg1, short arg2, short arg3) { return null; } public int[] method(int arg1, int arg2, int arg3) { return null; } public char[] method(char arg1, char arg2, char arg3) { return null; } public long[] method(long arg1, long arg2, long arg3) { return null; } public float[] method(float arg1, float arg2, float arg3) { return null; } public double[] method(double arg1, double arg2, double arg3) { return null; } public Object[] method(Object arg1, Object arg2, Object arg3) { return null; } }; }  }
ClassByImplementationBenchmark { @Benchmark public ExampleInterface baseline() { return new ExampleInterface() { public boolean method(boolean arg) { return false; } public byte method(byte arg) { return 0; } public short method(short arg) { return 0; } public int method(int arg) { return 0; } public char method(char arg) { return 0; } public long method(long arg) { return 0; } public float method(float arg) { return 0; } public double method(double arg) { return 0; } public Object method(Object arg) { return null; } public boolean[] method(boolean arg1, boolean arg2, boolean arg3) { return null; } public byte[] method(byte arg1, byte arg2, byte arg3) { return null; } public short[] method(short arg1, short arg2, short arg3) { return null; } public int[] method(int arg1, int arg2, int arg3) { return null; } public char[] method(char arg1, char arg2, char arg3) { return null; } public long[] method(long arg1, long arg2, long arg3) { return null; } public float[] method(float arg1, float arg2, float arg3) { return null; } public double[] method(double arg1, double arg2, double arg3) { return null; } public Object[] method(Object arg1, Object arg2, Object arg3) { return null; } }; }  @Setup void setup(); @Benchmark ExampleInterface baseline(); @Benchmark ExampleInterface benchmarkByteBuddy(); @Benchmark ExampleInterface benchmarkByteBuddyWithTypePool(); @Benchmark ExampleInterface benchmarkCglib(); @Benchmark ExampleInterface benchmarkJavassist(); @Benchmark ExampleInterface benchmarkJdkProxy(); }
ClassByImplementationBenchmark { @Benchmark public ExampleInterface baseline() { return new ExampleInterface() { public boolean method(boolean arg) { return false; } public byte method(byte arg) { return 0; } public short method(short arg) { return 0; } public int method(int arg) { return 0; } public char method(char arg) { return 0; } public long method(long arg) { return 0; } public float method(float arg) { return 0; } public double method(double arg) { return 0; } public Object method(Object arg) { return null; } public boolean[] method(boolean arg1, boolean arg2, boolean arg3) { return null; } public byte[] method(byte arg1, byte arg2, byte arg3) { return null; } public short[] method(short arg1, short arg2, short arg3) { return null; } public int[] method(int arg1, int arg2, int arg3) { return null; } public char[] method(char arg1, char arg2, char arg3) { return null; } public long[] method(long arg1, long arg2, long arg3) { return null; } public float[] method(float arg1, float arg2, float arg3) { return null; } public double[] method(double arg1, double arg2, double arg3) { return null; } public Object[] method(Object arg1, Object arg2, Object arg3) { return null; } }; }  @Setup void setup(); @Benchmark ExampleInterface baseline(); @Benchmark ExampleInterface benchmarkByteBuddy(); @Benchmark ExampleInterface benchmarkByteBuddyWithTypePool(); @Benchmark ExampleInterface benchmarkCglib(); @Benchmark ExampleInterface benchmarkJavassist(); @Benchmark ExampleInterface benchmarkJdkProxy(); static final Class<? extends ExampleInterface> BASE_CLASS; static final String DEFAULT_REFERENCE_VALUE; static final boolean DEFAULT_BOOLEAN_VALUE; static final byte DEFAULT_BYTE_VALUE; static final short DEFAULT_SHORT_VALUE; static final char DEFAULT_CHAR_VALUE; static final int DEFAULT_INT_VALUE; static final long DEFAULT_LONG_VALUE; static final float DEFAULT_FLOAT_VALUE; static final double DEFAULT_DOUBLE_VALUE; }