下面列出了io.netty.util.ResourceLeakDetector.Level#org.openjdk.jmh.runner.Runner 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void launchBenchmark() throws Exception {
Options opt = new OptionsBuilder()
.include(this.getClass().getName() + ".*")
.mode(Mode.SampleTime)
.timeUnit(TimeUnit.MICROSECONDS)
.warmupIterations(1)
.warmupTime(TimeValue.seconds(1))
.measurementIterations(1)
.measurementTime(TimeValue.seconds(5))
.threads(2)
.forks(0)
.syncIterations(true)
.shouldFailOnError(true)
.shouldDoGC(false)
.jvmArgs("-Xms1G", "-Xmx1G", "-XX:MaxGCPauseMillis=10", "-XX:GCPauseIntervalMillis=100")
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws Exception {
ResourceLeakDetector.setLevel(Level.DISABLED);
// CtClass.debugDump = "d:/debugDump";
// RestClientBenchmark clientBenchmark = new RestClientBenchmark();
// System.out.println(clientBenchmark.createUser());
// clientBenchmark.close();
Options opt = new OptionsBuilder()//
.include(RestClientBenchmark.class.getSimpleName())//
.warmupIterations(5)//
.measurementIterations(5)//
.threads(CONCURRENCY)//
.forks(1)//
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws Exception {
ConvertInputStreamToStringBenchmark test = new ConvertInputStreamToStringBenchmark();
System.out.println();
System.out.println("1. apacheToInputStream : " + test.test1_apacheToInputStream().length());
System.out.println("2. guavaCharStreams : " + test.test2_guavaCharStreams().length());
System.out.println("3. jdkScanner : " + test.test3_jdkScanner().length());
System.out.println("4. jdkJava8 : " + test.test4_jdkJava8().length());
System.out.println("5. jdkJava8parallel : " + test.test5_jdkJava8parallel().length());
System.out.println("6. inputStreamReaderAndStringBuilder : " + test.test6_inputStreamReaderAndStringBuilder().length());
System.out.println("7. apacheStringWriterAndIOUtilsCopy : " + test.test7_apacheStringWriterAndIOUtilsCopy().length());
System.out.println("8. readByteArrayOutputStream : " + test.test8_readByteArrayOutputStream().length());
System.out.println("9. bufferedReaderReadLine : " + test.test9_bufferedReaderReadLine().length());
System.out.println("10. bufferedInputStreamAndByteArrayOutputStream : " + test.test10_bufferedInputStreamAndByteArrayOutputStream().length());
System.out.println("11. inputStreamReadAndStringBuilder : " + test.test11_inputStreamReadAndStringBuilder().length());
System.out.println();
Options opt = new OptionsBuilder()
.include(ConvertInputStreamToStringBenchmark.class.getSimpleName())
.build();
new Runner(opt).run();
}
@Test
public void testCompareQuery() throws SQLException, RunnerException {
Options options = new OptionsBuilder()
.include(getClass().getName() + ".*")
.mode(Mode.SingleShotTime)
.timeUnit(TimeUnit.MILLISECONDS)
.warmupTime(TimeValue.seconds(5))
.warmupIterations(2)
.measurementTime(TimeValue.seconds(10))
.measurementIterations(5)
.threads(1)
.forks(2)
.build();
try {
new Runner(options).run();
} catch (NoBenchmarksException ignored) {
// expected? only happens from gradle
}
}
@Test
public void runJmhBenchmarks() throws Exception {
ChainedOptionsBuilder options = new OptionsBuilder()
.mode(Mode.AverageTime) // Performance metric is Average time (ms per operation)
.warmupIterations(5) // Used to warm JVM before executing benchmark tests
.measurementIterations(5)
.timeUnit(TimeUnit.MILLISECONDS)
.threads(2) // TODO: Increase the number of threads and measure performance
.forks(2) // Need to increase more forks to get more observations, increases precision.
.shouldFailOnError(true) // Will stop forking of JVM as soon as there is a compilation error
.shouldDoGC(true) // do GC between measurement iterations
.output("jmh-report.json");
// .resultFormat(ResultFormatType.JSON) // store the results in a file called jmh-report.json
// .result("jmh-report.json");
BenchmarkFinder bf = new BenchmarkFinder(getClass());
bf.findBenchmarks(options);
new Runner(options.build()).run();
}
public static void main(String[] args) throws Exception {
Options opt = new OptionsBuilder()//
.include(Client.class.getSimpleName())//
.warmupIterations(3)//
.warmupTime(TimeValue.seconds(10))//
.measurementIterations(3)//
.measurementTime(TimeValue.seconds(10))//
.threads(CONCURRENCY)//
.forks(1)//
.build();
new Runner(opt).run();
// HproseTcpClient client = new HproseTcpClient("tcp://127.0.0.1:8080");
// UserService userService = client.useService(UserService.class);
// System.out.println(userService.existUser("1"));
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(SerializationBenchmark.class.getSimpleName())
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder() //
.include(RheaKVGetBenchmark.class.getSimpleName()) //
.warmupIterations(1) //
.warmupTime(TimeValue.seconds(10)) //
.measurementIterations(3) //
.measurementTime(TimeValue.seconds(10)) //
.threads(BenchmarkUtil.CONCURRENCY) //
.forks(1) //
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(".*" + OkHttpSenderBenchmarks.class.getSimpleName() + ".*")
.build();
new Runner(opt).run();
}
public static void main(String... args) throws RunnerException, CommandLineOptionException {
CommandLineOptions commandLineOptions = new CommandLineOptions(args);
ChainedOptionsBuilder builder = new OptionsBuilder().parent(commandLineOptions)
.include(Benchmarks.class.getSimpleName())
.jvmArgsAppend("-ea");
new Runner(builder.build()).run();
}
public static void main(String... args) throws RunnerException, CommandLineOptionException {
CommandLineOptions commandLineOptions = new CommandLineOptions(args);
ChainedOptionsBuilder builder = new OptionsBuilder().parent(commandLineOptions)
.include(Benchmarks.class.getSimpleName())
.jvmArgsAppend("-ea");
new Runner(builder.build()).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(JMHSample_15_Asymmetric.class.getSimpleName())
.warmupIterations(5)
.measurementIterations(5)
.forks(1)
.build();
new Runner(opt).run();
}
/**
*
* @param args Args.
* @throws Exception Exception.
*/
public static void main(String[] args) throws Exception {
final Options options = new OptionsBuilder()
.include(JmhPartitionUpdateCounterBenchmark.class.getSimpleName())
.build();
new Runner(options).run();
}
public static void main(String[] args) throws Exception {
Options opt = new OptionsBuilder()
.include(SecondBenchmark.class.getSimpleName())
.forks(1)
.warmupIterations(5)
.measurementIterations(2)
.build();
Collection<RunResult> results = new Runner(opt).run();
ResultExporter.exportResult("单线程与多线程求和性能", results, "length", "微秒");
}
public static void runBenchmark(Class<?> benchmarkClass) throws RunnerException
{
final Options opt = new OptionsBuilder()
.include(benchmarkClass.getSimpleName())
.addProfiler(GCProfiler.class)
.shouldDoGC(true)
.warmupIterations(5)
.measurementIterations(5)
.forks(1)
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(PreDictEEBenchmark.class.getSimpleName())
.warmupIterations(5)
.measurementIterations(5)
.forks(1)
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(H3SetToMultiPolygonBenchmark.class.getSimpleName())
.forks(1)
.build();
new Runner(opt).run();
}
public static void main(String... args) throws RunnerException, CommandLineOptionException {
Options opt = new OptionsBuilder()
.parent(new CommandLineOptions())
.include(V2DefaultClientCreationBenchmark.class.getSimpleName())
.addProfiler(StackProfiler.class)
.build();
Collection<RunResult> run = new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(LitePoolBenchmark.class.getSimpleName())
.include(CommonsPool2Benchmark.class.getSimpleName())
.warmupIterations(10)
.measurementIterations(10)
.forks(1)
.resultFormat(JSON)
.result("benchmark-" + System.currentTimeMillis() + ".json")
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(FriendlyIdBenchmark.class.getSimpleName())
.build();
new Runner(opt).run();
}
public static void main(String[] args)
throws RunnerException
{
Options options = new OptionsBuilder()
.verbosity(VerboseMode.NORMAL)
.include(".*" + BenchmarkHashAndStreamingAggregationOperators.class.getSimpleName() + ".*")
.build();
new Runner(options).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.addProfiler("gc")
.include(".*" + MutableSpanBenchmarks.class.getSimpleName() + ".*")
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.addProfiler("gc")
.include(".*" + NoopAwareSpanHandlerBenchmarks.class.getSimpleName() + ".*")
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.addProfiler("gc")
.include(".*" + B3PropagationBenchmarks.class.getSimpleName())
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options options = new OptionsBuilder()
.include(FalseSharingBenchmark.class.getSimpleName())
.forks(1)
.warmupIterations(10)
.measurementIterations(10)
.threads(2)
.timeUnit(TimeUnit.MICROSECONDS)
.build();
new Runner(options).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder().include("")
// .addProfiler("stack", "lines=20;period=1;top=20")
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(HashCodesBenchmark.class.getSimpleName())
.warmupIterations(5)
.warmupTime(TimeValue.seconds(1))
.measurementIterations(1)
.measurementTime(TimeValue.seconds(3))
.forks(1)
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws Exception {
Options opt = new OptionsBuilder()//
.include(Client.class.getSimpleName())//
.warmupIterations(3)//
.warmupTime(TimeValue.seconds(10))//
.measurementIterations(3)//
.measurementTime(TimeValue.seconds(10))//
.threads(CONCURRENCY)//
.forks(1)//
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws Exception {
new Runner(
new OptionsBuilder()
.include(LegacyTransmuterBenchmark.class.getName() + ".*")
.param("entityCount", "1024", "4096")
.build())
.run();
}