< prev index next >

test/micro/org/openjdk/bench/java/lang/invoke/LookupDefineClass.java

Print this page




 184         public void doSetup() {
 185             loader = new XLoader();
 186             loader.install("foo.AnonymousHost", FOO_HOST_BYTES);
 187         }
 188     }
 189 
 190 
 191     @State(Scope.Thread)
 192     @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 193     @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 194     @Fork(3)
 195     @BenchmarkMode(Mode.AverageTime)
 196     @OutputTimeUnit(TimeUnit.NANOSECONDS)
 197     public static class WeakClass {
 198         private static final MethodHandles.Lookup HOST_LOOKUP =
 199                 defineHostClass(new Loader("weak-class-loader"), "foo.AnonymousHost", FOO_HOST_BYTES);
 200 
 201         @Benchmark
 202         public Class<?> load() throws ClassNotFoundException {
 203             try {
 204                 return HOST_LOOKUP.defineHiddenClass(X_BYTECODE, false, WEAK).lookupClass();
 205             } catch (IllegalAccessException e) {
 206                 throw new InternalError(e);
 207             }
 208         }
 209 
 210         public static void main(String[] args) throws RunnerException {
 211             Options opt = new OptionsBuilder()
 212                     .include(LookupDefineClass.WeakClass.class.getSimpleName())
 213                     // .addProfiler(ClassloaderProfiler.class)
 214                     // .addProfiler(CompilerProfiler.class)
 215                     .build();
 216 
 217             new Runner(opt).run();
 218         }
 219     }
 220 
 221     @State(Scope.Thread)
 222     @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 223     @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 224     @Fork(3)


 252             f.setAccessible(true);
 253             return (sun.misc.Unsafe)f.get(null);
 254         } catch (ReflectiveOperationException e) {
 255             throw new RuntimeException(e);
 256         }
 257     }
 258 
 259     @State(Scope.Thread)
 260     @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 261     @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 262     @Fork(3)
 263     @BenchmarkMode(Mode.AverageTime)
 264     @OutputTimeUnit(TimeUnit.NANOSECONDS)
 265     public static class HiddenClass {
 266         private static final MethodHandles.Lookup HOST_LOOKUP =
 267                 defineHostClass(new Loader("hidden-class-loader"),"foo.AnonymousHost", FOO_HOST_BYTES);
 268 
 269         @Benchmark
 270         public Class<?> load() throws ClassNotFoundException {
 271             try {
 272                 return HOST_LOOKUP.defineHiddenClass(X_BYTECODE, false).lookupClass();
 273             } catch (IllegalAccessException e) {
 274                 throw new InternalError(e);
 275             }
 276         }
 277 
 278         public static void main(String[] args) throws RunnerException {
 279             Options opt = new OptionsBuilder()
 280                     .include(LookupDefineClass.HiddenClass.class.getSimpleName())
 281                     // .addProfiler(ClassloaderProfiler.class)
 282                     // .addProfiler(CompilerProfiler.class)
 283                     .build();
 284 
 285             new Runner(opt).run();
 286         }
 287     }
 288 }


 184         public void doSetup() {
 185             loader = new XLoader();
 186             loader.install("foo.AnonymousHost", FOO_HOST_BYTES);
 187         }
 188     }
 189 
 190 
 191     @State(Scope.Thread)
 192     @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 193     @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 194     @Fork(3)
 195     @BenchmarkMode(Mode.AverageTime)
 196     @OutputTimeUnit(TimeUnit.NANOSECONDS)
 197     public static class WeakClass {
 198         private static final MethodHandles.Lookup HOST_LOOKUP =
 199                 defineHostClass(new Loader("weak-class-loader"), "foo.AnonymousHost", FOO_HOST_BYTES);
 200 
 201         @Benchmark
 202         public Class<?> load() throws ClassNotFoundException {
 203             try {
 204                 return HOST_LOOKUP.defineHiddenClass(X_BYTECODE, false).lookupClass();
 205             } catch (IllegalAccessException e) {
 206                 throw new InternalError(e);
 207             }
 208         }
 209 
 210         public static void main(String[] args) throws RunnerException {
 211             Options opt = new OptionsBuilder()
 212                     .include(LookupDefineClass.WeakClass.class.getSimpleName())
 213                     // .addProfiler(ClassloaderProfiler.class)
 214                     // .addProfiler(CompilerProfiler.class)
 215                     .build();
 216 
 217             new Runner(opt).run();
 218         }
 219     }
 220 
 221     @State(Scope.Thread)
 222     @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 223     @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 224     @Fork(3)


 252             f.setAccessible(true);
 253             return (sun.misc.Unsafe)f.get(null);
 254         } catch (ReflectiveOperationException e) {
 255             throw new RuntimeException(e);
 256         }
 257     }
 258 
 259     @State(Scope.Thread)
 260     @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 261     @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 262     @Fork(3)
 263     @BenchmarkMode(Mode.AverageTime)
 264     @OutputTimeUnit(TimeUnit.NANOSECONDS)
 265     public static class HiddenClass {
 266         private static final MethodHandles.Lookup HOST_LOOKUP =
 267                 defineHostClass(new Loader("hidden-class-loader"),"foo.AnonymousHost", FOO_HOST_BYTES);
 268 
 269         @Benchmark
 270         public Class<?> load() throws ClassNotFoundException {
 271             try {
 272                 return HOST_LOOKUP.defineHiddenClass(X_BYTECODE, false, STRONG).lookupClass();
 273             } catch (IllegalAccessException e) {
 274                 throw new InternalError(e);
 275             }
 276         }
 277 
 278         public static void main(String[] args) throws RunnerException {
 279             Options opt = new OptionsBuilder()
 280                     .include(LookupDefineClass.HiddenClass.class.getSimpleName())
 281                     // .addProfiler(ClassloaderProfiler.class)
 282                     // .addProfiler(CompilerProfiler.class)
 283                     .build();
 284 
 285             new Runner(opt).run();
 286         }
 287     }
 288 }
< prev index next >