下面列出了io.netty.util.ResourceLeakDetector.Level#org.openjdk.jmh.runner.options.OptionsBuilder 实例代码,或者点击链接到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();
}
@Test
public void runBenchmarks() throws RunnerException {
Options opt = new OptionsBuilder()
.include(this.getClass().getSimpleName())
.mode(Mode.AverageTime)
.timeUnit(MILLISECONDS)
.warmupIterations(2)
.warmupTime(TimeValue.seconds(2))
.measurementIterations(10)
.measurementTime(TimeValue.seconds(2))
.threads(1)
.warmupForks(0)
.forks(1)
.shouldFailOnError(true)
.shouldDoGC(true)
.result("benchmarks/performance-results.csv")
.resultFormat(ResultFormatType.CSV)
.jvmArgs("-server", "-Xms2048M", "-Xmx2048M", "-XX:+UseG1GC")
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
System.out.println("Running benchmark with specialization " + (SPECIALIZE ? "ON" : "OFF"));
Options opt = new OptionsBuilder()
.include(DkDirectScopebindBenchmark.class.getSimpleName())
.forks(2)
.warmupIterations(3)
.warmupTime(TimeValue.seconds(1L))
.measurementIterations(10)
.measurementTime(TimeValue.seconds(2L))
.mode(Mode.AverageTime)
.timeUnit(TimeUnit.NANOSECONDS)
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws Exception {
Client client = new Client();
for (int i = 0; i < 60; i++) {
try {
System.out.println(client.getUser());
break;
} catch (Exception e) {
Thread.sleep(1000);
}
}
client.close();
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 RunnerException {
Options opt = new OptionsBuilder()
.include(LogBenchmark.class.getSimpleName())
.warmupIterations(5)
.measurementIterations(5)
.addProfiler("gc")
.forks(1)
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(".*" + MeterBenchMark.class.getSimpleName() + ".*")
.warmupIterations(3)
.measurementIterations(5)
.threads(32)
.forks(1)
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(OriginalSymSpellBenchmark.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(".*" + MessageBufferBenchmarks_PutPeekTake.class.getSimpleName() + ".*")
.threads(40)
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(GarmadonSerializationRegistryBenchmark.class.getSimpleName())
.build();
new Runner(opt).run();
}
public static void main(String[] args)
throws RunnerException
{
Options options = new OptionsBuilder()
.verbosity(VerboseMode.NORMAL)
.include(".*" + BenchmarkDecimalAggregation.class.getSimpleName() + ".*")
.build();
new Runner(options).run();
}
public static void main(String[] args)
throws RunnerException
{
Options options = new OptionsBuilder()
.verbosity(VerboseMode.NORMAL)
.threads(getInteger("threads", 1))
.include(".*" + BenchmarkCPUCounters.class.getSimpleName() + ".*")
.build();
new Runner(options).run();
}
public static void main(String[] args)
throws RunnerException {
Options options = new OptionsBuilder()
.verbosity(VerboseMode.NORMAL)
.include(".*" + StreamNetworkThroughputBenchmarkExecutor.class.getCanonicalName() + ".*")
.build();
new Runner(options).run();
}
protected ChainedOptionsBuilder newOptionsBuilder() throws Exception {
String className = getClass().getSimpleName();
ChainedOptionsBuilder runnerOptions = new OptionsBuilder()
.include(".*" + className + ".*")
.jvmArgs(jvmArgs());
if (getWarmupIterations() > 0) {
runnerOptions.warmupIterations(getWarmupIterations());
}
if (getMeasureIterations() > 0) {
runnerOptions.measurementIterations(getMeasureIterations());
}
if (getReportDir() != null) {
String filePath = getReportDir() + className + ".json";
File file = new File(filePath);
if (file.exists()) {
file.delete();
} else {
file.getParentFile().mkdirs();
file.createNewFile();
}
runnerOptions.resultFormat(ResultFormatType.JSON);
runnerOptions.result(filePath);
}
return runnerOptions;
}
public static void main(String[] args)
throws Exception
{
// assure the benchmarks are valid before running
BenchmarkData data = new BenchmarkData();
data.setup();
new BenchmarkOrcDecimalReader().readDecimal(data);
Options options = new OptionsBuilder()
.verbosity(VerboseMode.NORMAL)
.include(".*" + BenchmarkOrcDecimalReader.class.getSimpleName() + ".*")
.build();
new Runner(options).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(JMHSample_24_Inheritance.class.getSimpleName())
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws Exception {
new Runner(
new OptionsBuilder()
.include(PooledComponentBenchmark.class.getName() + ".*")
.param("entityCount", "1024", "4096")
.build())
.run();
}
public static void main(String[] args) throws RunnerException {
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 RunnerException
{
Options options = new OptionsBuilder()
.verbosity(VerboseMode.NORMAL)
.include(".*" + BenchmarkScanFilterAndProjectOperator.class.getSimpleName() + ".*")
.build();
new Runner(options).run();
}
public static void main(String[] args)
throws RunnerException
{
Options options = new OptionsBuilder()
.verbosity(VerboseMode.NORMAL)
.include(".*" + BenchmarkHashBuildAndJoinOperators.class.getSimpleName() + ".*")
.build();
new Runner(options).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(ApproxLogBench.class.getSimpleName())
.warmupIterations(5)
.measurementIterations(5)
.forks(1)
.resultFormat(ResultFormatType.CSV)
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(ColumnSizeLookup.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(RawKVGetBenchmark.class.getSimpleName()) //
.warmupIterations(1) //
.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 {
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 main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.verbosity(VerboseMode.NORMAL)
.include(".*" + ListStateBenchmark.class.getCanonicalName() + ".*")
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(((Class) SmoothlyDecayingRollingCounterBenchmark.class).getSimpleName())
.warmupIterations(5)
.measurementIterations(5)
.threads(4)
.forks(1)
.build();
try {
new Runner(opt).run();
} catch (RunnerException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(FirstBenchmark.class.getSimpleName())
.forks(1)
.warmupIterations(5)
.measurementIterations(5)
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(".*" + SparkBenchmarks.class.getSimpleName() + ".*")
.build();
new Runner(opt).run();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(MeterRegistrationBenchmark.class.getSimpleName())
.warmupIterations(2)
.measurementIterations(5)
.mode(Mode.SampleTime)
.timeUnit(TimeUnit.SECONDS)
.forks(1)
.build();
new Runner(opt).run();
}
@Test
public void givenPrimesCalculated_whenUsingPoolsAndOneThread_thenOneThreadSlowest() {
Options opt = new OptionsBuilder()
.include(Benchmarker.class.getSimpleName())
.forks(1)
.build();
try {
new Runner(opt).run();
} catch (RunnerException e) {
fail();
}
}
public static void main(String[] args)
throws RunnerException
{
Options options = new OptionsBuilder()
.verbosity(VerboseMode.NORMAL)
.include(".*" + BenchmarkStringFunctions.class.getSimpleName() + ".*")
.build();
new Runner(options).run();
}